PiotrSty commited on
Commit
48a097a
·
1 Parent(s): 106f3f1

fix(ontology): version Sejm build protocol

Browse files

Align PR #18 with the Slayer Research Ontology v0.1 without changing the
published speech records.

The update versions the filtering protocol by content digest and immutable
commit URI. A follow-up metadata commit adds the complete Object, Version,
Relation, Protocol, Run, Evidence, Claim and Actor graph, plus contract tests
for references, acyclicity, immutable payload URIs and artifact checksums.

The data Parquet and attribution sidecar are reproduced from the pinned source
and must retain their previously published SHA-256 digests.

Files changed (1) hide show
  1. src/fetch_sejm_api_2011_2022.py +362 -19
src/fetch_sejm_api_2011_2022.py CHANGED
@@ -7,10 +7,13 @@ import argparse
7
  import collections
8
  import datetime as dt
9
  import hashlib
 
10
  import json
11
  import pathlib
 
12
  import re
13
  import shutil
 
14
  from typing import Any
15
 
16
 
@@ -90,7 +93,14 @@ def registry_entry() -> str:
90
 
91
  def update_registry(registry: str) -> str:
92
  if re.search(rf'^\s{{4}}["\']{SOURCE_NAME}["\']\s*:', registry, re.MULTILINE):
93
- raise BuildError(f"{SOURCE_NAME} already exists in the target registry")
 
 
 
 
 
 
 
94
  marker = ' "sejm_api": {'
95
  if registry.count(marker) != 1:
96
  raise BuildError("cannot locate the accepted sejm_api registry entry")
@@ -193,14 +203,25 @@ third-party rights and provider-specific limitations.
193
  def contract_test() -> str:
194
  return f'''"""Contract checks for the {SOURCE_NAME} contribution."""
195
 
 
196
  import json
197
  import pathlib
 
198
 
199
  import pyarrow.parquet as pq
200
 
201
 
202
  ROOT = pathlib.Path(__file__).resolve().parents[1]
203
  DATA = ROOT / "data" / "{SOURCE_NAME}"
 
 
 
 
 
 
 
 
 
204
 
205
 
206
  def test_artifacts_and_schema():
@@ -223,14 +244,114 @@ def test_attribution_count_and_legal_evidence():
223
  legal = json.loads((DATA / "{SOURCE_NAME}.license-evidence.json").read_text(encoding="utf-8"))
224
  assert legal["status"] == "reviewed-open-official-materials"
225
  assert legal["pinned_source"].endswith(stats["source_revision"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  '''
227
 
228
 
229
  def build(args: argparse.Namespace) -> dict[str, Any]:
 
230
  if not COMMIT_PATTERN.fullmatch(args.source_revision):
231
  raise BuildError("source revision must be a 40-character commit")
232
  if not COMMIT_PATTERN.fullmatch(args.target_revision):
233
  raise BuildError("target revision must be a 40-character commit")
 
 
 
 
234
  if not args.target_registry.is_file():
235
  raise BuildError("target sources.py is missing")
236
 
@@ -358,33 +479,250 @@ def build(args: argparse.Namespace) -> dict[str, Any]:
358
  "stats_sha256": sha256_file(stats_path),
359
  "legal_evidence_sha256": sha256_file(legal_path),
360
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  version_digest = canonical_sha256({
362
  "source_revision": args.source_revision, "target_revision": args.target_revision,
363
  "range": [START_DATE, END_DATE], "artifacts": artifact_digests,
364
  })
 
365
  version_id = f"slayer://version/dataset-source/{SOURCE_NAME}@sha256:{version_digest}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  manifest = {
367
  "schema_version": "slayer.ai/dataset-source-contribution/v1",
368
- "object": {"id": f"slayer://object/dataset-source/{SOURCE_NAME}", "kind": "dataset_source", "name": SOURCE_NAME},
369
- "version": {"id": version_id, "digest": f"sha256:{version_digest}"},
370
- "protocol": {"entrypoint": "python src/fetch_sejm_api_2011_2022.py", "configuration": {"start_date": START_DATE, "end_date": END_DATE, "tokenizer": "cl100k_base"}},
371
- "run": {"id": args.run_id, "actor_id": args.actor, "inputs": [
372
- {"role": "source", "version_id": f"hf://datasets/{SOURCE_REPOSITORY}@{args.source_revision}"},
373
- {"role": "target_base", "version_id": f"hf://datasets/{TARGET_REPOSITORY}@{args.target_revision}"},
374
- ], "outputs": [{"role": "dataset_source", "version_id": version_id}]},
375
- "evidence": [
376
- {"observation_type": "dataset_record_counts", "payload": stats},
377
- {"observation_type": "known_temporal_overlap", "payload": {"parliamentary": "1991-2019", "parlamint_pl_registered": "2015-2022", "novelty_claimed": False}},
378
- {"observation_type": "artifact_checksums", "payload": artifact_digests},
379
- ],
380
- "claims": [
381
- {"statement": "All retained records from the pinned source dated 2011-2022 are included after exact within-source deduplication.", "falsification_condition": "A qualifying pinned-source record is absent without a recorded drop reason."},
382
- {"statement": "Every contributed document has non-empty speaker attribution.", "falsification_condition": "Any contributed author field is empty."},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  ],
 
 
 
 
 
 
 
384
  "attestations": [
385
- {"type": "schema_valid", "value": True, "fields": list(EXPECTED_FIELDS)},
386
- {"type": "temporal_overlap", "value": "known_and_disclosed"},
387
- {"type": "speaker_attribution", "value": "100_percent"},
 
 
388
  ],
389
  }
390
  write_json(artifact_dir / f"{SOURCE_NAME}_ontology_manifest.json", manifest)
@@ -403,6 +741,11 @@ def main() -> int:
403
  parser.add_argument("--output", type=pathlib.Path, required=True)
404
  parser.add_argument("--source-revision", required=True)
405
  parser.add_argument("--target-revision", required=True)
 
 
 
 
 
406
  parser.add_argument("--added-date", default=dt.datetime.now(dt.timezone.utc).date().isoformat())
407
  parser.add_argument("--actor", default="hf:PiotrSty")
408
  parser.add_argument("--run-id", default=f"sejm-api-2011-2022-{dt.datetime.now(dt.timezone.utc).strftime('%Y%m%dT%H%M%SZ')}")
 
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
 
 
93
 
94
  def update_registry(registry: str) -> str:
95
  if re.search(rf'^\s{{4}}["\']{SOURCE_NAME}["\']\s*:', registry, re.MULTILINE):
96
+ required = (
97
+ '"file_key": "sejm_api_2011_2022"',
98
+ '"license_spdx": "LicenseRef-Polish-Official-Documents"',
99
+ '"upstream": "https://api.sejm.gov.pl/"',
100
+ )
101
+ if not all(value in registry for value in required):
102
+ raise BuildError(f"existing {SOURCE_NAME} registry entry differs from the contract")
103
+ return registry
104
  marker = ' "sejm_api": {'
105
  if registry.count(marker) != 1:
106
  raise BuildError("cannot locate the accepted sejm_api registry entry")
 
203
  def contract_test() -> str:
204
  return f'''"""Contract checks for the {SOURCE_NAME} contribution."""
205
 
206
+ import hashlib
207
  import json
208
  import pathlib
209
+ import re
210
 
211
  import pyarrow.parquet as pq
212
 
213
 
214
  ROOT = pathlib.Path(__file__).resolve().parents[1]
215
  DATA = ROOT / "data" / "{SOURCE_NAME}"
216
+ MANIFEST = ROOT / "artifacts" / "{SOURCE_NAME}_ontology_manifest.json"
217
+
218
+
219
+ def sha256_file(path):
220
+ digest = hashlib.sha256()
221
+ with path.open("rb") as stream:
222
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
223
+ digest.update(chunk)
224
+ return digest.hexdigest()
225
 
226
 
227
  def test_artifacts_and_schema():
 
244
  legal = json.loads((DATA / "{SOURCE_NAME}.license-evidence.json").read_text(encoding="utf-8"))
245
  assert legal["status"] == "reviewed-open-official-materials"
246
  assert legal["pinned_source"].endswith(stats["source_revision"])
247
+
248
+
249
+ def test_ontology_kernel_and_references():
250
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
251
+ required = {{
252
+ "object", "version", "protocol", "run", "relations", "evidence",
253
+ "claims", "claim_evidence", "actors", "attestations",
254
+ }}
255
+ assert required <= set(manifest)
256
+ assert manifest["ontology_version"] == "slayer.ai/research-ontology/v0.1"
257
+
258
+ actor_ids = {{item["id"] for item in manifest["actors"]}}
259
+ assert manifest["run"]["actor_id"] in actor_ids
260
+ assert manifest["version"]["object_id"] == manifest["object"]["id"]
261
+ assert manifest["version"]["created_by"] in actor_ids
262
+ assert re.fullmatch(r"sha256:[0-9a-f]{{64}}", manifest["version"]["digest"])
263
+ assert re.search(r"@[0-9a-f]{{40}}/", manifest["version"]["payload_uri"])
264
+
265
+ protocol = manifest["protocol"]
266
+ protocol_version = protocol["version"]
267
+ assert protocol_version["object_id"] == protocol["id"]
268
+ assert manifest["run"]["protocol_version_id"] == protocol_version["id"]
269
+ assert re.fullmatch(r"sha256:[0-9a-f]{{64}}", protocol_version["digest"])
270
+ assert re.search(r"@[0-9a-f]{{40}}/", protocol_version["payload_uri"])
271
+ script = ROOT / protocol["specification"]["source_path"]
272
+ assert sha256_file(script) == protocol_version["code_sha256"]
273
+
274
+ run = manifest["run"]
275
+ assert run["started_at"] <= run["finished_at"]
276
+ assert run["git_commit"] in protocol_version["payload_uri"]
277
+ assert {{"python", "platform", "machine", "packages", "determinism"}} <= set(run["environment"])
278
+
279
+ evidence_ids = {{item["id"] for item in manifest["evidence"]}}
280
+ assert len(evidence_ids) == len(manifest["evidence"])
281
+ for item in manifest["evidence"]:
282
+ assert item["run_id"] == run["id"]
283
+ assert item["subject_version"] == manifest["version"]["id"]
284
+ assert re.search(r"@sha256:[0-9a-f]{{64}}$", item["id"])
285
+
286
+ claim_ids = {{item["id"] for item in manifest["claims"]}}
287
+ assert len(claim_ids) == len(manifest["claims"])
288
+ for item in manifest["claims"]:
289
+ assert item["scope"] == manifest["version"]["id"]
290
+ assert item["asserted_by"] in actor_ids
291
+ assert item["supported_by"]
292
+ assert set(item["supported_by"]) <= evidence_ids
293
+ assert item["falsification_condition"]
294
+
295
+ for link in manifest["claim_evidence"]:
296
+ assert link["claim_id"] in claim_ids
297
+ assert link["evidence_id"] in evidence_ids
298
+ assert link["relation"] in {{"SUPPORTS", "REFUTES", "QUALIFIES"}}
299
+
300
+ edges = {{}}
301
+ for relation in manifest["relations"]:
302
+ source = relation["source_version_id"]
303
+ target = relation["target_version_id"]
304
+ assert source != target
305
+ assert relation["introduced_by_run"] == run["id"]
306
+ if target.startswith("slayer://version/"):
307
+ edges.setdefault(source, set()).add(target)
308
+
309
+ visiting, visited = set(), set()
310
+ def visit(node):
311
+ assert node not in visiting, "version lineage must be acyclic"
312
+ if node in visited:
313
+ return
314
+ visiting.add(node)
315
+ for target in edges.get(node, ()):
316
+ visit(target)
317
+ visiting.remove(node)
318
+ visited.add(node)
319
+ for node in edges:
320
+ visit(node)
321
+
322
+ for attestation in manifest["attestations"]:
323
+ assert attestation["actor_id"] in actor_ids
324
+ assert attestation["subject_version"] == manifest["version"]["id"]
325
+ assert attestation["supported_by"]
326
+ assert set(attestation["supported_by"]) <= evidence_ids
327
+
328
+
329
+ def test_manifest_artifact_checksums():
330
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
331
+ checksums = next(
332
+ item["payload"] for item in manifest["evidence"]
333
+ if item["observation_type"] == "artifact_checksums"
334
+ )
335
+ paths = {{
336
+ "parquet_sha256": DATA / "{SOURCE_NAME}.parquet",
337
+ "attribution_sha256": DATA / "{SOURCE_NAME}.attribution.jsonl",
338
+ "stats_sha256": DATA / "{SOURCE_NAME}.stats.json",
339
+ "legal_evidence_sha256": DATA / "{SOURCE_NAME}.license-evidence.json",
340
+ }}
341
+ assert {{name: sha256_file(path) for name, path in paths.items()}} == checksums
342
  '''
343
 
344
 
345
  def build(args: argparse.Namespace) -> dict[str, Any]:
346
+ run_started_at = dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")
347
  if not COMMIT_PATTERN.fullmatch(args.source_revision):
348
  raise BuildError("source revision must be a 40-character commit")
349
  if not COMMIT_PATTERN.fullmatch(args.target_revision):
350
  raise BuildError("target revision must be a 40-character commit")
351
+ if not COMMIT_PATTERN.fullmatch(args.dataset_payload_commit):
352
+ raise BuildError("dataset payload commit must be a 40-character commit")
353
+ if not COMMIT_PATTERN.fullmatch(args.protocol_payload_commit):
354
+ raise BuildError("protocol payload commit must be a 40-character commit")
355
  if not args.target_registry.is_file():
356
  raise BuildError("target sources.py is missing")
357
 
 
479
  "stats_sha256": sha256_file(stats_path),
480
  "legal_evidence_sha256": sha256_file(legal_path),
481
  }
482
+ expected_digests = {
483
+ "parquet_sha256": args.expected_parquet_sha256,
484
+ "attribution_sha256": args.expected_attribution_sha256,
485
+ }
486
+ supplied_expected = {key: value for key, value in expected_digests.items() if value}
487
+ mismatches = {
488
+ key: {"expected": expected, "actual": artifact_digests[key]}
489
+ for key, expected in supplied_expected.items()
490
+ if artifact_digests[key] != expected
491
+ }
492
+ if mismatches:
493
+ raise BuildError(f"reproduction digest mismatch: {mismatches}")
494
+
495
  version_digest = canonical_sha256({
496
  "source_revision": args.source_revision, "target_revision": args.target_revision,
497
  "range": [START_DATE, END_DATE], "artifacts": artifact_digests,
498
  })
499
+ object_id = f"slayer://object/dataset-source/{SOURCE_NAME}"
500
  version_id = f"slayer://version/dataset-source/{SOURCE_NAME}@sha256:{version_digest}"
501
+ protocol_object_id = f"slayer://object/protocol/{SOURCE_NAME}-filter"
502
+ protocol_configuration = {
503
+ "date_range": [START_DATE, END_DATE],
504
+ "deduplication": {"algorithm": "sha1", "field": "text", "scope": "within_source"},
505
+ "id_generation": {"algorithm": "sha256", "fields": ["date", "term", "speaker", "text"]},
506
+ "minimum_text_characters": 200,
507
+ "parquet": {"compression": "zstd", "write_batch_size": 1024},
508
+ "source_splits": ["train", "validation"],
509
+ "speaker_required": True,
510
+ "tokenizer": "cl100k_base",
511
+ }
512
+ protocol_specification = {
513
+ "entrypoint": "python src/fetch_sejm_api_2011_2022.py",
514
+ "source_path": "src/fetch_sejm_api_2011_2022.py",
515
+ "summary": "Deterministic date filtering, exact-text deduplication, attribution preservation and DynaWord projection.",
516
+ "configuration": protocol_configuration,
517
+ "required_inputs": ["pinned source Parquet splits", "pinned target sources.py"],
518
+ "outputs": ["DynaWord Parquet", "attribution sidecar", "stats", "legal evidence", "ontology manifest"],
519
+ }
520
+ protocol_code_digest = sha256_file(pathlib.Path(__file__).resolve())
521
+ protocol_digest = canonical_sha256({
522
+ "object_id": protocol_object_id,
523
+ "code_sha256": protocol_code_digest,
524
+ "specification": protocol_specification,
525
+ })
526
+ protocol_version_id = f"slayer://version/protocol/{SOURCE_NAME}-filter@sha256:{protocol_digest}"
527
+ source_version_id = f"hf://datasets/{SOURCE_REPOSITORY}@{args.source_revision}"
528
+ target_version_id = f"hf://datasets/{TARGET_REPOSITORY}@{args.target_revision}"
529
+ run_finished_at = dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")
530
+ environment = {
531
+ "python": sys.version,
532
+ "python_executable": sys.executable,
533
+ "platform": platform.platform(),
534
+ "machine": platform.machine(),
535
+ "packages": {
536
+ "pyarrow": pa.__version__,
537
+ "tiktoken": importlib.metadata.version("tiktoken"),
538
+ },
539
+ "container_image": None,
540
+ "environment_limitation": "No container image was used; material runtime and package versions are recorded.",
541
+ "determinism": {"sampling": "none", "seed": None, "input_order": ["train", "validation"]},
542
+ }
543
+
544
+ def evidence(observation_type: str, payload: Any) -> dict[str, Any]:
545
+ evidence_digest = canonical_sha256({
546
+ "run_id": args.run_id,
547
+ "subject_version": version_id,
548
+ "observation_type": observation_type,
549
+ "payload": payload,
550
+ })
551
+ return {
552
+ "id": f"slayer://evidence/{SOURCE_NAME}/{observation_type}@sha256:{evidence_digest}",
553
+ "run_id": args.run_id,
554
+ "subject_version": version_id,
555
+ "observation_type": observation_type,
556
+ "payload": payload,
557
+ "observed_at": run_finished_at,
558
+ }
559
+
560
+ evidence_items = [
561
+ evidence("dataset_record_counts", stats),
562
+ evidence("speaker_attribution_coverage", {
563
+ "records": counter["kept"], "non_empty_authors": counter["authors_with_value"],
564
+ "coverage": counter["authors_with_value"] / counter["kept"],
565
+ }),
566
+ evidence("known_temporal_overlap", {
567
+ "parliamentary_registered_range": "1991-2019",
568
+ "parlamint_pl_registered_range": "2015-2022",
569
+ "novelty_claimed": False,
570
+ }),
571
+ evidence("artifact_checksums", artifact_digests),
572
+ evidence("legal_provenance_review", {
573
+ "status": "reviewed-open-official-materials",
574
+ "artifact": f"data/{SOURCE_NAME}/{SOURCE_NAME}.license-evidence.json",
575
+ "sha256": artifact_digests["legal_evidence_sha256"],
576
+ "limitations_retained": True,
577
+ }),
578
+ evidence("schema_validation", {
579
+ "schema": list(EXPECTED_FIELDS), "records": counter["kept"], "valid": True,
580
+ }),
581
+ evidence("pinned_input_reproduction", {
582
+ "expected": supplied_expected,
583
+ "actual": {key: artifact_digests[key] for key in supplied_expected},
584
+ "matches": bool(supplied_expected) and not mismatches,
585
+ }),
586
+ ]
587
+ evidence_by_type = {item["observation_type"]: item["id"] for item in evidence_items}
588
+
589
+ def claim(statement: str, falsification_condition: str, supported_by: list[str]) -> dict[str, Any]:
590
+ claim_digest = canonical_sha256({
591
+ "scope": version_id,
592
+ "statement": statement,
593
+ "falsification_condition": falsification_condition,
594
+ })
595
+ return {
596
+ "id": f"slayer://claim/{SOURCE_NAME}@sha256:{claim_digest}",
597
+ "scope": version_id,
598
+ "statement": statement,
599
+ "asserted_by": args.actor,
600
+ "supported_by": supported_by,
601
+ "falsification_condition": falsification_condition,
602
+ }
603
+
604
+ claims = [
605
+ claim(
606
+ "All retained records from the pinned source dated 2011-2022 are included after exact within-source deduplication.",
607
+ "A qualifying pinned-source record is absent without a recorded drop reason.",
608
+ [evidence_by_type["dataset_record_counts"]],
609
+ ),
610
+ claim(
611
+ "Every contributed document has non-empty speaker attribution.",
612
+ "Any contributed author field is empty.",
613
+ [evidence_by_type["speaker_attribution_coverage"]],
614
+ ),
615
+ claim(
616
+ "The contribution does not establish temporal novelty relative to every target source because registered ranges overlap.",
617
+ "The cited target-source ranges do not overlap 2011-2022.",
618
+ [evidence_by_type["known_temporal_overlap"]],
619
+ ),
620
+ claim(
621
+ "The contributed records are official Sejm materials documented for statutory reuse, subject to retained privacy and third-party limitations.",
622
+ "The records are not official materials or the cited legal basis and provider conditions contradict the documented reuse status.",
623
+ [evidence_by_type["legal_provenance_review"]],
624
+ ),
625
+ claim(
626
+ "The generated artifact set conforms to the DynaWord source schema and recorded checksums.",
627
+ "A contract field is missing, a row violates the schema, or a recorded artifact checksum differs.",
628
+ [evidence_by_type["schema_validation"], evidence_by_type["artifact_checksums"]],
629
+ ),
630
+ ]
631
+ if supplied_expected:
632
+ claims.append(claim(
633
+ "Rebuilding from pinned inputs reproduced the expected Parquet and attribution-sidecar digests.",
634
+ "A rebuilt Parquet or attribution-sidecar digest differs from the expected digest.",
635
+ [evidence_by_type["pinned_input_reproduction"]],
636
+ ))
637
+
638
+ claim_evidence = [
639
+ {
640
+ "claim_id": item["id"], "evidence_id": evidence_id,
641
+ "relation": "SUPPORTS", "introduced_by_run": args.run_id,
642
+ }
643
+ for item in claims for evidence_id in item["supported_by"]
644
+ ]
645
+
646
+ def attestation(attestation_type: str, value: Any, supported_by: list[str]) -> dict[str, Any]:
647
+ attestation_digest = canonical_sha256({
648
+ "type": attestation_type, "value": value, "actor_id": args.actor,
649
+ "subject_version": version_id, "supported_by": supported_by,
650
+ })
651
+ return {
652
+ "id": f"slayer://attestation/{SOURCE_NAME}/{attestation_type}@sha256:{attestation_digest}",
653
+ "type": attestation_type,
654
+ "value": value,
655
+ "actor_id": args.actor,
656
+ "subject_version": version_id,
657
+ "supported_by": supported_by,
658
+ "created_at": run_finished_at,
659
+ }
660
+
661
  manifest = {
662
  "schema_version": "slayer.ai/dataset-source-contribution/v1",
663
+ "ontology_version": "slayer.ai/research-ontology/v0.1",
664
+ "object": {
665
+ "id": object_id, "kind": "dataset_source", "name": SOURCE_NAME,
666
+ "metadata": {"language": "pl", "domain": "political/spoken", "provider": "Kancelaria Sejmu RP"},
667
+ },
668
+ "version": {
669
+ "id": version_id,
670
+ "object_id": object_id,
671
+ "digest": f"sha256:{version_digest}",
672
+ "schema_version": "slayer.ai/dataset-source/v1",
673
+ "payload_uri": f"hf://datasets/{TARGET_REPOSITORY}@{args.dataset_payload_commit}/data/{SOURCE_NAME}/{SOURCE_NAME}.parquet",
674
+ "created_at": args.version_created_at,
675
+ "created_by": args.actor,
676
+ },
677
+ "protocol": {
678
+ "id": protocol_object_id,
679
+ "kind": "dataset_filtering",
680
+ "name": f"{SOURCE_NAME}-filter",
681
+ "version": {
682
+ "id": protocol_version_id,
683
+ "object_id": protocol_object_id,
684
+ "digest": f"sha256:{protocol_digest}",
685
+ "code_sha256": protocol_code_digest,
686
+ "schema_version": "slayer.ai/protocol/v1",
687
+ "payload_uri": f"hf://datasets/{TARGET_REPOSITORY}@{args.protocol_payload_commit}/src/fetch_sejm_api_2011_2022.py",
688
+ "created_at": run_finished_at,
689
+ "created_by": args.actor,
690
+ },
691
+ "specification": protocol_specification,
692
+ },
693
+ "run": {
694
+ "id": args.run_id,
695
+ "protocol_version_id": protocol_version_id,
696
+ "actor_id": args.actor,
697
+ "git_commit": args.protocol_payload_commit,
698
+ "started_at": run_started_at,
699
+ "finished_at": run_finished_at,
700
+ "config": protocol_configuration,
701
+ "environment": environment,
702
+ "inputs": [
703
+ {"role": "source", "version_id": source_version_id},
704
+ {"role": "target_base", "version_id": target_version_id},
705
+ ],
706
+ "outputs": [{"role": "dataset_source", "version_id": version_id}],
707
+ },
708
+ "relations": [
709
+ {"source_version_id": version_id, "predicate": "DERIVED_FROM", "target_version_id": source_version_id, "introduced_by_run": args.run_id},
710
+ {"source_version_id": version_id, "predicate": "COMPATIBLE_WITH", "target_version_id": target_version_id, "introduced_by_run": args.run_id},
711
+ {"source_version_id": version_id, "predicate": "FILTERED_BY", "target_version_id": protocol_version_id, "introduced_by_run": args.run_id},
712
  ],
713
+ "evidence": evidence_items,
714
+ "claims": claims,
715
+ "claim_evidence": claim_evidence,
716
+ "actors": [{
717
+ "id": args.actor, "kind": "human", "identity": "Piotr Sty\u0142a",
718
+ "identifiers": {"hugging_face": "PiotrSty", "github": "PiotrStyla"},
719
+ }],
720
  "attestations": [
721
+ attestation("schema_valid", True, [evidence_by_type["schema_validation"], evidence_by_type["artifact_checksums"]]),
722
+ attestation("temporal_overlap", "known_and_disclosed", [evidence_by_type["known_temporal_overlap"]]),
723
+ attestation("speaker_attribution", "100_percent", [evidence_by_type["speaker_attribution_coverage"]]),
724
+ attestation("legal_status", "documented_open_official_materials_with_limitations", [evidence_by_type["legal_provenance_review"]]),
725
+ attestation("pinned_input_reproduction", bool(supplied_expected), [evidence_by_type["pinned_input_reproduction"]]),
726
  ],
727
  }
728
  write_json(artifact_dir / f"{SOURCE_NAME}_ontology_manifest.json", manifest)
 
741
  parser.add_argument("--output", type=pathlib.Path, required=True)
742
  parser.add_argument("--source-revision", required=True)
743
  parser.add_argument("--target-revision", required=True)
744
+ parser.add_argument("--dataset-payload-commit", required=True)
745
+ parser.add_argument("--protocol-payload-commit", required=True)
746
+ parser.add_argument("--version-created-at", default="2026-08-31T09:59:00Z")
747
+ parser.add_argument("--expected-parquet-sha256")
748
+ parser.add_argument("--expected-attribution-sha256")
749
  parser.add_argument("--added-date", default=dt.datetime.now(dt.timezone.utc).date().isoformat())
750
  parser.add_argument("--actor", default="hf:PiotrSty")
751
  parser.add_argument("--run-id", default=f"sejm-api-2011-2022-{dt.datetime.now(dt.timezone.utc).strftime('%Y%m%dT%H%M%SZ')}")