context-primitive-code-agent-pack-v0 / data /foundry /symbol_explanations.eval.jsonl
Primitive-Origins's picture
Add free Hub release: context-primitive-code-agent-pack-v0
5334ec3 verified
Raw History Blame Contribute Delete
100 kB
{"id":"primitive_foundry.aws_data_exchange.verify_aws_release_inputs::explain","input":"Module: primitive_foundry.aws_data_exchange\nDomains: sterilization, release, marketplace, commercial\nSource path: primitive_foundry/aws_data_exchange.py\n\ndef verify_aws_release_inputs(release: Path) -> dict[str, Any]:\n failures: list[str] = []\n bundle = release / \"bundle\"\n bundle_verify = verify_foundry_bundle(bundle) if bundle.exists() else {\"passed\": False, \"failures\": [\"missing_bundle\"]}\n if not bundle_verify.get(\"passed\"):\n failures.append(\"bundle_verify_failed\")\n sterilized = verify_sterilized_bundle(bundle) if bundle.exists() else {\"passed\": False, \"failures\": [\"missing_bundle\"]}\n if not sterilized.get(\"passed\"):\n failures.append(\"bundle_sterilization_failed\")\n preview = bundle / \"preview\" / \"preview_records.jsonl\"\n if preview.exists():\n preview_verify = verify_sterilized_jsonl(preview)\n if not preview_verify.get(\"passed\"):\n failures.append(\"preview_sterilization_failed\")\n else:\n failures.append(\"missing_sterilized_preview\")\n promotion_path = first_file(release / \"promotions\", \"*.promotion.json\")\n review_path = first_file(release / \"reviews\", \"*.review.json\")\n autonomous_manifest = release / \"AUTONOMOUS_RELEASE.json\"\n commercial_listing = release / \"MARKETPLACE_LISTING.json\"\n if not promotion_path and not autonomous_manifest.exists() and not commercial_listing.exists():\n failures.append(\"missing_promotion_autonomous_or_commercial_manifest\")\n else:\n promotion_verify = verify_promotion_manifest(promotion_path) if promotion_path else {\"passed\": True}\n if not promotion_verify.get(\"passed\"):\n failures.append(\"promotion_verify_failed\")\n if not review_path and not commercial_listing.exists():\n failures.append(\"missing_review_or_commercial_listing\")\n else:\n review_verify = verify_review_manifest(review_path) if review_path else {\"passed\": True, \"decision\": \"commercial_release\"}\n if not review_verify.get(\"passed\") or review_verify.get(\"decision\") != \"approved\":\n if not commercial_listing.exists():\n failures.append(\"review_not_approved\")\n if commercial_listing.exists():\n commercial_verify = verify_commercial_release(release)\n if not commercial_verify.get(\"passed\"):\n failures.append(\"commercial_release_verify_failed\")\n release_index = release / \"RELEASE_INDEX.json\"\n if release_index.exists() and not verify_release_index(release_index).get(\"passed\"):\n failures.append(\"release_index_verify_failed\")\n return {\n \"artifact_ready\": not failures,\n \"failures\": failures,\n \"bundle\": bundle_verify,\n \"sterilization\": sterilized,\n \"promotion_manifest\": str(promotion_path) if promotion_path else \"\",\n \"review_manifest\": str(review_path) if review_path else \"\",\n }","instruction":"Explain the role of `def verify_aws_release_inputs(release: Path) -> dict[str, Any]` in Primitive Foundry.","output":"`verify_aws_release_inputs` is a function in `primitive_foundry.aws_data_exchange`. It belongs to the sterilization, release, marketplace, commercial area of Primitive Foundry.","source_id":"primitive_foundry.aws_data_exchange.verify_aws_release_inputs","task":"python_symbol_explanation"}
{"id":"primitive_foundry.bus_orchestration.handle_foundry_run_requested::explain","input":"Module: primitive_foundry.bus_orchestration\nDomains: release, bus, curation\nSource path: primitive_foundry/bus_orchestration.py\n\ndef handle_foundry_run_requested(payload: dict[str, Any]) -> dict[str, Any]:\n \"\"\"Run a Foundry product-node request received from the event bus.\n\n This is intentionally a handler, not a user-facing CLI. Hinge emits the\n request event; a Foundry subscriber calls this function and republishes the\n returned status events for Fin/Athena to observe.\n \"\"\"\n request = validate_run_request(payload)\n started = status_event(FOUNDRY_RUN_STARTED, request, {\"status\": \"started\"})\n try:\n result = run_product_node(\n events_path=request[\"events_path\"],\n output_root=request[\"output_root\"],\n state_path=request.get(\"state_path\"),\n iterations=int(request.get(\"iterations\") or 1),\n poll_seconds=float(request.get(\"poll_seconds\") or 0),\n target_size=str(request.get(\"target_size\") or \"standard\"),\n target_count=request.get(\"target_count\"),\n min_value_score=float(request.get(\"min_value_score\") or 0.62),\n min_source_diversity=int(request.get(\"min_source_diversity\") or 3),\n classifier=str(request.get(\"classifier\") or \"deterministic\"),\n dedupe_threshold=float(request.get(\"dedupe_threshold\") or 0.92),\n reviewer=str(request.get(\"reviewer\") or \"local-autonomous-reviewer\"),\n delivery_shapes=tuple(request.get(\"delivery_shapes\") or (\"tar_gz\",)),\n standing_orders_path=request.get(\"standing_orders_path\"),\n curation_plan_path=request.get(\"curation_plan_path\"),\n )\n except Exception as exc:\n failed = status_event(\n FOUNDRY_RUN_FAILED,\n request,\n {\n \"status\": \"failed\",\n \"error_class\": exc.__class__.__name__,\n \"error_message\": str(exc),\n \"fin_visible\": True,\n },\n )\n return {\"passed\": False, \"request\": request, \"events\": [started, failed], \"result\": None}\n\n completed = status_event(\n FOUNDRY_RUN_COMPLETED,\n request,\n {\n \"status\": \"completed\",\n \"passed\": bool(result.get(\"passed\")),\n \"releases_created\": int(result.get(\"releases_created\") or 0),\n \"fin_visible\": bool(result.get(\"releases_created\")),\n \"result\": result,\n },\n )\n events = [started]\n for item in result.get(\"results\", []):\n if item.get(\"curation_event\"):\n events.append(item[\"curation_event\"])\n events.append(completed)\n return {\"passed\": bool(result.get(\"passed\")), \"request\": request, \"events\": events, \"result\": result}","instruction":"Explain the role of `def handle_foundry_run_requested(payload: dict[str, Any]) -> dict[str, Any]` in Primitive Foundry.","output":"`handle_foundry_run_requested` is a function in `primitive_foundry.bus_orchestration`. It belongs to the release, bus, curation area of Primitive Foundry.","source_id":"primitive_foundry.bus_orchestration.handle_foundry_run_requested","task":"python_symbol_explanation"}
{"id":"primitive_foundry.bus_poller.PollTickResult::explain","input":"Module: primitive_foundry.bus_poller\nDomains: bus\nSource path: primitive_foundry/bus_poller.py\n\nclass PollTickResult:\n tick: int\n started_at: float\n finished_at: float\n pulled_count: int = 0\n imported_count: int = 0\n acked_count: int = 0\n ok: bool = True\n error: str = \"\"\n\n def to_dict(self) -> dict[str, Any]:\n return {\n \"tick\": self.tick,\n \"started_at\": self.started_at,\n \"finished_at\": self.finished_at,\n \"duration_seconds\": round(self.finished_at - self.started_at, 4),\n \"pulled_count\": self.pulled_count,\n \"imported_count\": self.imported_count,\n \"acked_count\": self.acked_count,\n \"ok\": self.ok,\n \"error\": self.error,\n }","instruction":"Explain the role of `class PollTickResult` in Primitive Foundry.","output":"`PollTickResult` is a class in `primitive_foundry.bus_poller`. It belongs to the bus area of Primitive Foundry.","source_id":"primitive_foundry.bus_poller.PollTickResult","task":"python_symbol_explanation"}
{"id":"primitive_foundry.commercial.verify_external_listing_release::explain","input":"Module: primitive_foundry.commercial\nDomains: release, marketplace, commercial, planner\nSource path: primitive_foundry/commercial.py\n\ndef verify_external_listing_release(release_dir: str | Path) -> dict[str, Any]:\n commercial = verify_commercial_release(release_dir)\n directory = Path(release_dir)\n failures = list(commercial[\"failures\"])\n legal_path = directory / \"LEGAL_REVIEW_PACKET.json\"\n listing_path = directory / \"MARKETPLACE_LISTING.json\"\n marketplace_path = directory / \"MARKETPLACE_METADATA.json\"\n manifest_path = directory / \"AUTONOMOUS_RELEASE.json\"\n legal = json.loads(legal_path.read_text(encoding=\"utf-8\")) if legal_path.exists() else {}\n listing = json.loads(listing_path.read_text(encoding=\"utf-8\")) if listing_path.exists() else {}\n marketplace = json.loads(marketplace_path.read_text(encoding=\"utf-8\")) if marketplace_path.exists() else {}\n failures.extend(verify_complementary_bundle(directory, listing))\n failures.extend(verify_card_accuracy(directory, listing))\n if legal.get(\"legal_review\", {}).get(\"approved\") is not True:\n failures.append(\"legal_review_not_approved\")\n if not legal.get(\"legal_review\", {}).get(\"reviewer\"):\n failures.append(\"legal_review_missing_reviewer\")\n if not legal.get(\"legal_review\", {}).get(\"reviewed_at\"):\n failures.append(\"legal_review_missing_reviewed_at\")\n if listing.get(\"externally_listable\") is not True:\n failures.append(\"listing_not_marked_externally_listable\")\n failures.extend(verify_external_marketplace_fields(marketplace))\n if manifest_path.exists():\n manifest = json.loads(manifest_path.read_text(encoding=\"utf-8\"))\n if manifest.get(\"release_hash\") != sha256_json({**manifest, \"release_hash\": \"\"}):\n failures.append(\"autonomous_release_hash_mismatch\")\n from .product_planner import verify_autonomous_release\n\n release_verify = verify_autonomous_release(manifest_path)\n if not release_verify[\"passed\"]:\n failures.append(\"autonomous_release_verification_failed\")\n package_manifest = manifest.get(\"package\", {}).get(\"manifest\")\n if package_manifest:\n from .node_ops import verify_package\n\n package_verify = verify_package(package_manifest)\n if not package_verify[\"passed\"]:\n failures.append(\"package_failed\")\n else:\n failures.append(\"missing_package_manifest\")\n else:\n failures.append(\"missing_autonomous_release_manifest\")\n return {\n \"passed\": not failures,\n \"release_dir\": str(directory),\n \"commercial_passed\": commercial[\"passed\"],\n \"externally_listable\": not failures,\n \"release_verify\": release_verify if manifest_path.exists() else {\"passed\": False, \"failures\": [\"missing\"]},\n \"failures\": failures,\n }","instruction":"Explain the role of `def verify_external_listing_release(release_dir: str | Path) -> dict[str, Any]` in Primitive Foundry.","output":"`verify_external_listing_release` is a function in `primitive_foundry.commercial`. It belongs to the release, marketplace, commercial, planner area of Primitive Foundry.","source_id":"primitive_foundry.commercial.verify_external_listing_release","task":"python_symbol_explanation"}
{"id":"primitive_foundry.commercial.release_version_policy::explain","input":"Module: primitive_foundry.commercial\nDomains: release, commercial\nSource path: primitive_foundry/commercial.py\n\ndef release_version_policy(release_id: str, sku: str, version: str, target_size: str) -> dict[str, Any]:\n payload = {\n \"manifest_type\": \"aml_release_version_policy\",\n \"release_id\": release_id,\n \"sku\": sku,\n \"version\": version,\n \"target_size\": target_size,\n \"sku_immutable\": True,\n \"package_immutable_after_release\": True,\n \"new_data_requires_new_release_id\": True,\n \"replacement_requires_new_sku_or_version\": True,\n \"continuous_products_use_snapshot_versions\": True,\n }\n payload[\"version_policy_hash\"] = sha256_json({**payload, \"version_policy_hash\": \"\"})\n return payload","instruction":"Explain the role of `def release_version_policy(release_id: str, sku: str, version: str, target_size: str) -> dict[str, Any]` in Primitive Foundry.","output":"`release_version_policy` is a function in `primitive_foundry.commercial`. It belongs to the release, commercial area of Primitive Foundry.","source_id":"primitive_foundry.commercial.release_version_policy","task":"python_symbol_explanation"}
{"id":"primitive_foundry.commercial.verify_version_policy_payload::explain","input":"Module: primitive_foundry.commercial\nDomains: release, commercial\nSource path: primitive_foundry/commercial.py\n\ndef verify_version_policy_payload(payload: dict[str, Any], listing: dict[str, Any]) -> list[str]:\n failures = []\n if payload.get(\"manifest_type\") != \"aml_release_version_policy\":\n failures.append(\"invalid_version_policy_type\")\n if payload.get(\"version_policy_hash\") != sha256_json({**payload, \"version_policy_hash\": \"\"}):\n failures.append(\"version_policy_hash_mismatch\")\n if payload.get(\"sku\") != listing.get(\"sku\"):\n failures.append(\"version_policy_sku_mismatch\")\n if payload.get(\"release_id\") != listing.get(\"release_id\"):\n failures.append(\"version_policy_release_id_mismatch\")\n if payload.get(\"target_size\") != listing.get(\"target_size\"):\n failures.append(\"version_policy_target_size_mismatch\")\n if payload.get(\"version\") != listing.get(\"version\"):\n failures.append(\"version_policy_version_mismatch\")\n for key in (\"sku_immutable\", \"package_immutable_after_release\", \"new_data_requires_new_release_id\"):\n if payload.get(key) is not True:\n failures.append(f\"version_policy_false:{key}\")\n return failures","instruction":"Explain the role of `def verify_version_policy_payload(payload: dict[str, Any], listing: dict[str, Any]) -> list[str]` in Primitive Foundry.","output":"`verify_version_policy_payload` is a function in `primitive_foundry.commercial`. It belongs to the release, commercial area of Primitive Foundry.","source_id":"primitive_foundry.commercial.verify_version_policy_payload","task":"python_symbol_explanation"}
{"id":"primitive_foundry.commercial.verify_pricing_payload::explain","input":"Module: primitive_foundry.commercial\nDomains: commercial, license\nSource path: primitive_foundry/commercial.py\n\ndef verify_pricing_payload(payload: dict[str, Any], listing: dict[str, Any]) -> list[str]:\n failures = []\n if payload.get(\"manifest_type\") != \"aml_pricing_evidence\":\n failures.append(\"invalid_pricing_type\")\n if payload.get(\"pricing_hash\") != sha256_json({**payload, \"pricing_hash\": \"\"}):\n failures.append(\"pricing_hash_mismatch\")\n if payload.get(\"computed_price_usd\") != listing.get(\"price_usd\"):\n failures.append(\"pricing_listing_mismatch\")\n if payload.get(\"record_count\") != listing.get(\"record_count\"):\n failures.append(\"pricing_record_count_mismatch\")\n if payload.get(\"profile_record_count\") != listing.get(\"profile_record_count\"):\n failures.append(\"pricing_profile_record_count_mismatch\")\n if payload.get(\"commercial_tier\") != listing.get(\"commercial_tier\"):\n failures.append(\"pricing_commercial_tier_mismatch\")\n if payload.get(\"license_tier\") != listing.get(\"license_tier\"):\n failures.append(\"pricing_license_tier_mismatch\")\n if payload.get(\"review_level\") != listing.get(\"review_level\"):\n failures.append(\"pricing_review_level_mismatch\")\n if payload.get(\"computed_price_usd\", 0) <= 0:\n failures.append(\"pricing_non_positive\")\n if not payload.get(\"pricing_method\"):\n failures.append(\"pricing_method_missing\")\n return failures","instruction":"Explain the role of `def verify_pricing_payload(payload: dict[str, Any], listing: dict[str, Any]) -> list[str]` in Primitive Foundry.","output":"`verify_pricing_payload` is a function in `primitive_foundry.commercial`. It belongs to the commercial, license area of Primitive Foundry.","source_id":"primitive_foundry.commercial.verify_pricing_payload","task":"python_symbol_explanation"}
{"id":"primitive_foundry.commercial.verify_external_marketplace_fields::explain","input":"Module: primitive_foundry.commercial\nDomains: marketplace, commercial\nSource path: primitive_foundry/commercial.py\n\ndef verify_external_marketplace_fields(payload: dict[str, Any]) -> list[str]:\n failures = []\n if payload.get(\"support_contact_required\") is True and is_placeholder(payload.get(\"support_contact\")):\n failures.append(\"marketplace_support_contact_unset\")\n if payload.get(\"refund_policy_required\") is True and is_placeholder(payload.get(\"refund_policy\")):\n failures.append(\"marketplace_refund_policy_unset\")\n if payload.get(\"tax_vat_required\") is True and is_placeholder(payload.get(\"tax_vat_status\")):\n failures.append(\"marketplace_tax_vat_unset\")\n if payload.get(\"public_sample_available\") is not False:\n failures.append(\"marketplace_public_sample_not_blocked\")\n if payload.get(\"private_buyer_preview_available\") is not True:\n failures.append(\"marketplace_private_preview_not_enabled\")\n return failures","instruction":"Explain the role of `def verify_external_marketplace_fields(payload: dict[str, Any]) -> list[str]` in Primitive Foundry.","output":"`verify_external_marketplace_fields` is a function in `primitive_foundry.commercial`. It belongs to the marketplace, commercial area of Primitive Foundry.","source_id":"primitive_foundry.commercial.verify_external_marketplace_fields","task":"python_symbol_explanation"}
{"id":"primitive_foundry.curation_brain.StandingOrder::explain","input":"Module: primitive_foundry.curation_brain\nDomains: curation\nSource path: primitive_foundry/curation_brain.py\n\nclass StandingOrder:\n order_id: str\n priority: int = 50\n focus_families: tuple[str, ...] = ()\n product_kinds: tuple[str, ...] = ()\n keywords: tuple[str, ...] = ()\n banned_keywords: tuple[str, ...] = ()\n min_value_score: float = MEDIUM_VALUE_THRESHOLD\n target_count: int | None = None\n require_complementary_bundle: bool = True\n research_allowed: bool = False\n source: str = \"local\"\n notes: str = \"\"\n metadata: dict[str, Any] = field(default_factory=dict)\n\n @classmethod\n def from_dict(cls, payload: dict[str, Any], index: int = 0) -> \"StandingOrder\":\n data = payload.get(\"payload\") if isinstance(payload.get(\"payload\"), dict) else payload\n if not isinstance(data, dict):\n raise ValueError(\"standing order payload must be a dictionary\")\n order_id = str(data.get(\"order_id\") or data.get(\"id\") or f\"standing-order-{index:04d}\")\n return cls(\n order_id=order_id,\n priority=int(data.get(\"priority\") or 50),\n focus_families=tuple(str(item) for item in data.get(\"focus_families\", []) if str(item).strip()),\n product_kinds=tuple(str(item) for item in data.get(\"product_kinds\", []) if str(item).strip()),\n keywords=tuple(str(item).lower() for item in data.get(\"keywords\", []) if str(item).strip()),\n banned_keywords=tuple(str(item).lower() for item in data.get(\"banned_keywords\", []) if str(item).strip()),\n min_value_score=float(data.get(\"min_value_score\") or MEDIUM_VALUE_THRESHOLD),\n target_count=int(data[\"target_count\"]) if data.get(\"target_count\") is not None else None,\n require_complementary_bundle=bool(data.get(\"require_complementary_bundle\", True)),\n research_allowed=bool(data.get(\"research_allowed\", False)),\n source=str(data.get(\"source\") or payload.get(\"source\") or \"local\"),\n notes=str(data.get(\"notes\") or \"\"),\n metadata=dict(data.get(\"metadata\", {})) if isinstance(data.get(\"metadata\"), dict) else {},\n )\n\n def to_dict(self) -> dict[str, Any]:\n return {\n \"order_id\": self.order_id,\n \"priority\": self.priority,\n \"focus_families\": list(self.focus_families),\n \"product_kinds\": list(self.product_kinds),\n \"keywords\": list(self.keywords),\n \"banned_keywords\": list(self.banned_keywords),\n \"min_value_score\": self.min_value_score,\n \"target_count\": self.target_count,\n \"require_complementary_bundle\": self.require_complementary_bundle,\n \"research_allowed\": self.research_allowed,\n \"source\": self.source,\n \"notes\": self.notes,\n \"metadata\": self.metadata,\n }","instruction":"Explain the role of `class StandingOrder` in Primitive Foundry.","output":"`StandingOrder` is a class in `primitive_foundry.curation_brain`. It belongs to the curation area of Primitive Foundry.","source_id":"primitive_foundry.curation_brain.StandingOrder","task":"python_symbol_explanation"}
{"id":"primitive_foundry.curation_brain.build_curation_plan_event::explain","input":"Module: primitive_foundry.curation_brain\nDomains: bus, curation\nSource path: primitive_foundry/curation_brain.py\n\ndef build_curation_plan_event(plan: dict[str, Any]) -> dict[str, Any]:\n return {\n \"event_type\": CURATION_PLAN_EMITTED,\n \"source\": \"primitive_foundry.curation_brain\",\n \"payload\": {\n \"schema_version\": 1,\n \"coordination\": \"event-bus-only\",\n \"direct_agent_call\": False,\n \"direct_user_notification\": False,\n \"local_private_only\": True,\n \"plan_hash\": plan.get(\"plan_hash\"),\n \"opportunity_count\": len(plan.get(\"opportunities\", [])),\n \"research_request_count\": len(plan.get(\"research_requests\", [])),\n \"opportunities\": plan.get(\"opportunities\", []),\n },\n }","instruction":"Explain the role of `def build_curation_plan_event(plan: dict[str, Any]) -> dict[str, Any]` in Primitive Foundry.","output":"`build_curation_plan_event` is a function in `primitive_foundry.curation_brain`. It belongs to the bus, curation area of Primitive Foundry.","source_id":"primitive_foundry.curation_brain.build_curation_plan_event","task":"python_symbol_explanation"}
{"id":"primitive_foundry.curation_brain.llm_advisor_available::explain","input":"Module: primitive_foundry.curation_brain\nDomains: curation\nSource path: primitive_foundry/curation_brain.py\n\ndef llm_advisor_available(probe: Callable[[str], bool] | None = None) -> bool:\n if os.environ.get(LLM_ADVISOR_ENV_VAR, \"0\") not in (\"1\", \"true\", \"True\", \"yes\"):\n return False\n endpoint = os.environ.get(LLM_ENDPOINT_ENV_VAR, DEFAULT_LLM_ENDPOINT)\n if probe is not None:\n return bool(probe(endpoint))\n return _default_probe(endpoint)","instruction":"Explain the role of `def llm_advisor_available(probe: Callable[[str], bool] | None=None) -> bool` in Primitive Foundry.","output":"`llm_advisor_available` is a function in `primitive_foundry.curation_brain`. It belongs to the curation area of Primitive Foundry.","source_id":"primitive_foundry.curation_brain.llm_advisor_available","task":"python_symbol_explanation"}
{"id":"primitive_foundry.curation_brain._normalise_advisor_response::explain","input":"Module: primitive_foundry.curation_brain\nDomains: curation\nSource path: primitive_foundry/curation_brain.py\n\ndef _normalise_advisor_response(\n raw: Any,\n opportunities: list[dict[str, Any]],\n) -> dict[str, Any]:\n valid_families = {item[\"family\"] for item in opportunities}\n if not isinstance(raw, dict):\n return {\"status\": \"rejected\", \"reason\": \"advisor_returned_non_dict\"}\n ranked = []\n for entry in raw.get(\"ranked_families\", []):\n if isinstance(entry, dict) and entry.get(\"family\") in valid_families:\n ranked.append(\n {\n \"family\": entry[\"family\"],\n \"rationale\": str(entry.get(\"rationale\") or \"\")[:500],\n \"complementary_kinds_to_add\": [\n str(kind)\n for kind in entry.get(\"complementary_kinds_to_add\", [])\n if str(kind) in PRODUCT_KINDS\n ],\n \"recommend_research\": bool(entry.get(\"recommend_research\", False)),\n }\n )\n bundle_proposals = []\n for entry in raw.get(\"bundle_proposals\", []):\n if isinstance(entry, dict) and entry.get(\"family\") in valid_families:\n bundle_proposals.append(\n {\n \"family\": entry[\"family\"],\n \"composition\": [\n str(kind)\n for kind in entry.get(\"composition\", [])\n if str(kind) in PRODUCT_KINDS\n ],\n \"complementary\": bool(entry.get(\"complementary\", True)),\n \"rationale\": str(entry.get(\"rationale\") or \"\")[:500],\n }\n )\n return {\n \"status\": \"ok\",\n \"ranked_families\": ranked,\n \"bundle_proposals\": bundle_proposals,\n \"advisor_notes\": str(raw.get(\"advisor_notes\") or \"\")[:1000],\n }","instruction":"Explain the role of `def _normalise_advisor_response(raw: Any, opportunities: list[dict[str, Any]]) -> dict[str, Any]` in Primitive Foundry.","output":"`_normalise_advisor_response` is a function in `primitive_foundry.curation_brain`. It belongs to the curation area of Primitive Foundry.","source_id":"primitive_foundry.curation_brain._normalise_advisor_response","task":"python_symbol_explanation"}
{"id":"primitive_foundry.delivery.parquet.read_jsonl::explain","input":"Module: primitive_foundry.delivery.parquet\nDomains: foundry\nSource path: primitive_foundry/delivery/parquet.py\n\ndef read_jsonl(path: Path) -> list[dict[str, Any]]:\n rows = []\n with path.open(\"r\", encoding=\"utf-8\") as handle:\n for line in handle:\n stripped = line.strip()\n if stripped:\n rows.append(json.loads(stripped))\n return rows","instruction":"Explain the role of `def read_jsonl(path: Path) -> list[dict[str, Any]]` in Primitive Foundry.","output":"`read_jsonl` is a function in `primitive_foundry.delivery.parquet`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.delivery.parquet.read_jsonl","task":"python_symbol_explanation"}
{"id":"primitive_foundry.delivery.s3_manifest.write_s3_asset_manifest::explain","input":"Module: primitive_foundry.delivery.s3_manifest\nDomains: marketplace, atomic_write\nSource path: primitive_foundry/delivery/s3_manifest.py\n\ndef write_s3_asset_manifest(bundle_dir: Path, output_dir: Path) -> dict[str, Any]:\n output_dir.mkdir(parents=True, exist_ok=True)\n assets = []\n for path in sorted(item for item in bundle_dir.rglob(\"*\") if item.is_file()):\n assets.append(\n {\n \"relative_path\": str(path.relative_to(bundle_dir)),\n \"bytes\": path.stat().st_size,\n \"sha256\": sha256_bytes(path.read_bytes()),\n }\n )\n manifest = {\n \"shape\": \"s3_manifest\",\n \"marketplace\": \"aws_data_exchange\",\n \"source_bundle\": str(bundle_dir),\n \"asset_count\": len(assets),\n \"assets\": assets,\n \"cloud_upload_performed\": False,\n }\n atomic_write_json(output_dir / \"DELIVERY_MANIFEST.json\", manifest)\n return manifest","instruction":"Explain the role of `def write_s3_asset_manifest(bundle_dir: Path, output_dir: Path) -> dict[str, Any]` in Primitive Foundry.","output":"`write_s3_asset_manifest` is a function in `primitive_foundry.delivery.s3_manifest`. It belongs to the marketplace, atomic_write area of Primitive Foundry.","source_id":"primitive_foundry.delivery.s3_manifest.write_s3_asset_manifest","task":"python_symbol_explanation"}
{"id":"primitive_foundry.exporters.datasheet._fmt::explain","input":"Module: primitive_foundry.exporters.datasheet\nDomains: release, exporter\nSource path: primitive_foundry/exporters/datasheet.py\n\ndef _fmt(value: Any, default: str = \"Not specified for this release.\") -> str:\n text = str(value or \"\").strip()\n return text if text else default","instruction":"Explain the role of `def _fmt(value: Any, default: str='Not specified for this release.') -> str` in Primitive Foundry.","output":"`_fmt` is a function in `primitive_foundry.exporters.datasheet`. It belongs to the release, exporter area of Primitive Foundry.","source_id":"primitive_foundry.exporters.datasheet._fmt","task":"python_symbol_explanation"}
{"id":"primitive_foundry.families.canonical_family::explain","input":"Module: primitive_foundry.families\nDomains: foundry\nSource path: primitive_foundry/families.py\n\ndef canonical_family(name: str) -> str:\n if name in REGISTRY and not REGISTRY[name].legacy:\n return name\n for family in REGISTRY.values():\n if name in family.aliases and family.active:\n return family.name\n return name","instruction":"Explain the role of `def canonical_family(name: str) -> str` in Primitive Foundry.","output":"`canonical_family` is a function in `primitive_foundry.families`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.families.canonical_family","task":"python_symbol_explanation"}
{"id":"primitive_foundry.foundry_bridge.default_rubric::explain","input":"Module: primitive_foundry.foundry_bridge\nDomains: foundry\nSource path: primitive_foundry/foundry_bridge.py\n\ndef default_rubric(record: FoundryRecord) -> dict[str, Any]:\n return {\n \"type\": \"route_and_provenance\",\n \"pass_conditions\": [\"expected_cell_selected\", \"answer_contains_provenance\"],\n \"expected_cell_ids\": record.expected_cell_ids,\n }","instruction":"Explain the role of `def default_rubric(record: FoundryRecord) -> dict[str, Any]` in Primitive Foundry.","output":"`default_rubric` is a function in `primitive_foundry.foundry_bridge`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.foundry_bridge.default_rubric","task":"python_symbol_explanation"}
{"id":"primitive_foundry.foundry_bridge.verify_foundry_records::explain","input":"Module: primitive_foundry.foundry_bridge\nDomains: sterilization, dataset\nSource path: primitive_foundry/foundry_bridge.py\n\ndef verify_foundry_records(path: str | Path) -> dict[str, Any]:\n records = read_foundry_jsonl(path)\n failures: list[str] = []\n ids = [record[\"record_id\"] for record in records]\n source_hashes = [item for record in records for item in record.get(\"source_hashes\", [])]\n\n if len(ids) != len(set(ids)):\n failures.append(\"duplicate_record_ids\")\n if len(source_hashes) != len(set(source_hashes)):\n failures.append(\"duplicate_source_hashes\")\n\n for record in records:\n missing = [\n key\n for key in (\n \"record_id\",\n \"dataset_family\",\n \"dataset_version\",\n \"source_event_ids\",\n \"source_hashes\",\n \"source_system\",\n \"event_type\",\n \"sterilization\",\n \"domain_review\",\n \"rubric_id\",\n \"provenance_hash\",\n )\n if record.get(key) in (None, \"\", [], {})\n ]\n if missing:\n failures.append(f\"{record.get('record_id', '<missing>')}:missing:{','.join(missing)}\")\n if record.get(\"sterilization\", {}).get(\"status\") != \"clean\":\n failures.append(f\"{record['record_id']}:not_clean\")\n if record.get(\"features\", {}).get(\"raw_source_included\") is not False:\n failures.append(f\"{record['record_id']}:raw_source_flag_not_false\")\n review = record.get(\"domain_review\", {})\n if not isinstance(review, dict) or not review.get(\"reviewer_name\") or not review.get(\"reviewed_at\"):\n failures.append(f\"{record['record_id']}:missing_domain_review\")\n if not record.get(\"features\", {}).get(\"rubric\"):\n failures.append(f\"{record['record_id']}:missing_rubric\")\n if not record.get(\"rubric_id\"):\n failures.append(f\"{record['record_id']}:missing_rubric_id\")\n if not record.get(\"features\", {}).get(\"buyer_task\"):\n failures.append(f\"{record['record_id']}:missing_buyer_task\")\n sterilization = verify_sterilized_payload(record)\n if not sterilization[\"passed\"]:\n failures.extend(f\"{record['record_id']}:{item}\" for item in sterilization[\"failures\"])\n expected_hash = provenance_hash_for_payload(record)\n if record.get(\"provenance_hash\") != expected_hash:\n failures.append(f\"{record['record_id']}:bad_provenance_hash\")\n\n label_coverage = (\n sum(1 for record in records if record.get(\"labels\") or record.get(\"quality_label\") or record.get(\"outcome_label\"))\n / len(records)\n if records\n else 0.0\n )\n return {\n \"passed\": not failures,\n \"record_count\": len(records),\n \"failures\": failures,\n \"label_coverage\": round(label_coverage, 4),\n \"provenance_hash_coverage\": 1.0 if records and not any(\"bad_provenance_hash\" in item for item in failures) else 0.0,\n \"source_hash_coverage\": 1.0 if records and all(record.get(\"source_hashes\") for record in records) else 0.0,\n }","instruction":"Explain the role of `def verify_foundry_records(path: str | Path) -> dict[str, Any]` in Primitive Foundry.","output":"`verify_foundry_records` is a function in `primitive_foundry.foundry_bridge`. It belongs to the sterilization, dataset area of Primitive Foundry.","source_id":"primitive_foundry.foundry_bridge.verify_foundry_records","task":"python_symbol_explanation"}
{"id":"primitive_foundry.foundry_bridge.read_foundry_jsonl::explain","input":"Module: primitive_foundry.foundry_bridge\nDomains: foundry\nSource path: primitive_foundry/foundry_bridge.py\n\ndef read_foundry_jsonl(path: str | Path) -> list[dict[str, Any]]:\n records = []\n with Path(path).open(\"r\", encoding=\"utf-8\") as handle:\n for line_number, line in enumerate(handle, start=1):\n stripped = line.strip()\n if not stripped:\n continue\n try:\n records.append(json.loads(stripped))\n except json.JSONDecodeError as exc:\n raise ValueError(f\"Invalid Foundry JSONL at {path}:{line_number}: {exc}\") from exc\n return records","instruction":"Explain the role of `def read_foundry_jsonl(path: str | Path) -> list[dict[str, Any]]` in Primitive Foundry.","output":"`read_foundry_jsonl` is a function in `primitive_foundry.foundry_bridge`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.foundry_bridge.read_foundry_jsonl","task":"python_symbol_explanation"}
{"id":"primitive_foundry.generate_dataset.write_jsonl::explain","input":"Module: primitive_foundry.generate_dataset\nDomains: dataset\nSource path: primitive_foundry/generate_dataset.py\n\ndef write_jsonl(records: list[dict[str, Any]], output_path: Path) -> None:\n output_path.parent.mkdir(parents=True, exist_ok=True)\n with output_path.open(\"w\", encoding=\"utf-8\") as handle:\n for record in records:\n handle.write(json.dumps(record, sort_keys=True))\n handle.write(\"\\n\")","instruction":"Explain the role of `def write_jsonl(records: list[dict[str, Any]], output_path: Path) -> None` in Primitive Foundry.","output":"`write_jsonl` is a function in `primitive_foundry.generate_dataset`. It belongs to the dataset area of Primitive Foundry.","source_id":"primitive_foundry.generate_dataset.write_jsonl","task":"python_symbol_explanation"}
{"id":"primitive_foundry.generate_source_cards.source_id_key::explain","input":"Module: primitive_foundry.generate_source_cards\nDomains: source_card\nSource path: primitive_foundry/generate_source_cards.py\n\ndef source_id_key(source_id: str | None) -> str | None:\n if not source_id:\n return None\n return source_id.split(\"::\", 1)[0]","instruction":"Explain the role of `def source_id_key(source_id: str | None) -> str | None` in Primitive Foundry.","output":"`source_id_key` is a function in `primitive_foundry.generate_source_cards`. It belongs to the source_card area of Primitive Foundry.","source_id":"primitive_foundry.generate_source_cards.source_id_key","task":"python_symbol_explanation"}
{"id":"primitive_foundry.generate_source_cards.rebase_to_known_root::explain","input":"Module: primitive_foundry.generate_source_cards\nDomains: source_card\nSource path: primitive_foundry/generate_source_cards.py\n\ndef rebase_to_known_root(path: Path) -> Path | None:\n parts = path.parts\n if \"foundry\" in parts:\n relative = Path(*parts[parts.index(\"foundry\") + 1 :])\n return PROJECT_ROOT / relative\n marker = \"this is the context primitive core ecosystem with tennets\"\n if marker in parts:\n relative = Path(*parts[parts.index(marker) + 1 :])\n return ROOT / relative\n return None","instruction":"Explain the role of `def rebase_to_known_root(path: Path) -> Path | None` in Primitive Foundry.","output":"`rebase_to_known_root` is a function in `primitive_foundry.generate_source_cards`. It belongs to the source_card area of Primitive Foundry.","source_id":"primitive_foundry.generate_source_cards.rebase_to_known_root","task":"python_symbol_explanation"}
{"id":"primitive_foundry.generators.verified_agentic_build.VerifiedAgenticBuildGenerator::explain","input":"Module: primitive_foundry.generators.verified_agentic_build\nDomains: source_card\nSource path: primitive_foundry/generators/verified_agentic_build.py\n\nclass VerifiedAgenticBuildGenerator:\n family = \"verified_agentic_build\"\n\n def build_record(self, source_card: Any, index: int) -> dict[str, Any]:\n cells = [\"technology.embedding.2024\"]\n spec_id = f\"spec.{source_card.record_id}\"\n return {\n **source_base(source_card),\n \"source_family\": self.family,\n \"task\": \"spec_to_verified_patch\",\n \"domain_path\": \"technology.embedding\",\n \"spec_id\": spec_id,\n \"spec\": f\"Implement and verify the behavior described by this source card: {source_card.source_summary}\",\n \"starter_code_archive\": f\"artifacts/{source_card.record_id}/starter.tar.gz\",\n \"hidden_test_archive\": f\"artifacts/{source_card.record_id}/hidden_tests.tar.gz\",\n \"repair_budget\": {\"max_iterations\": 3, \"max_tokens\": 50000},\n \"query\": self.task_template().format(source=source_card.source_summary),\n \"buyer_task\": \"Produce a patch from the spec, run verification, and stay within the repair-loop budget.\",\n \"expected_outcome\": \"tests_pass_with_repair\",\n \"expected_answer\": cells[0],\n \"expected_cell_id\": cells[0],\n \"expected_cell_ids\": cells,\n \"rubric_id\": self.rubric_id(),\n \"rubric\": {\n \"type\": \"test_suite\",\n \"required_artifacts\": [\"spec\", \"tests\", \"patch_trace\", \"repair_loop_budget\"],\n \"pass_conditions\": [\"tests_pass\", \"trace_matches_patch\", \"budget_not_exceeded\"],\n \"repair_loop_budget\": 3,\n },\n \"ground_truth\": {\"expected_outcome\": \"tests_pass_with_repair\", \"max_repair_iterations\": 3},\n \"domain_review\": review_for(source_card),\n \"metadata\": {\"spec_id\": spec_id, \"repair_loop_budget\": 3},\n }\n\n def task_template(self) -> str:\n return \"Verify this agentic software build trace against spec, tests, and repair budget. Source: {source}\"\n\n def rubric_id(self) -> str:\n return \"rubric.build.v1\"","instruction":"Explain the role of `class VerifiedAgenticBuildGenerator` in Primitive Foundry.","output":"`VerifiedAgenticBuildGenerator` is a class in `primitive_foundry.generators.verified_agentic_build`. It belongs to the source_card area of Primitive Foundry.","source_id":"primitive_foundry.generators.verified_agentic_build.VerifiedAgenticBuildGenerator","task":"python_symbol_explanation"}
{"id":"primitive_foundry.io_utils._add_deterministic_tar_entry::explain","input":"Module: primitive_foundry.io_utils\nDomains: foundry\nSource path: primitive_foundry/io_utils.py\n\ndef _add_deterministic_tar_entry(archive: tarfile.TarFile, source: Path, arcname: str) -> None:\n if source.is_symlink():\n raise ValueError(f\"Archive entry may not be a symlink: {source}\")\n if source.is_dir():\n _add_path_to_archive(archive, source, arcname)\n for child in sorted(source.rglob(\"*\"), key=lambda item: item.relative_to(source).as_posix()):\n if child.is_symlink():\n raise ValueError(f\"Archive entry tree may not contain symlinks: {child}\")\n child_arcname = f\"{arcname}/{child.relative_to(source).as_posix()}\"\n _add_path_to_archive(archive, child, child_arcname)\n return\n _add_path_to_archive(archive, source, arcname)","instruction":"Explain the role of `def _add_deterministic_tar_entry(archive: tarfile.TarFile, source: Path, arcname: str) -> None` in Primitive Foundry.","output":"`_add_deterministic_tar_entry` is a function in `primitive_foundry.io_utils`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.io_utils._add_deterministic_tar_entry","task":"python_symbol_explanation"}
{"id":"primitive_foundry.marketplace_packet.render_channel_draft::explain","input":"Module: primitive_foundry.marketplace_packet\nDomains: release, marketplace, compliance\nSource path: primitive_foundry/marketplace_packet.py\n\ndef render_channel_draft(channel_name: str, context: dict[str, Any]) -> str:\n listing = context[\"listing\"]\n metadata = context[\"metadata\"]\n sample_policy = context[\"sample_policy\"]\n pricing = context[\"pricing\"]\n channel = channel_profile(context[\"channel_plan\"], channel_name)\n requirements = \"\\n\".join(f\"- {item}\" for item in channel.get(\"required_before_external_listing\", [])) or \"- account setup\"\n rights = \"\\n\".join(f\"- {item}\" for item in listing.get(\"usage_rights\", []))\n restrictions = \"\\n\".join(f\"- {item}\" for item in listing.get(\"restrictions\", []))\n tags = \", \".join(metadata.get(\"tags\", []))\n return (\n f\"# {channel_name} Listing Draft\\n\\n\"\n \"Status: local draft only. External upload remains blocked until legal/account approval passes.\\n\\n\"\n f\"Product title: {listing.get('title')}\\n\\n\"\n f\"SKU: `{listing.get('sku')}`\\n\\n\"\n f\"Version: `{listing.get('version')}`\\n\\n\"\n f\"Category: `{metadata.get('category')}`\\n\\n\"\n f\"Price: ${listing.get('price_usd')} {listing.get('currency', 'USD')}\\n\\n\"\n f\"Tags: {tags}\\n\\n\"\n \"## Short Description\\n\\n\"\n f\"{metadata.get('subtitle')}\\n\\n\"\n \"## Long Description\\n\\n\"\n f\"{listing.get('description')}\\n\\n\"\n \"This product is a private, provenance-backed AI evaluation data product. It includes verified \"\n \"manifests, quality evidence, terms, sample policy, and package hashes. Raw private sources are \"\n \"excluded.\\n\\n\"\n \"## Delivery\\n\\n\"\n f\"- Format: `{listing.get('delivery_format')}`\\n\"\n f\"- Record count: {listing.get('record_count')}\\n\"\n f\"- Package path: `{context['release_dir']}`\\n\"\n f\"- Public sample available: {metadata.get('public_sample_available')}\\n\"\n f\"- Private buyer preview available: {metadata.get('private_buyer_preview_available')}\\n\"\n f\"- Raw sources in preview: {sample_policy.get('raw_sources_in_preview')}\\n\\n\"\n \"## Rights\\n\\n\"\n f\"{rights}\\n\\n\"\n \"## Restrictions\\n\\n\"\n f\"{restrictions}\\n\\n\"\n \"## Compliance Claims To Preserve\\n\\n\"\n \"- US and EU regions declared\\n\"\n \"- No raw source files included\\n\"\n \"- No personal data included\\n\"\n \"- No sensitive personal data included\\n\"\n \"- Claims are limited to verified package contents\\n\\n\"\n \"## Pricing Evidence\\n\\n\"\n f\"- Method: {pricing.get('pricing_method')}\\n\"\n f\"- Computed price: ${pricing.get('computed_price_usd')} {listing.get('currency', 'USD')}\\n\\n\"\n \"## Account Requirements Before Upload\\n\\n\"\n f\"{requirements}\\n\"\n )","instruction":"Explain the role of `def render_channel_draft(channel_name: str, context: dict[str, Any]) -> str` in Primitive Foundry.","output":"`render_channel_draft` is a function in `primitive_foundry.marketplace_packet`. It belongs to the release, marketplace, compliance area of Primitive Foundry.","source_id":"primitive_foundry.marketplace_packet.render_channel_draft","task":"python_symbol_explanation"}
{"id":"primitive_foundry.node_ops.validate_rejected_log::explain","input":"Module: primitive_foundry.node_ops\nDomains: foundry\nSource path: primitive_foundry/node_ops.py\n\ndef validate_rejected_log(path: str | Path) -> dict[str, Any]:\n log_path = Path(path)\n if not log_path.exists():\n return {\"passed\": True, \"path\": str(log_path), \"record_count\": 0, \"failures\": []}\n failures = []\n count = 0\n with log_path.open(\"r\", encoding=\"utf-8\") as handle:\n for line_number, line in enumerate(handle, start=1):\n stripped = line.strip()\n if not stripped:\n continue\n count += 1\n try:\n payload = json.loads(stripped)\n except json.JSONDecodeError:\n failures.append(f\"invalid_json:{line_number}\")\n continue\n if not payload.get(\"reason\"):\n failures.append(f\"missing_reason:{line_number}\")\n return {\"passed\": not failures, \"path\": str(log_path), \"record_count\": count, \"failures\": failures}","instruction":"Explain the role of `def validate_rejected_log(path: str | Path) -> dict[str, Any]` in Primitive Foundry.","output":"`validate_rejected_log` is a function in `primitive_foundry.node_ops`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.node_ops.validate_rejected_log","task":"python_symbol_explanation"}
{"id":"primitive_foundry.node_ops.verify_embedded_manifest_lock::explain","input":"Module: primitive_foundry.node_ops\nDomains: foundry\nSource path: primitive_foundry/node_ops.py\n\ndef verify_embedded_manifest_lock(\n archive: tarfile.TarFile,\n members: list[str],\n candidate_id: str,\n) -> list[str]:\n failures = []\n lock_members = [name for name in members if name.endswith(\"MANIFEST.lock\")]\n if len(lock_members) != 1:\n failures.append(\"embedded_manifest_lock_count_mismatch\")\n return failures\n extracted = archive.extractfile(lock_members[0])\n if extracted is None:\n failures.append(\"embedded_manifest_lock_unreadable\")\n return failures\n try:\n lock = json.loads(extracted.read().decode(\"utf-8\"))\n except json.JSONDecodeError as exc:\n failures.append(f\"embedded_manifest_lock_invalid_json:{exc}\")\n return failures\n if str(lock.get(\"candidate_id\") or \"\") != candidate_id:\n failures.append(\"embedded_manifest_lock_candidate_mismatch\")\n if lock.get(\"manifest_lock_hash\") != sha256_json({**lock, \"manifest_lock_hash\": \"\"}):\n failures.append(\"embedded_manifest_lock_hash_mismatch\")\n return failures","instruction":"Explain the role of `def verify_embedded_manifest_lock(archive: tarfile.TarFile, members: list[str], candidate_id: str) -> list[str]` in Primitive Foundry.","output":"`verify_embedded_manifest_lock` is a function in `primitive_foundry.node_ops`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.node_ops.verify_embedded_manifest_lock","task":"python_symbol_explanation"}
{"id":"primitive_foundry.node_ops.verify_package_sterilization::explain","input":"Module: primitive_foundry.node_ops\nDomains: sterilization\nSource path: primitive_foundry/node_ops.py\n\ndef verify_package_sterilization(archive: tarfile.TarFile, members: list[str]) -> list[str]:\n failures = []\n for member_name in members:\n if not member_name.endswith(\".jsonl\"):\n continue\n extracted = archive.extractfile(member_name)\n if extracted is None:\n continue\n for line_number, raw in enumerate(extracted, start=1):\n stripped = raw.decode(\"utf-8\").strip()\n if not stripped:\n continue\n try:\n payload = json.loads(stripped)\n except json.JSONDecodeError as exc:\n failures.append(f\"package_sterilization:{member_name}:{line_number}:invalid_json:{exc}\")\n continue\n verified = verify_sterilized_payload(payload)\n failures.extend(\n f\"package_sterilization:{member_name}:{line_number}:{item}\"\n for item in verified[\"failures\"]\n )\n return failures","instruction":"Explain the role of `def verify_package_sterilization(archive: tarfile.TarFile, members: list[str]) -> list[str]` in Primitive Foundry.","output":"`verify_package_sterilization` is a function in `primitive_foundry.node_ops`. It belongs to the sterilization area of Primitive Foundry.","source_id":"primitive_foundry.node_ops.verify_package_sterilization","task":"python_symbol_explanation"}
{"id":"primitive_foundry.node_ops.write_service_files::explain","input":"Module: primitive_foundry.node_ops\nDomains: foundry\nSource path: primitive_foundry/node_ops.py\n\ndef write_service_files(\n *,\n output_dir: str | Path = \"node\",\n repo_dir: str | Path = \".\",\n events: str | Path = \"events/inbox/kernel_events.jsonl\",\n output_root: str | Path = artifact_path(\"products\", \"node-stream\"),\n state: str | Path = artifact_path(\"products\", \"node-stream\", \"STREAM_STATE.json\"),\n poll_seconds: float = 5.0,\n batch_size: int = 25,\n) -> dict[str, Any]:\n out = Path(output_dir)\n out.mkdir(parents=True, exist_ok=True)\n repo = Path(repo_dir).resolve()\n runner = out / \"run-primitive-foundry-node.sh\"\n service = out / \"primitive-foundry-node.service\"\n runner.write_text(\n \"#!/usr/bin/env bash\\n\"\n \"set -euo pipefail\\n\"\n f\"cd {repo}\\n\"\n \"primitive-foundry run-stream \"\n f\"--events {events} \"\n f\"--output-root {output_root} \"\n f\"--state {state} \"\n f\"--batch-size {batch_size} \"\n \"--iterations 0 \"\n f\"--poll-seconds {poll_seconds}\\n\",\n encoding=\"utf-8\",\n )\n runner.chmod(0o755)\n service.write_text(\n \"[Unit]\\n\"\n \"Description=Primitive Foundry Product Stream Node\\n\"\n \"After=network.target\\n\\n\"\n \"[Service]\\n\"\n \"Type=simple\\n\"\n f\"WorkingDirectory={repo}\\n\"\n f\"ExecStart={runner.resolve()}\\n\"\n \"Restart=always\\n\"\n \"RestartSec=5\\n\\n\"\n \"[Install]\\n\"\n \"WantedBy=default.target\\n\",\n encoding=\"utf-8\",\n )\n return {\"runner\": str(runner), \"service\": str(service)}","instruction":"Explain the role of `def write_service_files(*, output_dir: str | Path='node', repo_dir: str | Path='.', events: str | Path='events/inbox/kernel_events.jsonl', output_root: str | Path=artifact_path('products', 'node-stream'), state: str | Path=artifact_path('products', 'node-stream', 'STREAM_STATE.json'), poll_seconds: float=5.0, batch_size: int=25) -> dict[str, Any]` in Primitive Foundry.","output":"`write_service_files` is a function in `primitive_foundry.node_ops`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.node_ops.write_service_files","task":"python_symbol_explanation"}
{"id":"primitive_foundry.ontologies.verified_agentic_build.build_registry::explain","input":"Module: primitive_foundry.ontologies.verified_agentic_build\nDomains: source_card\nSource path: primitive_foundry/ontologies/verified_agentic_build.py\n\ndef build_registry(source_cards_path: str | Path, output_path: str | Path) -> dict:\n cells = []\n for card in read_cards(source_cards_path):\n spec_id = slug(str(card.get(\"metadata\", {}).get(\"spec_id\") or card.get(\"buyer_task\", {}).get(\"spec_id\") or card.get(\"record_id\")))\n cell_id = f\"build.python.test_repair.{spec_id}\"\n cells.append(\n Cell(\n cell_id=cell_id,\n domain_path=\"build.python.test_repair\",\n valid_from=str(card.get(\"valid_from\", \"2024-01-01\")),\n valid_until=card.get(\"valid_until\"),\n trust_score=0.93,\n status=\"active\",\n keywords=(\"build\", \"patch\", \"tests\", \"repair\", spec_id),\n answer_template=f\"Produce and verify a patch for build spec {spec_id}.\",\n )\n )\n return write_registry(cells, output_path, \"verified-agentic-build-ontology-v1\")","instruction":"Explain the role of `def build_registry(source_cards_path: str | Path, output_path: str | Path) -> dict` in Primitive Foundry.","output":"`build_registry` is a function in `primitive_foundry.ontologies.verified_agentic_build`. It belongs to the source_card area of Primitive Foundry.","source_id":"primitive_foundry.ontologies.verified_agentic_build.build_registry","task":"python_symbol_explanation"}
{"id":"primitive_foundry.primitive_bus_adapter.write_source_cache::explain","input":"Module: primitive_foundry.primitive_bus_adapter\nDomains: bus\nSource path: primitive_foundry/primitive_bus_adapter.py\n\ndef write_source_cache(cache_dir: Path, message: PrimitiveMessageView, text: str) -> Path:\n digest = sha256_json({\"subject\": message.subject, \"message_id\": message.message_id, \"payload\": message.payload})[:20]\n path = cache_dir / f\"{digest}.json\"\n payload = {\n \"manifest_type\": \"aml_primitive_bus_source_cache\",\n \"subject\": message.subject,\n \"message_id\": message.message_id,\n \"source_node_id\": message.source_node_id,\n \"source_agent_id\": message.source_agent_id,\n \"text\": text,\n \"payload_hash\": sha256_json(message.payload),\n }\n payload[\"cache_hash\"] = sha256_json({**payload, \"cache_hash\": \"\"})\n path.write_text(json.dumps(payload, indent=2, sort_keys=True) + \"\\n\", encoding=\"utf-8\")\n return path","instruction":"Explain the role of `def write_source_cache(cache_dir: Path, message: PrimitiveMessageView, text: str) -> Path` in Primitive Foundry.","output":"`write_source_cache` is a function in `primitive_foundry.primitive_bus_adapter`. It belongs to the bus area of Primitive Foundry.","source_id":"primitive_foundry.primitive_bus_adapter.write_source_cache","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_factory.process_event_stream_once::explain","input":"Module: primitive_foundry.product_factory\nDomains: product_factory\nSource path: primitive_foundry/product_factory.py\n\ndef process_event_stream_once(\n *,\n events_path: str | Path,\n output_root: str | Path = \"products\",\n state_path: str | Path | None = None,\n batch_size: int = 25,\n min_value_score: float = MEDIUM_VALUE_THRESHOLD,\n reviewer: str = \"local-owner\",\n approve: bool = True,\n min_records: int = 1,\n min_source_diversity: int = 1,\n require_product_kinds: tuple[str, ...] = (),\n dedupe_threshold: float = 0.92,\n classifier: str = \"deterministic\",\n) -> dict[str, Any]:\n if batch_size < 1:\n raise ValueError(\"batch_size must be >= 1\")\n root = Path(output_root)\n root.mkdir(parents=True, exist_ok=True)\n state_file = Path(state_path) if state_path else root / \"STREAM_STATE.json\"\n state = load_stream_state(state_file)\n processed_ids = set(state.get(\"processed_event_ids\", []))\n rejected_path = root / \"REJECTED_EVENTS.jsonl\"\n quarantine_dir = root / \"quarantine\"\n batches_dir = root / \"event_batches\"\n batches_dir.mkdir(parents=True, exist_ok=True)\n\n rows = read_product_event_rows(events_path)\n accepted_events: list[ProductEvent] = []\n accepted_fingerprints: list[set[str]] = []\n rejected_rows: list[dict[str, Any]] = []\n invalid_count = 0\n duplicate_count = 0\n low_value_count = 0\n deferred_count = 0\n semantic_duplicate_count = 0\n\n for row in rows:\n if row.event is None:\n invalid_count += 1\n rejected_rows.append(\n {\n \"line_number\": row.line_number,\n \"event_id\": None,\n \"accepted\": False,\n \"reason\": \"invalid_event\",\n \"error\": row.error,\n \"raw\": row.raw,\n }\n )\n continue\n event = row.event\n if event.event_id in processed_ids:\n duplicate_count += 1\n continue\n classification = classify_event_with_mode(event, min_value_score, classifier)\n if classification.accepted:\n if len(accepted_events) < batch_size:\n fingerprint = event_fingerprint(event)\n duplicate_of = semantic_duplicate_index(fingerprint, accepted_fingerprints, dedupe_threshold)\n if duplicate_of is not None:\n semantic_duplicate_count += 1\n processed_ids.add(event.event_id)\n rejected_rows.append(\n {\n \"line_number\": row.line_number,\n \"event_id\": event.event_id,\n \"accepted\": False,\n \"reason\": \"semantic_duplicate\",\n \"duplicate_of\": accepted_events[duplicate_of].event_id,\n \"classification\": asdict_classification(classification),\n \"source_path\": event.source_path,\n }\n )\n write_quarantine_event(quarantine_dir, event, \"semantic_duplicate\", classification)\n continue\n accepted_events.append(event)\n accepted_fingerprints.append(fingerprint)\n processed_ids.add(event.event_id)\n else:\n deferred_count += 1\n continue\n else:\n low_value_count += 1\n processed_ids.add(event.event_id)\n rejected_rows.append(\n {\n \"line_number\": row.line_number,\n \"event_id\": event.event_id,\n \"accepted\": False,\n \"reason\": \"below_value_threshold\",\n \"classification\": asdict_classification(classification),\n \"source_path\": event.source_path,\n }\n )\n write_quarantine_event(quarantine_dir, event, \"below_value_threshold\", classification)\n\n if rejected_rows:\n append_jsonl(rejected_path, rejected_rows)\n\n candidate = None\n if accepted_events:\n sequence = int(state.get(\"candidate_sequence\", 0)) + 1\n candidate_id = f\"aml_stream_{sequence:06d}\"\n batch_path = batches_dir / f\"{candidate_id}.events.jsonl\"\n write_jsonl(\n batch_path,\n [\n {\n \"event_id\": event.event_id,\n \"text\": event.text,\n \"source_path\": event.source_path,\n \"source_id\": event.source_id,\n \"tags\": event.tags,\n \"metadata\": event.metadata,\n }\n for event in accepted_events\n ],\n )\n candidate = build_candidate_from_events(\n events_path=batch_path,\n output_root=root,\n candidate_id=candidate_id,\n min_value_score=min_value_score,\n reviewer=reviewer,\n approve=approve,\n min_records=min_records,\n min_source_diversity=min_source_diversity,\n require_product_kinds=require_product_kinds,\n classifier=classifier,\n )\n state[\"candidate_sequence\"] = sequence\n state.setdefault(\"candidates\", []).append(candidate)\n\n state[\"processed_event_ids\"] = sorted(processed_ids)\n state[\"updated_at\"] = datetime.now(timezone.utc).isoformat()\n state[\"events_path\"] = str(events_path)\n state[\"classifier\"] = classifier\n save_stream_state(state_file, state)\n\n return {\n \"stream\": \"aml_product_stream\",\n \"events_path\": str(events_path),\n \"state_path\": str(state_file),\n \"processed_event_count\": len(processed_ids),\n \"new_candidate\": candidate,\n \"accepted_in_batch\": len(accepted_events),\n \"invalid_count\": invalid_count,\n \"duplicate_count\": duplicate_count,\n \"low_value_count\": low_value_count,\n \"deferred_count\": deferred_count,\n \"semantic_duplicate_count\": semantic_duplicate_count,\n \"rejected_path\": str(rejected_path),\n \"quarantine_dir\": str(quarantine_dir),\n \"passed\": candidate[\"passed\"] if candidate else True,\n }","instruction":"Explain the role of `def process_event_stream_once(*, events_path: str | Path, output_root: str | Path='products', state_path: str | Path | None=None, batch_size: int=25, min_value_score: float=MEDIUM_VALUE_THRESHOLD, reviewer: str='local-owner', approve: bool=True, min_records: int=1, min_source_diversity: int=1, require_product_kinds: tuple[str, ...]=(), dedupe_threshold: float=0.92, classifier: str='deterministic') -> dict[str, Any]` in Primitive Foundry.","output":"`process_event_stream_once` is a function in `primitive_foundry.product_factory`. It belongs to the product_factory area of Primitive Foundry.","source_id":"primitive_foundry.product_factory.process_event_stream_once","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_factory.semantic_duplicate_index::explain","input":"Module: primitive_foundry.product_factory\nDomains: product_factory\nSource path: primitive_foundry/product_factory.py\n\ndef semantic_duplicate_index(\n fingerprint: set[str],\n existing: list[set[str]],\n threshold: float,\n) -> int | None:\n if not fingerprint:\n return None\n for index, other in enumerate(existing):\n union = fingerprint | other\n if not union:\n continue\n similarity = len(fingerprint & other) / len(union)\n if similarity >= threshold:\n return index\n return None","instruction":"Explain the role of `def semantic_duplicate_index(fingerprint: set[str], existing: list[set[str]], threshold: float) -> int | None` in Primitive Foundry.","output":"`semantic_duplicate_index` is a function in `primitive_foundry.product_factory`. It belongs to the product_factory area of Primitive Foundry.","source_id":"primitive_foundry.product_factory.semantic_duplicate_index","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_factory.write_jsonl::explain","input":"Module: primitive_foundry.product_factory\nDomains: atomic_write, product_factory\nSource path: primitive_foundry/product_factory.py\n\ndef write_jsonl(path: Path, rows: list[dict[str, Any]]) -> None:\n atomic_write_jsonl(path, rows)","instruction":"Explain the role of `def write_jsonl(path: Path, rows: list[dict[str, Any]]) -> None` in Primitive Foundry.","output":"`write_jsonl` is a function in `primitive_foundry.product_factory`. It belongs to the atomic_write, product_factory area of Primitive Foundry.","source_id":"primitive_foundry.product_factory.write_jsonl","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_families.privacy_provenance.generate_privacy_provenance_card::explain","input":"Module: primitive_foundry.product_families.privacy_provenance\nDomains: privacy, release, license, compliance\nSource path: primitive_foundry/product_families/privacy_provenance.py\n\ndef generate_privacy_provenance_card(\n *,\n base: dict[str, Any],\n domain_path: str,\n sterile_text: str,\n reviewer: str,\n) -> dict[str, Any]:\n cells = expected_cells(\"legal.privacy\")\n return {\n **base,\n \"source_family\": FAMILY,\n \"task\": \"privacy_provenance_binary_rubric\",\n \"domain_path\": \"legal.privacy\",\n \"query\": (\n \"Evaluate this legal privacy compliance export for provenance-backed release. \"\n \"Regime: GDPR/CCPA/HIPAA/EU AI Act. Return pass only when the sanitized export, \"\n \"provenance manifest, license, retention basis, and buyer-visible audit trail are present. \"\n f\"Source: {sterile_text}\"\n ),\n \"expected_answer\": cells[0],\n \"expected_cell_id\": cells[0],\n \"expected_cell_ids\": cells,\n \"rubric\": {\n \"type\": \"binary\",\n \"pass_conditions\": [\n \"sanitized_export_present\",\n \"provenance_manifest_present\",\n \"compliance_regime_stated\",\n \"no_raw_private_source\",\n \"buyer_audit_trail_present\",\n ],\n \"fail_conditions\": [\"missing_manifest\", \"raw_private_source\", \"unstated_regime\"],\n },\n \"domain_review\": base_review(reviewer),\n \"buyer_task\": {\n \"family\": FAMILY,\n \"inputs\": [\"sanitized_export\", \"provenance_manifest\", \"compliance_regime\"],\n \"expected_output\": \"binary pass/fail with cited missing controls\",\n },\n \"metadata\": {\"compliance_regimes\": [\"GDPR\", \"CCPA\", \"HIPAA\", \"EU AI Act\"]},\n }","instruction":"Explain the role of `def generate_privacy_provenance_card(*, base: dict[str, Any], domain_path: str, sterile_text: str, reviewer: str) -> dict[str, Any]` in Primitive Foundry.","output":"`generate_privacy_provenance_card` is a function in `primitive_foundry.product_families.privacy_provenance`. It belongs to the privacy, release, license, compliance area of Primitive Foundry.","source_id":"primitive_foundry.product_families.privacy_provenance.generate_privacy_provenance_card","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_families.verified_agentic_software_build.generate_verified_agentic_software_build_card::explain","input":"Module: primitive_foundry.product_families.verified_agentic_software_build\nDomains: router\nSource path: primitive_foundry/product_families/verified_agentic_software_build.py\n\ndef generate_verified_agentic_software_build_card(\n *,\n base: dict[str, Any],\n domain_path: str,\n sterile_text: str,\n reviewer: str,\n) -> dict[str, Any]:\n cells = expected_cells(\"technology.embedding\")\n return {\n **base,\n \"source_family\": FAMILY,\n \"task\": \"agentic_build_verify_repair\",\n \"domain_path\": \"technology.embedding\",\n \"query\": (\n \"Verify an agentic software build for a technology embedding router. \"\n \"Given a spec, scaffold-to-patch trace, test suite, and repair-loop budget, \"\n \"score whether the agent produced a tested patch without exceeding the repair budget. \"\n f\"Source: {sterile_text}\"\n ),\n \"expected_answer\": cells[0],\n \"expected_cell_id\": cells[0],\n \"expected_cell_ids\": cells,\n \"rubric\": {\n \"type\": \"test_suite\",\n \"required_artifacts\": [\"spec\", \"tests\", \"patch_trace\", \"repair_loop_budget\"],\n \"pass_conditions\": [\"tests_pass\", \"trace_matches_patch\", \"budget_not_exceeded\"],\n \"repair_loop_budget\": 3,\n },\n \"domain_review\": base_review(reviewer),\n \"buyer_task\": {\n \"family\": FAMILY,\n \"inputs\": [\"spec\", \"test_suite\", \"agent_patch\", \"repair_trace\"],\n \"expected_output\": \"test-backed pass/fail with repair budget accounting\",\n },\n \"metadata\": {\"repair_loop_budget\": 3, \"verification_mode\": \"tests_plus_trace\"},\n }","instruction":"Explain the role of `def generate_verified_agentic_software_build_card(*, base: dict[str, Any], domain_path: str, sterile_text: str, reviewer: str) -> dict[str, Any]` in Primitive Foundry.","output":"`generate_verified_agentic_software_build_card` is a function in `primitive_foundry.product_families.verified_agentic_software_build`. It belongs to the router area of Primitive Foundry.","source_id":"primitive_foundry.product_families.verified_agentic_software_build.generate_verified_agentic_software_build_card","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_planner.manifest_lock_hash::explain","input":"Module: primitive_foundry.product_planner\nDomains: planner\nSource path: primitive_foundry/product_planner.py\n\ndef manifest_lock_hash(lock_path: Path) -> str:\n return sha256_json(json.loads(lock_path.read_text(encoding=\"utf-8\")))","instruction":"Explain the role of `def manifest_lock_hash(lock_path: Path) -> str` in Primitive Foundry.","output":"`manifest_lock_hash` is a function in `primitive_foundry.product_planner`. It belongs to the planner area of Primitive Foundry.","source_id":"primitive_foundry.product_planner.manifest_lock_hash","task":"python_symbol_explanation"}
{"id":"primitive_foundry.product_planner.append_queue_event::explain","input":"Module: primitive_foundry.product_planner\nDomains: planner\nSource path: primitive_foundry/product_planner.py\n\ndef append_queue_event(\n queue_path: Path,\n event: ProductEvent,\n classification: ProductClassification,\n family: str,\n) -> None:\n append_jsonl(\n queue_path,\n [\n {\n \"event\": {\n \"event_id\": event.event_id,\n \"text\": event.text,\n \"source_path\": event.source_path,\n \"source_id\": event.source_id,\n \"tags\": event.tags,\n \"metadata\": {**event.metadata, \"planner_family\": family},\n },\n \"classification\": {\n \"event_id\": classification.event_id,\n \"product_kind\": classification.product_kind,\n \"domain_path\": classification.domain_path,\n \"value_tier\": classification.value_tier,\n \"value_score\": classification.value_score,\n \"accepted\": classification.accepted,\n \"reasons\": classification.reasons,\n },\n \"queued_at\": datetime.now(timezone.utc).isoformat(),\n }\n ],\n )","instruction":"Explain the role of `def append_queue_event(queue_path: Path, event: ProductEvent, classification: ProductClassification, family: str) -> None` in Primitive Foundry.","output":"`append_queue_event` is a function in `primitive_foundry.product_planner`. It belongs to the planner area of Primitive Foundry.","source_id":"primitive_foundry.product_planner.append_queue_event","task":"python_symbol_explanation"}
{"id":"primitive_foundry.promotion.snapshot_bundle::explain","input":"Module: primitive_foundry.promotion\nDomains: foundry\nSource path: primitive_foundry/promotion.py\n\ndef snapshot_bundle(bundle_dir: str | Path) -> dict[str, Any]:\n bundle = Path(bundle_dir)\n files = {}\n for path in sorted(item for item in bundle.rglob(\"*\") if item.is_file()):\n relative = str(path.relative_to(bundle))\n files[relative] = sha256_bytes(path.read_bytes())\n return {\n \"bundle_dir\": str(bundle_dir),\n \"file_count\": len(files),\n \"files\": files,\n \"bundle_hash\": sha256_json(files),\n }","instruction":"Explain the role of `def snapshot_bundle(bundle_dir: str | Path) -> dict[str, Any]` in Primitive Foundry.","output":"`snapshot_bundle` is a function in `primitive_foundry.promotion`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.promotion.snapshot_bundle","task":"python_symbol_explanation"}
{"id":"primitive_foundry.promotion.snapshot_foundry_records::explain","input":"Module: primitive_foundry.promotion\nDomains: foundry\nSource path: primitive_foundry/promotion.py\n\ndef snapshot_foundry_records(path: str | Path) -> dict[str, Any]:\n records = read_foundry_jsonl(path)\n record_hashes = {\n str(record[\"record_id\"]): str(record[\"provenance_hash\"])\n for record in records\n }\n return {\n \"records_path\": str(path),\n \"record_count\": len(records),\n \"record_hashes\": record_hashes,\n \"records_hash\": sha256_json(record_hashes),\n }","instruction":"Explain the role of `def snapshot_foundry_records(path: str | Path) -> dict[str, Any]` in Primitive Foundry.","output":"`snapshot_foundry_records` is a function in `primitive_foundry.promotion`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.promotion.snapshot_foundry_records","task":"python_symbol_explanation"}
{"id":"primitive_foundry.pvtr_bridge.PvtrReceipt::explain","input":"Module: primitive_foundry.pvtr_bridge\nDomains: foundry\nSource path: primitive_foundry/pvtr_bridge.py\n\nclass PvtrReceipt:\n record_id: str\n shelf_id: str\n orb_id: str\n chain_position: int\n payload_hash: str\n endpoint: str","instruction":"Explain the role of `class PvtrReceipt` in Primitive Foundry.","output":"`PvtrReceipt` is a class in `primitive_foundry.pvtr_bridge`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.pvtr_bridge.PvtrReceipt","task":"python_symbol_explanation"}
{"id":"primitive_foundry.router.TrainedCentroidRouter::explain","input":"Module: primitive_foundry.router\nDomains: router\nSource path: primitive_foundry/router.py\n\nclass TrainedCentroidRouter:\n \"\"\"Local trained router backed by a JSON centroid model.\"\"\"\n\n def __init__(self, registry: CellRegistry, model_path: str | Path, top_k: int = 5) -> None:\n self.registry = registry\n self.model_path = Path(model_path)\n self.top_k = top_k\n self.model = load_router_model(self.model_path)\n self.dimensions = int(self.model[\"dimensions\"])\n self.centroids: dict[str, list[float]] = {\n cell_id: list(vector)\n for cell_id, vector in self.model[\"centroids\"].items()\n }\n\n def route(self, record: FoundryRecord) -> RouterDecision:\n query_vector = text_vector(record.query, self.dimensions)\n replacements = self.registry.replacements()\n candidates: list[tuple[str, float]] = []\n\n for cell in self.registry.active_cells():\n centroid = self.centroids.get(cell.cell_id)\n if centroid is None:\n continue\n score = cosine(query_vector, centroid)\n if record.stale_cell_id and replacements.get(record.stale_cell_id) == cell.cell_id:\n score += 0.2\n candidates.append((cell.cell_id, score))\n\n if not candidates:\n raise ValueError(f\"Trained router model has no active-cell centroids: {self.model_path}\")\n candidates.sort(key=lambda item: item[1], reverse=True)\n selected_cell_id, score = candidates[0]\n return RouterDecision(\n selected_cell_id=selected_cell_id,\n score=score,\n candidates=candidates[: self.top_k],\n top_k=self.top_k,\n )","instruction":"Explain the role of `class TrainedCentroidRouter` in Primitive Foundry.","output":"`TrainedCentroidRouter` is a class in `primitive_foundry.router`. It belongs to the router area of Primitive Foundry.","source_id":"primitive_foundry.router.TrainedCentroidRouter","task":"python_symbol_explanation"}
{"id":"primitive_foundry.runner.write_html_report::explain","input":"Module: primitive_foundry.runner\nDomains: router, benchmark\nSource path: primitive_foundry/runner.py\n\ndef write_html_report(report: dict[str, object], report_path: Path) -> None:\n metrics = report[\"metrics\"]\n results = report[\"results\"]\n assert isinstance(metrics, dict)\n assert isinstance(results, list)\n rows = []\n for result in results:\n status = \"PASS\" if result[\"passed\"] else \"FAIL\"\n rows.append(\n \"<tr>\"\n f\"<td>{escape(result['record_id'])}</td>\"\n f\"<td>{escape(result['task'])}</td>\"\n f\"<td>{status}</td>\"\n f\"<td>{escape(result['selected_cell_id'])}</td>\"\n f\"<td>{escape(result['expected_cell_id'])}</td>\"\n f\"<td>{result['scores']['routing']:.2f}</td>\"\n f\"<td>{result['scores']['top_k_routing']:.2f}</td>\"\n f\"<td>{result['scores']['expected_cells_coverage']:.2f}</td>\"\n \"</tr>\"\n )\n metric_items = \"\".join(\n f\"<li><strong>{escape(name)}</strong>: {value:.3f}</li>\"\n for name, value in metrics.items()\n )\n html = f\"\"\"<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>Primitive Foundry Benchmark Report</title>\n <style>\n body {{ font-family: system-ui, sans-serif; margin: 32px; color: #1f2933; }}\n table {{ border-collapse: collapse; width: 100%; margin-top: 20px; }}\n th, td {{ border: 1px solid #d9e2ec; padding: 8px; text-align: left; }}\n th {{ background: #f0f4f8; }}\n </style>\n</head>\n<body>\n <h1>Primitive Foundry Benchmark</h1>\n <p>Router: {escape(str(report['router']))} | Records: {report['record_count']} | Pass rate: {report['pass_rate']:.3f}</p>\n <h2>Metrics</h2>\n <ul>{metric_items}</ul>\n <h2>Results</h2>\n <table>\n <thead><tr><th>ID</th><th>Task</th><th>Status</th><th>Selected</th><th>Expected</th><th>Route</th><th>Top-K</th><th>Coverage</th></tr></thead>\n <tbody>{''.join(rows)}</tbody>\n </table>\n</body>\n</html>\n\"\"\"\n report_path.write_text(html, encoding=\"utf-8\")","instruction":"Explain the role of `def write_html_report(report: dict[str, object], report_path: Path) -> None` in Primitive Foundry.","output":"`write_html_report` is a function in `primitive_foundry.runner`. It belongs to the router, benchmark area of Primitive Foundry.","source_id":"primitive_foundry.runner.write_html_report","task":"python_symbol_explanation"}
{"id":"primitive_foundry.schema.EvalResult::explain","input":"Module: primitive_foundry.schema\nDomains: foundry\nSource path: primitive_foundry/schema.py\n\nclass EvalResult:\n record_id: str\n task: str\n selected_cell_id: str\n expected_cell_id: str\n expected_cell_ids: list[str]\n candidates: list[tuple[str, float]]\n scores: dict[str, float]\n passed: bool\n answer: str","instruction":"Explain the role of `class EvalResult` in Primitive Foundry.","output":"`EvalResult` is a class in `primitive_foundry.schema`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.schema.EvalResult","task":"python_symbol_explanation"}
{"id":"primitive_foundry.scorers.privacy_provenance.answer_text::explain","input":"Module: primitive_foundry.scorers.privacy_provenance\nDomains: privacy\nSource path: primitive_foundry/scorers/privacy_provenance.py\n\ndef answer_text(answer: dict[str, Any] | str) -> str:\n if isinstance(answer, dict):\n return \" \".join(str(value) for value in answer.values()).lower()\n return str(answer).lower()","instruction":"Explain the role of `def answer_text(answer: dict[str, Any] | str) -> str` in Primitive Foundry.","output":"`answer_text` is a function in `primitive_foundry.scorers.privacy_provenance`. It belongs to the privacy area of Primitive Foundry.","source_id":"primitive_foundry.scorers.privacy_provenance.answer_text","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.__init__.sha256_file::explain","input":"Module: primitive_foundry.source_adapters.__init__\nDomains: foundry\nSource path: primitive_foundry/source_adapters/__init__.py\n\ndef sha256_file(path: Path) -> str:\n digest = hashlib.sha256()\n with path.open(\"rb\") as handle:\n for chunk in iter(lambda: handle.read(1024 * 1024), b\"\"):\n digest.update(chunk)\n return digest.hexdigest()","instruction":"Explain the role of `def sha256_file(path: Path) -> str` in Primitive Foundry.","output":"`sha256_file` is a function in `primitive_foundry.source_adapters.__init__`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.__init__.sha256_file","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.__init__.parse_simple_yaml::explain","input":"Module: primitive_foundry.source_adapters.__init__\nDomains: foundry\nSource path: primitive_foundry/source_adapters/__init__.py\n\ndef parse_simple_yaml(text: str) -> dict[str, Any]:\n payload: dict[str, Any] = {}\n current_key = \"\"\n for raw_line in text.splitlines():\n line = raw_line.strip()\n if not line or line.startswith(\"#\"):\n continue\n if \":\" in line and not raw_line.startswith((\" \", \"-\")):\n key, value = line.split(\":\", 1)\n current_key = key.strip()\n payload[current_key] = parse_scalar(value.strip())\n continue\n if current_key and line.startswith(\"- \"):\n existing = payload.setdefault(current_key, [])\n if isinstance(existing, list):\n existing.append(parse_scalar(line[2:].strip()))\n return payload","instruction":"Explain the role of `def parse_simple_yaml(text: str) -> dict[str, Any]` in Primitive Foundry.","output":"`parse_simple_yaml` is a function in `primitive_foundry.source_adapters.__init__`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.__init__.parse_simple_yaml","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.agent_eval_scenarios.export_lab_run::explain","input":"Module: primitive_foundry.source_adapters.agent_eval_scenarios\nDomains: bus, exporter, source_card\nSource path: primitive_foundry/source_adapters/agent_eval_scenarios.py\n\ndef export_lab_run(run_dir: Path) -> list[SourceCard]:\n try:\n from context_primitive_lab.exporters.event_bus_source_card import export_scenario_run_as_source_cards\n except ImportError as exc:\n raise ImportError(\n \"Lab run directories require context_primitive_lab on PYTHONPATH to use the event-bus source-card exporter\"\n ) from exc\n return export_scenario_run_as_source_cards(run_dir)","instruction":"Explain the role of `def export_lab_run(run_dir: Path) -> list[SourceCard]` in Primitive Foundry.","output":"`export_lab_run` is a function in `primitive_foundry.source_adapters.agent_eval_scenarios`. It belongs to the bus, exporter, source_card area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.agent_eval_scenarios.export_lab_run","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.agentic_build_traces.build_source_cards::explain","input":"Module: primitive_foundry.source_adapters.agentic_build_traces\nDomains: sterilization, source_card\nSource path: primitive_foundry/source_adapters/agentic_build_traces.py\n\ndef build_source_cards(input_dir: Path, output_path: Path) -> list[SourceCard]:\n cards: list[SourceCard] = []\n run_dirs = [item for item in sorted(input_dir.iterdir()) if item.is_dir()]\n for index, run_dir in enumerate(run_dirs, start=1):\n exported = export_kairos_run(run_dir)\n if exported is not None:\n cards.append(exported)\n continue\n trace = load_trace(run_dir)\n spec = read_first_existing(run_dir, [\"spec.md\", \"spec.txt\"], str(trace.get(\"spec\", run_dir.name)))\n hidden_tests = first_existing(run_dir, [\"hidden_tests.tar.gz\", \"tests.tar.gz\", \"hidden_tests.zip\"])\n starter = first_existing(run_dir, [\"starter.tar.gz\", \"starter.zip\", \"repo.tar.gz\"])\n run_id = str(trace.get(\"run_id\", run_dir.name))\n outcome = str(trace.get(\"expected_outcome\", trace.get(\"status\", \"tests_pass\")))\n cards.append(\n {\n \"record_id\": f\"build-source-{index:04d}\",\n \"source_id\": f\"kairos::{run_id}::{directory_digest(run_dir)[:12]}\",\n \"source_path\": str(run_dir),\n \"source_summary\": \" \".join(spec.split())[:220],\n \"source_line_hint\": \"kairos-run-folder\",\n \"domain_path\": str(trace.get(\"domain_path\", \"software.build\")),\n \"query\": f\"Produce a verified patch for spec {run_id}: {' '.join(spec.split())[:180]}\",\n \"expected_answer\": \"software.build.2024\",\n \"expected_cell_id\": \"software.build.2024\",\n \"expected_cell_ids\": [\"software.build.2024\"],\n \"task\": \"spec_to_verified_patch\",\n \"source_family\": \"verified_agentic_build\",\n \"tags\": [\"agentic-build\", \"kairos\", outcome],\n \"rubric\": {\n \"rubric_id\": \"rubric.build.v1\",\n \"pass_conditions\": [\"tests_pass\", \"trace_matches_patch\", \"budget_not_exceeded\"],\n },\n \"buyer_task\": {\n \"family\": \"verified_agentic_build\",\n \"rubric_id\": \"rubric.build.v1\",\n \"spec_id\": run_id,\n \"starter_code_archive\": str(starter) if starter else \"\",\n \"hidden_test_archive\": str(hidden_tests) if hidden_tests else \"\",\n },\n \"domain_review\": {\n \"review_status\": str(trace.get(\"review_status\", \"founder_attested_v1\")),\n \"reviewer_name\": str(trace.get(\"reviewer_name\", \"local-owner\")),\n \"reviewer_credentials\": str(\n trace.get(\"reviewer_credentials\", \"Kairos run mapping review; SME review pending\")\n ),\n \"reviewed_at\": str(trace.get(\"reviewed_at\", \"2026-05-13\")),\n },\n \"metadata\": {\n \"adapter\": \"agentic_build_traces\",\n \"origin_adapter\": \"agentic_build_traces\",\n \"sterilization_ruleset\": \"build_traces\",\n \"run_id\": run_id,\n \"spec_id\": run_id,\n \"expected_outcome\": outcome,\n \"starter_code_archive\": str(starter) if starter else \"\",\n \"hidden_test_archive\": str(hidden_tests) if hidden_tests else \"\",\n \"repair_budget\": trace.get(\"repair_budget\", {\"max_iterations\": 3, \"max_tokens\": 50000}),\n },\n }\n )\n return write_source_cards(output_path, cards)","instruction":"Explain the role of `def build_source_cards(input_dir: Path, output_path: Path) -> list[SourceCard]` in Primitive Foundry.","output":"`build_source_cards` is a function in `primitive_foundry.source_adapters.agentic_build_traces`. It belongs to the sterilization, source_card area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.agentic_build_traces.build_source_cards","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.agentic_build_traces.export_kairos_run::explain","input":"Module: primitive_foundry.source_adapters.agentic_build_traces\nDomains: exporter, source_card\nSource path: primitive_foundry/source_adapters/agentic_build_traces.py\n\ndef export_kairos_run(run_dir: Path) -> SourceCard | None:\n try:\n from exporters.foundry_build_trace import export_build_run_as_source_card\n except ImportError:\n return None\n return export_build_run_as_source_card(run_dir)","instruction":"Explain the role of `def export_kairos_run(run_dir: Path) -> SourceCard | None` in Primitive Foundry.","output":"`export_kairos_run` is a function in `primitive_foundry.source_adapters.agentic_build_traces`. It belongs to the exporter, source_card area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.agentic_build_traces.export_kairos_run","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.agentic_build_traces.read_first_existing::explain","input":"Module: primitive_foundry.source_adapters.agentic_build_traces\nDomains: foundry\nSource path: primitive_foundry/source_adapters/agentic_build_traces.py\n\ndef read_first_existing(run_dir: Path, names: list[str], default: str) -> str:\n for name in names:\n path = run_dir / name\n if path.exists():\n return path.read_text(encoding=\"utf-8\")\n return default","instruction":"Explain the role of `def read_first_existing(run_dir: Path, names: list[str], default: str) -> str` in Primitive Foundry.","output":"`read_first_existing` is a function in `primitive_foundry.source_adapters.agentic_build_traces`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.agentic_build_traces.read_first_existing","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.agentic_build_traces.first_existing::explain","input":"Module: primitive_foundry.source_adapters.agentic_build_traces\nDomains: foundry\nSource path: primitive_foundry/source_adapters/agentic_build_traces.py\n\ndef first_existing(run_dir: Path, names: list[str]) -> Path | None:\n for name in names:\n path = run_dir / name\n if path.exists():\n return path\n return None","instruction":"Explain the role of `def first_existing(run_dir: Path, names: list[str]) -> Path | None` in Primitive Foundry.","output":"`first_existing` is a function in `primitive_foundry.source_adapters.agentic_build_traces`. It belongs to the foundry area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.agentic_build_traces.first_existing","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_adapters.privacy_regulatory.domain_review::explain","input":"Module: primitive_foundry.source_adapters.privacy_regulatory\nDomains: privacy\nSource path: primitive_foundry/source_adapters/privacy_regulatory.py\n\ndef domain_review(front_matter: dict[str, Any]) -> dict[str, Any]:\n return {\n \"review_status\": str(front_matter.get(\"review_status\", \"founder_attested_v1\")),\n \"reviewer_name\": str(front_matter.get(\"reviewer_name\", \"local-owner\")),\n \"reviewer_credentials\": str(\n front_matter.get(\"reviewer_credentials\", \"Regulatory-source mapping review; SME review pending\")\n ),\n \"reviewed_at\": str(front_matter.get(\"reviewed_at\", \"2026-05-13\")),\n }","instruction":"Explain the role of `def domain_review(front_matter: dict[str, Any]) -> dict[str, Any]` in Primitive Foundry.","output":"`domain_review` is a function in `primitive_foundry.source_adapters.privacy_regulatory`. It belongs to the privacy area of Primitive Foundry.","source_id":"primitive_foundry.source_adapters.privacy_regulatory.domain_review","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_curation.read_jsonl::explain","input":"Module: primitive_foundry.source_curation\nDomains: curation\nSource path: primitive_foundry/source_curation.py\n\ndef read_jsonl(path: str | Path) -> list[dict[str, Any]]:\n rows = []\n with Path(path).open(\"r\", encoding=\"utf-8\") as handle:\n for line_number, line in enumerate(handle, start=1):\n stripped = line.strip()\n if not stripped:\n continue\n try:\n rows.append(json.loads(stripped))\n except json.JSONDecodeError as exc:\n raise ValueError(f\"Invalid source card JSONL at {path}:{line_number}: {exc}\") from exc\n return rows","instruction":"Explain the role of `def read_jsonl(path: str | Path) -> list[dict[str, Any]]` in Primitive Foundry.","output":"`read_jsonl` is a function in `primitive_foundry.source_curation`. It belongs to the curation area of Primitive Foundry.","source_id":"primitive_foundry.source_curation.read_jsonl","task":"python_symbol_explanation"}
{"id":"primitive_foundry.source_curation.rubric_id_for_card::explain","input":"Module: primitive_foundry.source_curation\nDomains: curation\nSource path: primitive_foundry/source_curation.py\n\ndef rubric_id_for_card(card: dict[str, Any]) -> str:\n rubric = card.get(\"rubric\", {})\n buyer_task = card.get(\"buyer_task\", {})\n if isinstance(rubric, dict):\n for key in (\"rubric_id\", \"id\"):\n if rubric.get(key):\n return str(rubric[key])\n if isinstance(buyer_task, dict) and buyer_task.get(\"rubric_id\"):\n return str(buyer_task[\"rubric_id\"])\n return \"route_and_provenance\"","instruction":"Explain the role of `def rubric_id_for_card(card: dict[str, Any]) -> str` in Primitive Foundry.","output":"`rubric_id_for_card` is a function in `primitive_foundry.source_curation`. It belongs to the curation area of Primitive Foundry.","source_id":"primitive_foundry.source_curation.rubric_id_for_card","task":"python_symbol_explanation"}
{"id":"primitive_foundry.sterilization.SterilizationResult::explain","input":"Module: primitive_foundry.sterilization\nDomains: sterilization\nSource path: primitive_foundry/sterilization.py\n\nclass SterilizationResult:\n status: str\n text: str\n redacted_fields: list[str] = field(default_factory=list)\n risk_flags: list[str] = field(default_factory=list)\n notes: list[str] = field(default_factory=list)\n\n def to_dict(self) -> dict[str, Any]:\n return asdict(self)","instruction":"Explain the role of `class SterilizationResult` in Primitive Foundry.","output":"`SterilizationResult` is a class in `primitive_foundry.sterilization`. It belongs to the sterilization area of Primitive Foundry.","source_id":"primitive_foundry.sterilization.SterilizationResult","task":"python_symbol_explanation"}
{"id":"primitive_foundry.sterilization.verify_sterilized_payload::explain","input":"Module: primitive_foundry.sterilization\nDomains: sterilization\nSource path: primitive_foundry/sterilization.py\n\ndef verify_sterilized_payload(payload: Any) -> dict[str, Any]:\n failures: list[str] = []\n coppa_failures = _coppa_scan(payload)\n failures.extend(coppa_failures)\n string_count = 0\n oversize_paths: list[str] = []\n for path, value in iter_strings(payload):\n string_count += 1\n if len(value) > MAX_VERIFY_VALUE_BYTES:\n oversize_paths.append(path)\n scan_value = value[:MAX_VERIFY_VALUE_BYTES]\n else:\n scan_value = value\n if not is_machine_identifier_field(path):\n for name, pattern in SENSITIVE_PATTERNS:\n if pattern.search(scan_value):\n failures.append(f\"{path}:sensitive:{name}\")\n if RAW_PATH_PATTERN.search(scan_value):\n failures.append(f\"{path}:raw_local_path\")\n if WINDOWS_PATH_PATTERN.search(scan_value):\n failures.append(f\"{path}:raw_local_path\")\n for name, pattern in PATENT_SENSITIVE_PATTERNS:\n if pattern.search(scan_value):\n failures.append(f\"{path}:patent_sensitive_mechanism:{name}\")\n for path in oversize_paths:\n failures.append(f\"{path}:value_exceeds_{MAX_VERIFY_VALUE_BYTES}_bytes\")\n return {\n \"passed\": not failures,\n \"failures\": failures,\n \"string_count\": string_count,\n \"coppa_passed\": not coppa_failures,\n }","instruction":"Explain the role of `def verify_sterilized_payload(payload: Any) -> dict[str, Any]` in Primitive Foundry.","output":"`verify_sterilized_payload` is a function in `primitive_foundry.sterilization`. It belongs to the sterilization area of Primitive Foundry.","source_id":"primitive_foundry.sterilization.verify_sterilized_payload","task":"python_symbol_explanation"}
{"id":"primitive_foundry.summary.router_summary::explain","input":"Module: primitive_foundry.summary\nDomains: dataset, router, benchmark\nSource path: primitive_foundry/summary.py\n\ndef router_summary(\n dataset_path: str | Path,\n trained_router_path: str | Path | None = None,\n top_k: int = 5,\n) -> dict[str, Any]:\n router_specs: list[tuple[str, str | Path | None]] = [\n (\"keyword\", None),\n (\"hashed-embedding\", None),\n ]\n if trained_router_path:\n router_specs.append((\"trained\", trained_router_path))\n\n rows = []\n for router_name, router_path in router_specs:\n report = BenchmarkRunner(\n router_name=router_name,\n router_path=router_path,\n top_k=top_k,\n ).run_dataset(dataset_path)\n rows.append(\n {\n \"router\": router_name,\n \"router_path\": str(router_path) if router_path else None,\n \"record_count\": report[\"record_count\"],\n \"pass_rate\": report[\"pass_rate\"],\n \"routing\": report[\"metrics\"][\"routing\"],\n \"top_k_routing\": report[\"metrics\"][\"top_k_routing\"],\n \"expected_cells_coverage\": report[\"metrics\"][\"expected_cells_coverage\"],\n \"replacement\": report[\"metrics\"][\"replacement\"],\n \"staleness_detection\": report[\"metrics\"][\"staleness_detection\"],\n \"provenance\": report[\"metrics\"][\"provenance\"],\n }\n )\n return {\"dataset\": str(dataset_path), \"rows\": rows}","instruction":"Explain the role of `def router_summary(dataset_path: str | Path, trained_router_path: str | Path | None=None, top_k: int=5) -> dict[str, Any]` in Primitive Foundry.","output":"`router_summary` is a function in `primitive_foundry.summary`. It belongs to the dataset, router, benchmark area of Primitive Foundry.","source_id":"primitive_foundry.summary.router_summary","task":"python_symbol_explanation"}