File size: 62,738 Bytes
5334ec3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | {"id":"foundry::tests/test_atomic_writes.py::test_atomic_write_replaces_atomically::generate","input":"Source path: tests/test_atomic_writes.py\nDomains: atomic_write\nImports: primitive_foundry.io_utils\nAssertion count: 2","instruction":"Write a pytest test for Primitive Foundry that verifies: test atomic write replaces atomically.","output":"def test_atomic_write_replaces_atomically(tmp_path: Path) -> None:\n target = tmp_path / \"state.json\"\n atomic_write_json(target, {\"key\": \"v1\"})\n atomic_write_json(target, {\"key\": \"v2\"})\n payload = json.loads(target.read_text(encoding=\"utf-8\"))\n assert payload == {\"key\": \"v2\"}\n # No stragglers in tmp form.\n tmp_files = list(tmp_path.glob(\".*.tmp\"))\n assert tmp_files == []","source_id":"foundry::tests/test_atomic_writes.py::test_atomic_write_replaces_atomically","task":"python_test_generation"}
{"id":"foundry::tests/test_bus_poller.py::test_poll_loop_persists_status_after_each_tick::generate","input":"Source path: tests/test_bus_poller.py\nDomains: bus\nImports: primitive_foundry\nAssertion count: 4","instruction":"Write a pytest test for Primitive Foundry that verifies: test poll loop persists status after each tick.","output":"def test_poll_loop_persists_status_after_each_tick(tmp_path: Path) -> None:\n adapter = _write_jsonl_adapter(\n tmp_path,\n source_payload=[\n {\"event_id\": f\"e{i}\", \"text\": \"x\", \"source_path\": str(tmp_path / \"src.md\"),\n \"source_id\": f\"s{i}\", \"tags\": []}\n for i in range(3)\n ],\n )\n inbox = tmp_path / \"inbox.jsonl\"\n status_path = tmp_path / \"bus_poll_status.json\"\n state = bus_poller.poll_loop(\n adapter=adapter,\n inbox=inbox,\n interval_seconds=0,\n status_path=status_path,\n max_ticks=2,\n sleep=lambda _: None,\n )\n assert state.tick_count == 2\n assert state.success_count == 2\n payload = json.loads(status_path.read_text(encoding=\"utf-8\"))\n assert payload[\"tick_count\"] == 2\n assert payload[\"last_tick\"][\"ok\"] is True","source_id":"foundry::tests/test_bus_poller.py::test_poll_loop_persists_status_after_each_tick","task":"python_test_generation"}
{"id":"foundry::tests/test_bus_poller.py::test_resolve_status_path_lives_next_to_adapter::generate","input":"Source path: tests/test_bus_poller.py\nDomains: bus\nImports: primitive_foundry\nAssertion count: 1","instruction":"Write a pytest test for Primitive Foundry that verifies: test resolve status path lives next to adapter.","output":"def test_resolve_status_path_lives_next_to_adapter(tmp_path: Path) -> None:\n adapter = tmp_path / \"subdir\" / \"adapter.json\"\n path = bus_poller.resolve_status_path(adapter)\n assert path == tmp_path / \"subdir\" / \"bus_poll_status.json\"","source_id":"foundry::tests/test_bus_poller.py::test_resolve_status_path_lives_next_to_adapter","task":"python_test_generation"}
{"id":"foundry::tests/test_compliance.py::test_compliance_matrix_failure_on_incompatible_source::generate","input":"Source path: tests/test_compliance.py\nDomains: privacy, release, commercial, license, compliance, source_card\nImports: primitive_foundry.compliance\nAssertion count: 1","instruction":"Write a pytest test for Primitive Foundry that verifies: test compliance matrix failure on incompatible source.","output":"def test_compliance_matrix_failure_on_incompatible_source() -> None:\n listing = {\n \"release_id\": \"test_release\",\n \"family\": \"privacy_provenance_eval\",\n \"license\": \"private-commercial-evaluation\",\n }\n cards = [{\"source_id\": \"s1\", \"metadata\": {\"source_license\": \"AGPL-3.0\"}}]\n matrix = build_compliance_matrix(listing=listing, source_cards=cards)\n assert matrix[\"all_source_licenses_compatible\"] is False","source_id":"foundry::tests/test_compliance.py::test_compliance_matrix_failure_on_incompatible_source","task":"python_test_generation"}
{"id":"foundry::tests/test_exporters.py::test_dcat_payload_shape::generate","input":"Source path: tests/test_exporters.py\nDomains: release, dataset, exporter\nImports: primitive_foundry.exporters, primitive_foundry.exporters.croissant, primitive_foundry.exporters.dcat, primitive_foundry.exporters.schema_org_dataset\nAssertion count: 3","instruction":"Write a pytest test for Primitive Foundry that verifies: test dcat payload shape.","output":"def test_dcat_payload_shape(fake_release: tuple[Path, dict]) -> None:\n release, listing = fake_release\n payload = build_dcat(release, listing)\n assert payload[\"@type\"] == \"Dataset\"\n assert payload[\"dct:title\"] == listing[\"title\"]\n assert payload[\"distribution\"][0][\"mediaType\"] == \"application/gzip\"","source_id":"foundry::tests/test_exporters.py::test_dcat_payload_shape","task":"python_test_generation"}
{"id":"foundry::tests/test_golden_fixture.py::test_golden_fixture_manifest_and_hashes_are_stable::generate","input":"Source path: tests/test_golden_fixture.py\nDomains: privacy, signature\nImports: primitive_foundry.foundry_bridge, primitive_foundry.signing\nAssertion count: 5","instruction":"Write a pytest test for Primitive Foundry that verifies: test golden fixture manifest and hashes are stable.","output":"def test_golden_fixture_manifest_and_hashes_are_stable() -> None:\n manifest = json.loads((GOLDEN_ROOT / \"GOLDEN_FIXTURE.json\").read_text(encoding=\"utf-8\"))\n\n assert manifest[\"fixture_id\"] == \"aml_privacy_provenance_eval_standard_v1.0.0\"\n assert manifest[\"record_count\"] == 3\n assert sha256(BUNDLE_DIR / \"source_foundry_records.jsonl\") == (\n \"8d93236ea563c868e5590480a9b4d517345b5752bd520504e84b2879a64de0fa\"\n )\n assert sha256(BUNDLE_DIR / \"CHECKSUMS.sha256\") == (\n \"99578ebab35ee50a702051c2adb451dfdec426e0c63e4696ec3c364289b8ca9c\"\n )\n assert sha256(BUNDLE_DIR / \"SIGNATURE.json\") == (\n \"316faa30f0894b107afc632f5bd8b14b165435490520ba2fe6e041beefeb6683\"\n )","source_id":"foundry::tests/test_golden_fixture.py::test_golden_fixture_manifest_and_hashes_are_stable","task":"python_test_generation"}
{"id":"foundry::tests/test_golden_fixture.py::test_golden_fixture_loads_and_signature_verifies::generate","input":"Source path: tests/test_golden_fixture.py\nDomains: signature, dataset\nImports: primitive_foundry.foundry_bridge, primitive_foundry.signing\nAssertion count: 5","instruction":"Write a pytest test for Primitive Foundry that verifies: test golden fixture loads and signature verifies.","output":"def test_golden_fixture_loads_and_signature_verifies() -> None:\n from primitive_harness.bundle import load_bundle\n\n loaded = load_bundle(BUNDLE_DIR, publisher_public_key=PUBLIC_KEY.read_bytes())\n signature = verify_signature(BUNDLE_DIR, PUBLIC_KEY.read_bytes())\n foundry_verify = verify_foundry_bundle(BUNDLE_DIR)\n\n assert len(loaded.records) == 3\n assert loaded.schema[\"dataset_version\"] == \"0.5.0\"\n assert loaded.rubric[\"record_count\"] == 3\n assert signature[\"passed\"]\n assert foundry_verify[\"passed\"]","source_id":"foundry::tests/test_golden_fixture.py::test_golden_fixture_loads_and_signature_verifies","task":"python_test_generation"}
{"id":"foundry::tests/test_listing_gates.py::test_card_accuracy_fails_when_evidence_missing::generate","input":"Source path: tests/test_listing_gates.py\nDomains: release, marketplace\nImports: primitive_foundry.commercial\nAssertion count: 2","instruction":"Write a pytest test for Primitive Foundry that verifies: test card accuracy fails when evidence missing.","output":"def test_card_accuracy_fails_when_evidence_missing(tmp_path: Path) -> None:\n release = _build_full_release(tmp_path)\n (release / \"bundle\" / \"QUALITY_REPORT.md\").unlink()\n listing = json.loads((release / \"MARKETPLACE_LISTING.json\").read_text())\n failures = verify_card_accuracy(release, listing)\n assert any(\"missing_evidence_for\" in f for f in failures)\n assert any(\"missing_evidence_hash_for\" in f for f in failures)","source_id":"foundry::tests/test_listing_gates.py::test_card_accuracy_fails_when_evidence_missing","task":"python_test_generation"}
{"id":"foundry::tests/test_listing_gates.py::test_complementary_bundle_skipped_for_non_eval_family::generate","input":"Source path: tests/test_listing_gates.py\nDomains: release, marketplace, router\nImports: primitive_foundry.commercial\nAssertion count: 1","instruction":"Write a pytest test for Primitive Foundry that verifies: test complementary bundle skipped for non eval family.","output":"def test_complementary_bundle_skipped_for_non_eval_family(tmp_path: Path) -> None:\n release = _build_full_release(tmp_path)\n listing = json.loads((release / \"MARKETPLACE_LISTING.json\").read_text())\n listing[\"family\"] = \"router_training\"\n # Remove all bundle evidence to confirm the gate doesn't fire.\n (release / \"bundle\" / \"data\" / \"train.jsonl\").unlink()\n (release / \"bundle\" / \"QUALITY_REPORT.md\").unlink()\n assert verify_complementary_bundle(release, listing) == []","source_id":"foundry::tests/test_listing_gates.py::test_complementary_bundle_skipped_for_non_eval_family","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_v02_benchmark_passes::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: dataset, benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 3","instruction":"Write a pytest test for Primitive Foundry that verifies: test v02 benchmark passes.","output":"def test_v02_benchmark_passes() -> None:\n report = BenchmarkRunner().run_dataset(\"datasets/v0.2/aml_v0_2.jsonl\")\n assert report[\"record_count\"] == 100\n assert report[\"pass_rate\"] == 1.0\n assert report[\"metrics\"][\"top_k_routing\"] == 1.0","source_id":"foundry::tests/test_local_benchmark.py::test_v02_benchmark_passes","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_repair_foundry_bundle_backfills_harness_and_review::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: dataset, benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 5","instruction":"Write a pytest test for Primitive Foundry that verifies: test repair foundry bundle backfills harness and review.","output":"def test_repair_foundry_bundle_backfills_harness_and_review(tmp_path) -> None:\n records_path = tmp_path / \"aml_foundry.jsonl\"\n bundle_dir = tmp_path / \"bundle\"\n export_foundry_records(\"datasets/v0.4/hard.jsonl\", records_path)\n build_foundry_bundle(records_path, bundle_dir)\n\n import json\n\n rows = read_jsonl(bundle_dir / \"source_foundry_records.jsonl\")\n for row in rows:\n row.pop(\"domain_review\", None)\n row.get(\"features\", {}).pop(\"rubric\", None)\n row.get(\"features\", {}).pop(\"buyer_task\", None)\n row[\"provenance_hash\"] = \"stale\"\n with open(bundle_dir / \"source_foundry_records.jsonl\", \"w\", encoding=\"utf-8\") as handle:\n for row in rows:\n handle.write(json.dumps(row, sort_keys=True) + \"\\n\")\n for relative in (\"eval_harness/README.md\", \"eval_harness/buyer_harness.py\"):\n path = bundle_dir / relative\n if path.exists():\n path.unlink()\n\n assert not verify_foundry_bundle(bundle_dir)[\"passed\"]\n repaired = repair_foundry_bundle(bundle_dir)\n assert repaired[\"repaired\"]\n assert verify_foundry_bundle(bundle_dir)[\"passed\"]\n repaired_rows = read_jsonl(bundle_dir / \"source_foundry_records.jsonl\")\n assert all(row[\"domain_review\"][\"review_status\"] == \"founder_attested_v1\" for row in repaired_rows)\n assert all(row[\"features\"][\"rubric\"] for row in repaired_rows)","source_id":"foundry::tests/test_local_benchmark.py::test_repair_foundry_bundle_backfills_harness_and_review","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_pvtr_receipts_bind_bundle_and_harness_verifies::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: dataset, benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 4","instruction":"Write a pytest test for Primitive Foundry that verifies: test pvtr receipts bind bundle and harness verifies.","output":"def test_pvtr_receipts_bind_bundle_and_harness_verifies(tmp_path) -> None:\n from primitive_foundry.pvtr_bridge import bind_bundle_records_to_pvtr, verify_record_against_pvtr\n\n records_path = tmp_path / \"aml_foundry.jsonl\"\n bundle_dir = tmp_path / \"bundle\"\n export_foundry_records(\"datasets/v0.4/hard.jsonl\", records_path)\n build_foundry_bundle(records_path, bundle_dir)\n binding = bind_bundle_records_to_pvtr(bundle_dir, pvtr_endpoint=\"local://pvtr-test\")\n\n harness_src = Path(\"primitive-harness/src\").resolve()\n if str(harness_src) not in sys.path:\n sys.path.insert(0, str(harness_src))\n from primitive_harness.bundle import load_bundle\n from primitive_harness.runner import run\n\n def reference_agent(record: dict) -> dict:\n features = record.get(\"features\", {})\n return {\"selected_cell_ids\": features.get(\"expected_cell_ids\", [])}\n\n loaded = load_bundle(bundle_dir)\n report = run(reference_agent, loaded, verify_pvtr_endpoint=\"local://pvtr-test\")\n first_id = loaded.records[0][\"record_id\"]\n\n assert binding[\"receipt_count\"] == 72\n assert verify_foundry_bundle(bundle_dir)[\"passed\"]\n assert verify_record_against_pvtr(first_id, \"local://pvtr-test\", bundle_dir)[\"passed\"]\n assert report[\"results\"][0][\"pvtr\"][\"passed\"]","source_id":"foundry::tests/test_local_benchmark.py::test_pvtr_receipts_bind_bundle_and_harness_verifies","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_source_backed_curation_export_and_bundle::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: curation, dataset, router, benchmark, source_card\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 6","instruction":"Write a pytest test for Primitive Foundry that verifies: test source backed curation export and bundle.","output":"def test_source_backed_curation_export_and_bundle(tmp_path) -> None:\n dataset_path = tmp_path / \"source_backed.jsonl\"\n foundry_path = tmp_path / \"source_backed_foundry.jsonl\"\n bundle_dir = tmp_path / \"source_bundle\"\n curated = curate_source_cards(\"sources/v0.5/source_cards.jsonl\", dataset_path)\n report = BenchmarkRunner(router_name=\"keyword\").run_dataset(dataset_path)\n export = export_foundry_records(dataset_path, foundry_path)\n bundle = build_foundry_bundle(foundry_path, bundle_dir)\n\n assert curated[\"record_count\"] == 6\n assert report[\"pass_rate\"] == 1.0\n assert export[\"quality\"][\"passed\"]\n assert bundle[\"quality\"][\"passed\"]\n assert verify_foundry_bundle(bundle_dir)[\"passed\"]\n schema = json_load(bundle_dir / \"SCHEMA.json\")\n assert schema[\"dataset_version\"] == \"0.5.0\"","source_id":"foundry::tests/test_local_benchmark.py::test_source_backed_curation_export_and_bundle","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_legacy_patent_source_paths_do_not_resolve_to_commercial_sources::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: commercial, benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 2","instruction":"Write a pytest test for Primitive Foundry that verifies: test legacy patent source paths do not resolve to commercial sources.","output":"def test_legacy_patent_source_paths_do_not_resolve_to_commercial_sources() -> None:\n blocked_cases = [\n (\n \"/home/[USER] is the context primitive core ecosystem with tennets/build-workspace/context_primitive_kernel/PATENT.md\",\n \"context-kernel-patent::007\",\n ),\n (\n \"/home/[USER] is the context primitive core ecosystem with tennets/PATENT_PROCESS_MAP.md\",\n \"patent-process-map::006\",\n ),\n ]\n for legacy_path, source_id in blocked_cases:\n resolved = resolve_source_path(legacy_path, source_id=source_id)\n assert not resolved.exists()\n assert \"blocked-patent-sensitive-source\" in str(resolved)","source_id":"foundry::tests/test_local_benchmark.py::test_legacy_patent_source_paths_do_not_resolve_to_commercial_sources","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_generated_source_backed_60_export_quality::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: dataset, router, benchmark, source_card\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 6","instruction":"Write a pytest test for Primitive Foundry that verifies: test generated source backed 60 export quality.","output":"def test_generated_source_backed_60_export_quality(tmp_path) -> None:\n cards_path = tmp_path / \"cards_60.jsonl\"\n dataset_path = tmp_path / \"source_backed_60.jsonl\"\n foundry_path = tmp_path / \"source_backed_60_foundry.jsonl\"\n bundle_dir = tmp_path / \"source_bundle_60\"\n cards = generate_source_cards(60, cards_path)\n curated = curate_source_cards(cards_path, dataset_path)\n report = BenchmarkRunner(router_name=\"keyword\").run_dataset(dataset_path)\n export = export_foundry_records(dataset_path, foundry_path)\n bundle = build_foundry_bundle(foundry_path, bundle_dir)\n\n assert len(cards) == 60\n assert curated[\"record_count\"] == 60\n assert report[\"pass_rate\"] == 1.0\n assert export[\"quality\"][\"passed\"]\n assert bundle[\"quality\"][\"passed\"]\n assert verify_foundry_bundle(bundle_dir)[\"passed\"]","source_id":"foundry::tests/test_local_benchmark.py::test_generated_source_backed_60_export_quality","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_promotion_gate_success_and_failure::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: dataset, router, benchmark, source_card\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 4","instruction":"Write a pytest test for Primitive Foundry that verifies: test promotion gate success and failure.","output":"def test_promotion_gate_success_and_failure(tmp_path) -> None:\n cards_path = tmp_path / \"cards_60.jsonl\"\n dataset_path = tmp_path / \"source_backed_60.jsonl\"\n foundry_path = tmp_path / \"source_backed_60_foundry.jsonl\"\n bundle_dir = tmp_path / \"source_bundle_60\"\n manifest_path = tmp_path / \"promotion.json\"\n failed_manifest_path = tmp_path / \"promotion_failed.json\"\n generate_source_cards(60, cards_path)\n curate_source_cards(cards_path, dataset_path)\n export_foundry_records(dataset_path, foundry_path)\n build_foundry_bundle(foundry_path, bundle_dir)\n\n promoted = promote_bundle(\n dataset_path=dataset_path,\n foundry_records=foundry_path,\n bundle_dir=bundle_dir,\n output_manifest=manifest_path,\n require_audit=False,\n )\n verified = verify_promotion_manifest(manifest_path)\n assert promoted[\"promoted\"]\n assert verified[\"passed\"]\n\n failed = promote_bundle(\n dataset_path=dataset_path,\n foundry_records=foundry_path,\n bundle_dir=bundle_dir,\n output_manifest=failed_manifest_path,\n router=\"hashed-embedding\",\n min_pass_rate=1.0,\n require_audit=False,\n )\n failed_verified = verify_promotion_manifest(failed_manifest_path)\n assert not failed[\"promoted\"]\n assert not failed_verified[\"passed\"]","source_id":"foundry::tests/test_local_benchmark.py::test_promotion_gate_success_and_failure","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_source_card_adapters_emit_curatable_family_cards::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: sterilization, privacy, dataset, benchmark, source_card\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 14","instruction":"Write a pytest test for Primitive Foundry that verifies: test source card adapters emit curatable family cards.","output":"def test_source_card_adapters_emit_curatable_family_cards(tmp_path) -> None:\n from primitive_foundry.source_adapters.agent_eval_scenarios import build_source_cards as build_governance_cards\n from primitive_foundry.source_adapters.agentic_build_traces import build_source_cards as build_build_cards\n from primitive_foundry.source_adapters.privacy_regulatory import build_source_cards as build_privacy_cards\n from primitive_foundry.sterilization_rules import verify_with_ruleset\n\n privacy_dir = tmp_path / \"privacy\"\n privacy_dir.mkdir()\n (privacy_dir / \"gdpr_art_5.md\").write_text(\n \"---\\n\"\n \"regulation: GDPR\\n\"\n \"article: Art.5.1.b\\n\"\n \"jurisdiction: EU\\n\"\n \"effective_date: 2018-05-25\\n\"\n \"---\\n\"\n \"Personal data must be collected for specified, explicit, and legitimate purposes.\",\n encoding=\"utf-8\",\n )\n privacy_cards_path = tmp_path / \"privacy_cards.jsonl\"\n privacy_cards = build_privacy_cards(privacy_dir, privacy_cards_path)\n\n governance_dir = tmp_path / \"governance\"\n governance_dir.mkdir()\n (governance_dir / \"human_override.json\").write_text(\n '{'\n '\"scenario_id\":\"override-001\",'\n '\"scenario_kind\":\"human_override\",'\n '\"summary\":\"Agent must preserve an explicit reviewer override.\",'\n '\"expected_authority_events\":[\"override_seen\",\"reviewer_authority_verified\"]'\n '}',\n encoding=\"utf-8\",\n )\n governance_cards = build_governance_cards(governance_dir, tmp_path / \"governance_cards.jsonl\")\n\n build_dir = tmp_path / \"build_runs\" / \"run-001\"\n build_dir.mkdir(parents=True)\n (build_dir / \"trace.json\").write_text('{\"run_id\":\"run-001\",\"expected_outcome\":\"tests_pass_with_repair\"}', encoding=\"utf-8\")\n (build_dir / \"spec.md\").write_text(\"Fix the validation branch and keep the public API stable.\", encoding=\"utf-8\")\n (build_dir / \"starter.tar.gz\").write_text(\"starter archive placeholder\", encoding=\"utf-8\")\n (build_dir / \"hidden_tests.tar.gz\").write_text(\"hidden test archive placeholder\", encoding=\"utf-8\")\n build_cards = build_build_cards(tmp_path / \"build_runs\", tmp_path / \"build_cards.jsonl\")\n\n curated_path = tmp_path / \"privacy_dataset.jsonl\"\n curated = curate_source_cards(privacy_cards_path, curated_path)\n\n assert privacy_cards[0][\"source_family\"] == \"privacy_provenance_eval\"\n assert privacy_cards[0][\"rubric\"][\"rubric_id\"] == \"rubric.privacy.v1\"\n assert verify_with_ruleset(privacy_cards[0], privacy_cards[0][\"metadata\"][\"sterilization_ruleset\"])[\"passed\"]\n assert governance_cards[0][\"source_family\"] == \"agent_runtime_governance\"\n assert verify_with_ruleset(governance_cards[0], governance_cards[0][\"metadata\"][\"sterilization_ruleset\"])[\"passed\"]\n assert governance_cards[0][\"metadata\"][\"expected_authority_events\"] == [\n \"override_seen\",\n \"reviewer_authority_verified\",\n ]\n assert build_cards[0][\"source_family\"] == \"verified_agentic_build\"\n assert verify_with_ruleset(build_cards[0], build_cards[0][\"metadata\"][\"sterilization_ruleset\"])[\"passed\"]\n assert build_cards[0][\"metadata\"][\"expected_outcome\"] == \"tests_pass_with_repair\"\n assert curated[\"record_count\"] == 1\n loaded = load_jsonl(curated_path)[0]\n assert loaded.rubric_id == \"rubric.privacy.v1\"\n assert loaded.domain_review[\"review_status\"] == \"founder_attested_v1\"\n assert loaded.family_fields[\"control_id\"] == \"GDPR.Art.5.1.b\"\n assert loaded.metadata[\"source_family\"] == \"privacy_provenance_eval\"","source_id":"foundry::tests/test_local_benchmark.py::test_source_card_adapters_emit_curatable_family_cards","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_build_candidate_from_event_stream::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: privacy, release, bus, dataset, router, benchmark, source_card\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 10","instruction":"Write a pytest test for Primitive Foundry that verifies: test build candidate from event stream.","output":"def test_build_candidate_from_event_stream(tmp_path) -> None:\n source_a = tmp_path / \"dataset_source.md\"\n source_b = tmp_path / \"eval_source.md\"\n source_c = tmp_path / \"benchmark_source.md\"\n source_a.write_text(\"private dataset corpus source cards provenance foundry release\", encoding=\"utf-8\")\n source_b.write_text(\"evaluation harness audit score verify quality gates provenance\", encoding=\"utf-8\")\n source_c.write_text(\"benchmark baseline router regression lifecycle apoptosis event bus\", encoding=\"utf-8\")\n events_path = tmp_path / \"events.jsonl\"\n events = [\n {\n \"event_id\": \"evt-dataset\",\n \"text\": \"High value private dataset corpus with Foundry source cards, provenance, release bundle, and sale path.\",\n \"source_path\": str(source_a),\n \"tags\": [\"dataset\", \"foundry\"],\n },\n {\n \"event_id\": \"evt-eval\",\n \"text\": \"High value eval harness for audit scoring, quality gates, provenance verification, and private release checks.\",\n \"source_path\": str(source_b),\n \"tags\": [\"eval\", \"audit\"],\n },\n {\n \"event_id\": \"evt-benchmark\",\n \"text\": \"Medium value benchmark for router baseline comparison, lifecycle apoptosis replacement, and event bus regression tests.\",\n \"source_path\": str(source_c),\n \"tags\": [\"benchmark\", \"router\"],\n },\n ]\n with events_path.open(\"w\", encoding=\"utf-8\") as handle:\n for event in events:\n import json\n\n handle.write(json.dumps(event, sort_keys=True) + \"\\n\")\n\n result = build_candidate_from_events(\n events_path=events_path,\n output_root=tmp_path / \"products\",\n candidate_id=\"candidate_test\",\n )\n assert result[\"passed\"]\n assert result[\"accepted_event_count\"] == 3\n assert verify_manifest_lock(result[\"manifest_lock\"])[\"passed\"]\n assert (tmp_path / \"products\" / \"PRODUCT_CATALOG.json\").exists()\n cards = read_jsonl(tmp_path / \"products\" / \"candidate_test\" / \"source_cards.jsonl\")\n assert {card[\"source_family\"] for card in cards} == {\n \"privacy_provenance_eval\",\n \"agent_runtime_governance\",\n \"verified_agentic_build\",\n }\n assert all(card[\"domain_review\"][\"reviewer_name\"] == \"local-owner\" for card in cards)\n assert all(card[\"rubric\"] for card in cards)\n\n bundle_dir = Path(result[\"bundle_dir\"])\n buyer_manifest = json_load(bundle_dir / \"BUYER_MANIFEST.json\")\n assert buyer_manifest[\"eval_harness\"] == \"eval_harness/buyer_harness.py\"\n verify = verify_foundry_bundle(bundle_dir)\n assert verify[\"eval_harness\"][\"passed\"]\n foundry_records = read_jsonl(bundle_dir / \"source_foundry_records.jsonl\")\n assert all(record[\"domain_review\"][\"review_status\"] == \"founder_attested_v1\" for record in foundry_records)","source_id":"foundry::tests/test_local_benchmark.py::test_build_candidate_from_event_stream","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_cli_missing_file_errors_do_not_traceback::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 3","instruction":"Write a pytest test for Primitive Foundry that verifies: test cli missing file errors do not traceback.","output":"def test_cli_missing_file_errors_do_not_traceback() -> None:\n import subprocess\n import sys\n\n result = subprocess.run(\n [\n sys.executable,\n \"-m\",\n \"primitive_foundry.cli\",\n \"verify-package\",\n \"--manifest\",\n \"/tmp/aml-definitely-missing-package.json\",\n ],\n cwd=\".\",\n text=True,\n capture_output=True,\n check=False,\n )\n assert result.returncode == 2\n assert \"Traceback\" not in result.stderr\n assert \"No such file or directory\" in result.stderr","source_id":"foundry::tests/test_local_benchmark.py::test_cli_missing_file_errors_do_not_traceback","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_product_planner_closes_releases_and_continues::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: privacy, release, marketplace, commercial, planner, dataset, benchmark, compliance\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 82","instruction":"Write a pytest test for Primitive Foundry that verifies: test product planner closes releases and continues.","output":"def test_product_planner_closes_releases_and_continues(tmp_path) -> None:\n import tarfile\n\n sources = []\n for index in range(3):\n source = tmp_path / f\"privacy_source_{index}.md\"\n source.write_text(\n \"private privacy provenance dataset eval benchmark release quality foundry source\",\n encoding=\"utf-8\",\n )\n sources.append(source)\n events = tmp_path / \"events.jsonl\"\n import json\n\n names = [\"alpha\", \"bravo\", \"charlie\"]\n with events.open(\"w\", encoding=\"utf-8\") as handle:\n for index, (source, name) in enumerate(zip(sources, names), start=1):\n handle.write(\n json.dumps(\n {\n \"event_id\": f\"planner-{index}\",\n \"text\": f\"High value privacy provenance eval dataset release {name} source for quality gates.\",\n \"source_path\": str(source),\n \"tags\": [\"privacy\", \"provenance\", \"eval\", name],\n },\n sort_keys=True,\n )\n + \"\\n\"\n )\n\n output_root = tmp_path / \"autonomous\"\n result = run_product_node(\n events_path=events,\n output_root=output_root,\n state_path=output_root / \"PRODUCT_PLANNER_STATE.json\",\n target_size=\"micro\",\n target_count=2,\n min_source_diversity=2,\n iterations=1,\n poll_seconds=0,\n dedupe_threshold=1.0,\n )\n assert result[\"passed\"]\n assert result[\"releases_created\"] == 1\n assert verify_planner_state(output_root / \"PRODUCT_PLANNER_STATE.json\")[\"passed\"]\n assert (output_root / \"releases\" / \"privacy_provenance_eval_000001\" / \"AUTONOMOUS_RELEASE.json\").exists()\n assert (output_root / \"packages\" / \"privacy_provenance_eval_000001.tar.gz\").exists()\n release_dir = output_root / \"releases\" / \"privacy_provenance_eval_000001\"\n release_verify = verify_autonomous_release(\n output_root / \"releases\" / \"privacy_provenance_eval_000001\" / \"AUTONOMOUS_RELEASE.json\"\n )\n commercial_verify = verify_commercial_release(release_dir)\n listing = json_load(release_dir / \"MARKETPLACE_LISTING.json\")\n assert release_verify[\"passed\"]\n assert release_verify[\"commercial_verify\"][\"passed\"]\n assert commercial_verify[\"passed\"]\n assert listing[\"market_regions\"] == [\"US\", \"EU\"]\n assert listing[\"target_count\"] == 2\n assert listing[\"profile_record_count\"] == 25\n assert listing[\"record_count\"] == 2\n assert listing[\"externally_listable\"] is False\n assert listing[\"version\"] == \"1.0.1\"\n assert listing[\"compliance\"][\"personal_data_included\"] is False\n assert listing[\"compliance\"][\"sensitive_personal_data_included\"] is False\n assert listing[\"compliance\"][\"personal_information_sold_or_shared\"] is False\n assert {row[\"region\"] for row in listing[\"compliance\"][\"frameworks\"]} == {\"US\", \"EU\"}\n package_manifest = json_load(output_root / \"packages\" / \"privacy_provenance_eval_000001.package.json\")\n assert any(path.endswith(\"MARKETPLACE_LISTING.json\") for path in package_manifest[\"included\"])\n assert any(path.endswith(\"MARKETPLACE_METADATA.json\") for path in package_manifest[\"included\"])\n assert any(path.endswith(\"MARKETPLACE_CHANNEL_PLAN.json\") for path in package_manifest[\"included\"])\n assert any(\"aws_data_exchange\" in path for path in package_manifest[\"included\"])\n assert any(path.endswith(\"BUYER_SAMPLE_POLICY.json\") for path in package_manifest[\"included\"])\n assert any(path.endswith(\"VERSION_POLICY.json\") for path in package_manifest[\"included\"])\n assert any(path.endswith(\"PRICING_EVIDENCE.json\") for path in package_manifest[\"included\"])\n assert any(path.endswith(\"LEGAL_REVIEW_PACKET.json\") for path in package_manifest[\"included\"])\n assert not any(path.endswith(\"AUTONOMOUS_RELEASE.json\") for path in package_manifest[\"included\"])\n with tarfile.open(output_root / \"packages\" / \"privacy_provenance_eval_000001.tar.gz\", \"r:gz\") as archive:\n assert not any(name.endswith(\"AUTONOMOUS_RELEASE.json\") for name in archive.getnames())\n assert json_load(release_dir / \"MARKETPLACE_METADATA.json\")[\"support_contact_required\"] is True\n assert json_load(release_dir / \"MARKETPLACE_CHANNEL_PLAN.json\")[\"primary_channel\"] == \"aws_data_exchange\"\n assert json_load(release_dir / \"BUYER_SAMPLE_POLICY.json\")[\"raw_sources_in_preview\"] is False\n assert json_load(release_dir / \"VERSION_POLICY.json\")[\"sku_immutable\"] is True\n assert json_load(release_dir / \"PRICING_EVIDENCE.json\")[\"computed_price_usd\"] == listing[\"price_usd\"]\n assert json_load(release_dir / \"LEGAL_REVIEW_PACKET.json\")[\"legal_review\"][\"approved\"] is False\n aws_posting = json_load(release_dir / \"aws_data_exchange\" / \"AWS_DATA_EXCHANGE_POSTING.json\")\n assert aws_posting[\"artifact_ready\"] is True\n assert aws_posting[\"aws_publish_ready\"] is False\n assert \"aws_data_exchange_provider_account_not_confirmed\" in aws_posting[\"account_blockers\"]\n assert release_verify[\"aws_data_exchange_verify\"][\"passed\"]\n for name in (\n \"MARKETPLACE_LISTING.json\",\n \"COMMERCIAL_READINESS.json\",\n \"TERMS.md\",\n \"MARKETPLACE_METADATA.json\",\n \"MARKETPLACE_CHANNEL_PLAN.json\",\n \"BUYER_SAMPLE_POLICY.json\",\n \"VERSION_POLICY.json\",\n \"PRICING_EVIDENCE.json\",\n \"LEGAL_REVIEW_PACKET.json\",\n ):\n (release_dir / name).unlink()\n broken_release = verify_autonomous_release(release_dir / \"AUTONOMOUS_RELEASE.json\")\n assert not broken_release[\"passed\"]\n repaired_release = repair_release_artifacts(release_dir=release_dir)\n assert repaired_release[\"repaired\"]\n assert verify_autonomous_release(release_dir / \"AUTONOMOUS_RELEASE.json\")[\"passed\"]\n listing = json_load(release_dir / \"MARKETPLACE_LISTING.json\")\n external = verify_external_listing_release(release_dir)\n assert not external[\"passed\"]\n assert \"legal_review_not_approved\" in external[\"failures\"]\n assert \"listing_not_marked_externally_listable\" in external[\"failures\"]\n assert \"marketplace_support_contact_unset\" in external[\"failures\"]\n packets = write_marketplace_packets(release_dir=release_dir)\n assert packets[\"passed\"]\n assert not packets[\"external_listing_passed\"]\n assert \"legal_review_not_approved\" in packets[\"external_blockers\"]\n assert (release_dir / \"marketplace_packets\" / \"aws_data_exchange_listing_draft.md\").exists()\n assert \"AWS Data Exchange Listing Draft\" in (\n release_dir / \"marketplace_packets\" / \"aws_data_exchange_listing_draft.md\"\n ).read_text(encoding=\"utf-8\")\n try:\n approve_external_listing(\n release_dir=release_dir,\n reviewer=\"qualified-reviewer\",\n notes=\"This should fail before mutating approval fields.\",\n support_contact=\"[REDACTED_EMAIL]\",\n refund_policy=\"Refund requests reviewed within 14 days for undelivered or corrupt packages.\",\n tax_vat_status=\"seller_account_configured_for_us_eu_tax_review\",\n package_output_dir=tmp_path / \"wrong-packages\",\n )\n assert False, \"approval with wrong package output dir should fail\"\n except ValueError as error:\n assert \"package_output_dir must be the release package root\" in str(error)\n assert json_load(release_dir / \"MARKETPLACE_LISTING.json\")[\"externally_listable\"] is False\n assert json_load(release_dir / \"LEGAL_REVIEW_PACKET.json\")[\"legal_review\"][\"approved\"] is False\n approved = approve_external_listing(\n release_dir=release_dir,\n reviewer=\"qualified-reviewer\",\n notes=\"Reviewed local test terms, marketplace fields, privacy posture, and listing metadata.\",\n support_contact=\"[REDACTED_EMAIL]\",\n refund_policy=\"Refund requests reviewed within 14 days for undelivered or corrupt packages.\",\n tax_vat_status=\"seller_account_configured_for_us_eu_tax_review\",\n )\n approved_listing = json_load(release_dir / \"MARKETPLACE_LISTING.json\")\n approved_legal = json_load(release_dir / \"LEGAL_REVIEW_PACKET.json\")\n approved_marketplace = json_load(release_dir / \"MARKETPLACE_METADATA.json\")\n assert approved[\"approved\"]\n assert verify_external_listing_release(release_dir)[\"passed\"]\n assert verify_autonomous_release(release_dir / \"AUTONOMOUS_RELEASE.json\")[\"passed\"]\n assert verify_package(output_root / \"packages\" / \"privacy_provenance_eval_000001.package.json\")[\"passed\"]\n package_manifest_path = output_root / \"packages\" / \"privacy_provenance_eval_000001.package.json\"\n approved_package_manifest = json_load(package_manifest_path)\n tampered_package_manifest = json_load(package_manifest_path)\n tampered_package_manifest[\"candidate_id\"] = \"wrong_candidate\"\n tampered_package_manifest[\"package_manifest_hash\"] = sha256_json(\n {**tampered_package_manifest, \"package_manifest_hash\": \"\"}\n )\n package_manifest_path.write_text(json.dumps(tampered_package_manifest, indent=2, sort_keys=True) + \"\\n\", encoding=\"utf-8\")\n tampered_package_verify = verify_package(package_manifest_path)\n assert not tampered_package_verify[\"passed\"]\n assert \"package_name_candidate_mismatch\" in tampered_package_verify[\"failures\"]\n assert \"embedded_manifest_lock_candidate_mismatch\" in tampered_package_verify[\"failures\"]\n package_manifest_path.write_text(\n json.dumps(approved_package_manifest, indent=2, sort_keys=True) + \"\\n\",\n encoding=\"utf-8\",\n )\n assert verify_package(package_manifest_path)[\"passed\"]\n package_path = output_root / \"packages\" / \"privacy_provenance_eval_000001.tar.gz\"\n original_package_bytes = package_path.read_bytes()\n malicious_package_path = tmp_path / \"malicious.tar.gz\"\n import io\n\n with tarfile.open(package_path, \"r:gz\") as source_archive:\n with tarfile.open(malicious_package_path, \"w:gz\") as target_archive:\n for member in source_archive.getmembers():\n extracted = source_archive.extractfile(member) if member.isfile() else None\n target_archive.addfile(member, extracted)\n link = tarfile.TarInfo(\"privacy_provenance_eval_000001/bundle/raw-source-link\")\n link.type = tarfile.SYMTYPE\n link.linkname = \"/home/[USER]\"\n target_archive.addfile(link)\n package_path.write_bytes(malicious_package_path.read_bytes())\n malicious_manifest = json_load(package_manifest_path)\n malicious_manifest[\"package_hash\"] = sha256_bytes(package_path.read_bytes())\n malicious_manifest[\"package_manifest_hash\"] = sha256_json({**malicious_manifest, \"package_manifest_hash\": \"\"})\n package_manifest_path.write_text(json.dumps(malicious_manifest, indent=2, sort_keys=True) + \"\\n\", encoding=\"utf-8\")\n malicious_verify = verify_package(package_manifest_path)\n assert not malicious_verify[\"passed\"]\n assert \"unsafe_member_link:privacy_provenance_eval_000001/bundle/raw-source-link\" in malicious_verify[\"failures\"]\n package_path.write_bytes(b\"\")\n unreadable_manifest = json_load(package_manifest_path)\n unreadable_manifest[\"package_hash\"] = sha256_bytes(package_path.read_bytes())\n unreadable_manifest[\"package_manifest_hash\"] = sha256_json({**unreadable_manifest, \"package_manifest_hash\": \"\"})\n package_manifest_path.write_text(json.dumps(unreadable_manifest, indent=2, sort_keys=True) + \"\\n\", encoding=\"utf-8\")\n unreadable_verify = verify_package(package_manifest_path)\n assert not unreadable_verify[\"passed\"]\n assert any(item.startswith(\"package_archive_unreadable:\") for item in unreadable_verify[\"failures\"])\n package_path.write_bytes(original_package_bytes)\n package_manifest_path.write_text(\n json.dumps(approved_package_manifest, indent=2, sort_keys=True) + \"\\n\",\n encoding=\"utf-8\",\n )\n assert verify_package(package_manifest_path)[\"passed\"]\n with tarfile.open(output_root / \"packages\" / \"privacy_provenance_eval_000001.tar.gz\", \"r:gz\") as archive:\n assert not any(name.endswith(\"AUTONOMOUS_RELEASE.json\") for name in archive.getnames())\n assert approved_listing[\"externally_listable\"] is True\n assert approved_legal[\"legal_review\"][\"approved\"] is True\n assert approved_marketplace[\"support_contact\"] == \"[REDACTED_EMAIL]\"\n approved_manifest = json_load(release_dir / \"AUTONOMOUS_RELEASE.json\")\n assert approved_manifest[\"external_listing_verify\"][\"passed\"]\n refreshed = refresh_release_package(release_dir=release_dir)\n assert refreshed[\"refreshed\"]\n assert refreshed[\"external_verify\"][\"passed\"]\n try:\n approve_external_listing(\n release_dir=release_dir,\n reviewer=\"second-reviewer\",\n notes=\"Should not mutate an already externally approved release.\",\n support_contact=\"[REDACTED_EMAIL]\",\n refund_policy=\"Different policy.\",\n tax_vat_status=\"different_tax_status\",\n )\n assert False, \"second external approval should fail\"\n except ValueError as error:\n assert \"already approved\" in str(error)\n assert verify_planner_queues(output_root / \"queues\")[\"passed\"]\n assert planner_health(output_root=output_root, state_path=output_root / \"PRODUCT_PLANNER_STATE.json\")[\"passed\"]\n bundle_readme = release_dir / \"bundle\" / \"README.md\"\n bundle_readme.write_text(bundle_readme.read_text(encoding=\"utf-8\") + \"\\nTampered after approval.\\n\", encoding=\"utf-8\")\n tampered_external = verify_external_listing_release(release_dir)\n assert not tampered_external[\"passed\"]\n assert \"autonomous_release_verification_failed\" in tampered_external[\"failures\"]\n queue = output_root / \"queues\" / \"privacy_provenance_eval.jsonl\"\n assert queue.exists()\n assert sum(1 for _ in queue.open(\"r\", encoding=\"utf-8\")) == 1","source_id":"foundry::tests/test_local_benchmark.py::test_product_planner_closes_releases_and_continues","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_release_ledger_writes_are_locked_and_atomic::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: privacy, release, planner, benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 5","instruction":"Write a pytest test for Primitive Foundry that verifies: test release ledger writes are locked and atomic.","output":"def test_release_ledger_writes_are_locked_and_atomic(tmp_path) -> None:\n import concurrent.futures\n\n from primitive_foundry.product_planner import claim_release_id, load_release_ledger\n\n release_dir = tmp_path / \"releases\" / \"privacy_provenance_eval_000001\"\n release_dir.mkdir(parents=True)\n\n def claim(_index: int) -> None:\n claim_release_id(release_dir, lock_hash=\"same-lock-hash\")\n\n with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool:\n list(pool.map(claim, range(20)))\n\n ledger = load_release_ledger(tmp_path / \"releases\")\n assert ledger[\"releases\"][\"privacy_provenance_eval_000001\"][\"claimed\"] is True\n assert ledger[\"releases\"][\"privacy_provenance_eval_000001\"][\"lock_hash\"] == \"same-lock-hash\"\n assert ledger[\"ledger_hash\"] == sha256_json({**ledger, \"ledger_hash\": \"\"})\n assert (tmp_path / \"releases\" / \".RELEASE_LEDGER.json.lock\").exists()\n assert not list((tmp_path / \"releases\").glob(\".RELEASE_LEDGER.json.*.tmp\"))","source_id":"foundry::tests/test_local_benchmark.py::test_release_ledger_writes_are_locked_and_atomic","task":"python_test_generation"}
{"id":"foundry::tests/test_local_benchmark.py::test_foundry_handles_hinge_run_request_as_bus_contract::generate","input":"Source path: tests/test_local_benchmark.py\nDomains: privacy, release, bus, planner, curation, dataset, benchmark\nImports: primitive_foundry.cells, primitive_foundry.commercial, primitive_foundry.compare, primitive_foundry.curation_brain, primitive_foundry.dataset, primitive_foundry.external_listing, primitive_foundry.foundry_bridge, primitive_foundry.generate_source_cards, primitive_foundry.generators, primitive_foundry.inspect_adapter, primitive_foundry.lifecycle, primitive_foundry.marketplace_packet, primitive_foundry.node_ops, primitive_foundry.primitive_bus_adapter, primitive_foundry.product_factory, primitive_foundry.product_planner, primitive_foundry.promotion, primitive_foundry.release, primitive_foundry.runner, primitive_foundry.scorers, primitive_foundry.source_curation, primitive_foundry.sterilization, primitive_foundry.summary, primitive_foundry.train_router, primitive_foundry.v04\nAssertion count: 7","instruction":"Write a pytest test for Primitive Foundry that verifies: test foundry handles hinge run request as bus contract.","output":"def test_foundry_handles_hinge_run_request_as_bus_contract(tmp_path) -> None:\n import json\n\n from primitive_foundry.bus_orchestration import handle_foundry_run_requested\n\n sources = []\n for index in range(2):\n source = tmp_path / f\"privacy_source_{index}.md\"\n source.write_text(\n \"private privacy provenance dataset eval benchmark release quality foundry source\",\n encoding=\"utf-8\",\n )\n sources.append(source)\n\n events = tmp_path / \"events.jsonl\"\n names = [\"alpha\", \"bravo\"]\n with events.open(\"w\", encoding=\"utf-8\") as handle:\n for index, (source, name) in enumerate(zip(sources, names), start=1):\n handle.write(\n json.dumps(\n {\n \"event_id\": f\"bus-request-{index}\",\n \"text\": f\"High value privacy provenance eval dataset release {name} source for quality gates.\",\n \"source_path\": str(source),\n \"tags\": [\"privacy\", \"provenance\", \"eval\", name],\n },\n sort_keys=True,\n )\n + \"\\n\"\n )\n\n result = handle_foundry_run_requested(\n {\n \"requested_action\": \"run-product-node\",\n \"coordinator\": \"hinge\",\n \"events_path\": str(events),\n \"output_root\": str(tmp_path / \"products\"),\n \"state_path\": str(tmp_path / \"products\" / \"PRODUCT_PLANNER_STATE.json\"),\n \"iterations\": 1,\n \"poll_seconds\": 0,\n \"target_size\": \"micro\",\n \"target_count\": 2,\n \"min_source_diversity\": 2,\n \"dedupe_threshold\": 1.0,\n \"delivery_shapes\": [\"tar_gz\"],\n }\n )\n\n assert result[\"passed\"] is True\n assert [event[\"event_type\"] for event in result[\"events\"]] == [\n \"foundry.run.started\",\n \"foundry.curation.plan.emitted\",\n \"foundry.run.completed\",\n ]\n assert result[\"events\"][0][\"payload\"][\"direct_agent_call\"] is False\n assert result[\"events\"][1][\"payload\"][\"coordination\"] == \"event-bus-only\"\n assert result[\"events\"][2][\"payload\"][\"human_escalation_agent\"] == \"fin\"\n assert result[\"events\"][2][\"payload\"][\"releases_created\"] == 1\n assert (tmp_path / \"products\" / \"releases\" / \"privacy_provenance_eval_000001\").exists()","source_id":"foundry::tests/test_local_benchmark.py::test_foundry_handles_hinge_run_request_as_bus_contract","task":"python_test_generation"}
{"id":"foundry::tests/test_release_artifact_packaging.py::test_croissant_in_tarball_references_real_files::generate","input":"Source path: tests/test_release_artifact_packaging.py\nDomains: release, dataset\nImports: primitive_foundry.node_ops, primitive_foundry.product_planner\nAssertion count: 4","instruction":"Write a pytest test for Primitive Foundry that verifies: test croissant in tarball references real files.","output":"def test_croissant_in_tarball_references_real_files(\n release_dir: tuple[Path, Path, Path]\n) -> None:\n _, package, _ = release_dir\n with tarfile.open(package, \"r:gz\") as archive:\n croissant_member = next(\n (m for m in archive.getmembers() if Path(m.name).name == \"CROISSANT.jsonld\"),\n None,\n )\n assert croissant_member is not None\n payload = json.loads(archive.extractfile(croissant_member).read().decode(\"utf-8\"))\n assert payload[\"@type\"] == \"sc:Dataset\"\n assert payload[\"distribution\"], \"Croissant must reference at least one file\"\n for entry in payload[\"distribution\"]:\n assert entry[\"sha256\"] and len(entry[\"sha256\"]) == 64","source_id":"foundry::tests/test_release_artifact_packaging.py::test_croissant_in_tarball_references_real_files","task":"python_test_generation"}
{"id":"foundry::tests/test_sterilization_adversarial.py::test_redacts_pem_private_key_block::generate","input":"Source path: tests/test_sterilization_adversarial.py\nDomains: sterilization\nImports: primitive_foundry, primitive_foundry.sterilization\nAssertion count: 2","instruction":"Write a pytest test for Primitive Foundry that verifies: test redacts pem private key block.","output":"def test_redacts_pem_private_key_block() -> None:\n pem = \"[REDACTED_PRIVATE_KEY]\\nMIIEpAIBAAK\\n-----END RSA PRIVATE KEY-----\"\n result = sterilize_text(f\"leaking secret: {pem}\", max_chars=400)\n assert \"private_key_block\" in result.redacted_fields\n assert pem not in result.text","source_id":"foundry::tests/test_sterilization_adversarial.py::test_redacts_pem_private_key_block","task":"python_test_generation"}
{"id":"foundry::tests/test_sterilization_adversarial.py::test_redacts_openssh_private_key::generate","input":"Source path: tests/test_sterilization_adversarial.py\nDomains: sterilization\nImports: primitive_foundry, primitive_foundry.sterilization\nAssertion count: 2","instruction":"Write a pytest test for Primitive Foundry that verifies: test redacts openssh private key.","output":"def test_redacts_openssh_private_key() -> None:\n pem = \"[REDACTED_PRIVATE_KEY]\\naaaaaa\\n-----END OPENSSH PRIVATE KEY-----\"\n result = sterilize_text(pem, max_chars=400)\n assert any(\n tag in result.redacted_fields for tag in (\"ssh_private_key_openssh\", \"private_key_block\")\n )\n assert \"OPENSSH\" not in result.text","source_id":"foundry::tests/test_sterilization_adversarial.py::test_redacts_openssh_private_key","task":"python_test_generation"}
{"id":"foundry::primitive-harness/tests/test_runtime.py::test_runner_enforces_per_record_timeout::generate","input":"Source path: primitive-harness/tests/test_runtime.py\nDomains: foundry\nImports: none\nAssertion count: 2","instruction":"Write a pytest test for Primitive Foundry that verifies: test runner enforces per record timeout.","output":"def test_runner_enforces_per_record_timeout() -> None:\n from primitive_harness.bundle import Bundle\n from primitive_harness.runner import run\n\n bundle = Bundle(\n root=Path(\"/tmp/test-bundle\"),\n manifest={},\n schema={},\n harness_version={},\n rubric={},\n domain_review={},\n pvtr_receipts={},\n records=[{\"record_id\": \"timeout-1\", \"features\": {\"expected_cell_ids\": [\"ok\"]}}],\n )\n\n def slow_agent(record: dict) -> str:\n time.sleep(1)\n return \"ok\"\n\n try:\n run(slow_agent, bundle, per_record_timeout_s=0.01)\n assert False, \"slow agent should time out\"\n except TimeoutError as error:\n assert \"AgentTimeout\" in str(error)","source_id":"foundry::primitive-harness/tests/test_runtime.py::test_runner_enforces_per_record_timeout","task":"python_test_generation"}
|