"""Spec-integrity seam for the ingest spec (ingest-spec §11). The D7 analog of MAF's I1 framework-guard: this repo consumes ``shared/ingest-spec.md`` UNCHANGED from commons, and this test keeps the contract honest — it goes RED when the spec goes missing, names a concrete agent toolkit (the framework-neutrality rule), or stops documenting a contract field. It is the load-bearing guard the ingest layer relies on to keep being implementable "from this spec alone". """ from __future__ import annotations from pathlib import Path import pytest SPEC = Path(__file__).resolve().parents[1] / "shared" / "ingest-spec.md" # Concrete agent toolkits / vendor stacks the framework-neutral spec MUST NOT name. _FORBIDDEN_TOOLKITS = ( "claude", "anthropic", "openai", "gpt", "gemini", "llama", "langchain", "autogen", "crewai", "semantic kernel", "microsoft agent framework", "agent sdk", "bedrock", "vertex", "foundry", "maf", ) # Every field of the machine-readable contracts the D7 implementation depends on — the # spec's §12 cross-check table must keep documenting each (spec-integrity). _CONTRACT_FIELDS = ( "manifest_version", "source", "bundle_summary", "extractions", "source_system", "source_query", "ingested_at", "ingest_manifest", "generated", "okf_type", "max_rows", "root", "connection_ref", # the sql source reference the D7 sql connector (I5) depends on ) def test_spec_is_present() -> None: # RED if the spec goes missing (the layer stops being implementable from spec alone). assert SPEC.is_file(), "ingest-spec.md missing — subtree pull the commons contract" def test_spec_names_no_agent_toolkit() -> None: text = SPEC.read_text(encoding="utf-8").lower() present = [tok for tok in _FORBIDDEN_TOOLKITS if tok in text] assert not present, f"framework-neutral spec names a concrete toolkit: {present}" @pytest.mark.parametrize("field", _CONTRACT_FIELDS) def test_spec_documents_contract_field(field: str) -> None: text = SPEC.read_text(encoding="utf-8") assert field in text, f"contract field {field!r} is no longer documented in the spec"