Speiler MAF I4 fra shared/ingest-spec.md alene: manifest → SQL-konnektor → materialisert OKF-bundle, byte-identisk med den delte golden-fasiten. Gaten I4→I5 verifisert løst mot ground truth (MAF-commits d7e5f2f/4f45fe6/1b7612b) før arbeidet startet. Spec byte-identisk delt, ingen spec-endring (I4). - ingest.py: SqlSource (type: sql, id, connection_ref); ManifestContract.source er nå diskriminert union FileSource | SqlSource på type (http/ukjent tag → fail-fast). _render_sql_cell (§5 typed: NULL→"", int→decimal, float→korteste round-trip, str→verbatim m/ delt _escape_cell, annet→fail — aldri stille coercion). _resolve_connection_ref (env-oppslag §4/§8, usatt → fail-fast). _read_sql (read-only sqlite file:?mode=ro, ett SELECT, max_rows §8). _read_extraction dispatcher på source.type; materialisering/index/replacement uendret fra I3. - examples/ingest-golden-sql/: repo-lokal golden (byte-frossen kopi av I4s fasit). - Speiltester (I4s load-bearing-sett, gjennom SQL-konnektoren, detach-bevist røde): sql-golden byte-fasit + mutasjonskontroller · typed-cell/NULL (NY §I5-søm) · provenance/navigability/verdict-reservasjon/re-ingest-safety · SqlSource-kontrakt/ typed-rendering/connection_ref/max_rows/read-only · spec-integritet utvidet med connection_ref. Stale type:"sql"-avvisningscase erstattet (sql er gyldig post-I5). - docs/2026-07-04-I5-brief.md: brief + premiss-verifisering. Suite 265 passed uten nøkkel/nettverk (239 + 26 nye) · ruff + mypy --strict rene. [skip-docs] README + docs/extending.md er bevisst utsatt til I7 per sesjonsplan (programmet batcher ingest-doc der, avgrenset til det D7 faktisk har — CSV + SQL nå, HTTP/MCP kun pekere). Dokumentert i docs/2026-07-04-I5-brief.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MM6BWb1hWmJZuXFZ7rjxT
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
"""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"
|