chore(deps): re-pin llm-ingestion-okf to v0.3.1 + migrate tests to stable error codes
Pin dae0bd1a -> v0.3.1 (=692f2df) on the public Forgejo mirror; uv.lock pins the exact commit behind the tag. - Drop the mypy override: the library ships py.typed from v0.2.0, so strict mode now follows its real types instead of follow_untyped_imports. - Migrate 8 library-error assertions from pytest.raises(match=...) to exc.value.code — message text is explicitly unstable from v0.3.0, the codes are the stability contract. - Fix a real breakage the bump surfaced: IngestResult gained a required `stamp` field (d3a3bcc), which the delegation fake did not construct. - The read-only SQL test loses resolution under the code contract (`sql_failed` is generic), so it now proves read-onlyness by effect — the write never lands — instead of by message wording. - Correct the guard plan: G1's persist-gate anchor (ingest.py:372-387) died with the 2026-07-16 adoption. Door A is ungated by the library's own README, so gating stays our responsibility at the call site. Verified: 426 tests green, golden output byte-exact unchanged, full gate clean (ruff + format + mypy strict). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmNAgbRXUgvoSKxVK4Bevv
This commit is contained in:
parent
698e8f21dd
commit
a7e8ffecb8
6 changed files with 41 additions and 23 deletions
|
|
@ -59,8 +59,15 @@ går live. Det er derfor guarden er «når, ikke hvis».
|
||||||
Tre trigger-gatede wiringer, hver forankret i en eksisterende roadmap-beslutning:
|
Tre trigger-gatede wiringer, hver forankret i en eksisterende roadmap-beslutning:
|
||||||
|
|
||||||
### G1 — http-kilden går live · gate: D-B-utvidelse (i dag IKKE på D7-roadmap)
|
### G1 — http-kilden går live · gate: D-B-utvidelse (i dag IKKE på D7-roadmap)
|
||||||
- **Persist-gate:** i `_read_extraction`/`materialize`, MELLOM http-fetch og skriving av
|
- **Persist-gate:** MELLOM http-fetch og skriving av `ingest-{id}.md`.
|
||||||
`ingest-{id}.md` (`ingest.py:372-387`).
|
- **KORRIGERT 2026-07-20 (pin-bump til v0.3.1):** den opprinnelige forankringen
|
||||||
|
(`_read_extraction`/`materialize` i `ingest.py:372-387`) er DØD — adopsjonen 2026-07-16
|
||||||
|
flyttet den koden til `llm-ingestion-okf`; lokal `ingest.py` er nå en 63-linjers adapter.
|
||||||
|
Biblioteket bekrefter selv at dør A er **ugatet** («What is gated today: nothing» — README):
|
||||||
|
null runtime-avhengigheter, ingen guard-kall før skriving. Gating er derfor VÅRT ansvar på
|
||||||
|
kallstedet. To mulige forankringer når http går live: (a) wrap i vår egen seam
|
||||||
|
(`ingest.materialize`) rundt bibliotekkallet, eller (b) løft gaten inn i biblioteket via
|
||||||
|
operatør-køen. Valget er IKKE tatt — det hører til D-B.
|
||||||
- **Minimal wiring:** ingest har intet modell-steg, så bookend-formen kollapser til
|
- **Minimal wiring:** ingest har intet modell-steg, så bookend-formen kollapser til
|
||||||
sanitér+scan over den hentede ekstraksjons-kroppen:
|
sanitér+scan over den hentede ekstraksjons-kroppen:
|
||||||
`prepared = prepare_input(fetched_body)` → deterministisk render →
|
`prepared = prepare_input(fetched_body)` → deterministisk render →
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ dependencies = [
|
||||||
|
|
||||||
# Distribution channel (2026-07-16 decision, mirrors the library's B2 answer):
|
# Distribution channel (2026-07-16 decision, mirrors the library's B2 answer):
|
||||||
# git pin against the public Forgejo repo — reproducible for every consumer of
|
# git pin against the public Forgejo repo — reproducible for every consumer of
|
||||||
# this public repo, uv.lock pins the exact commit. Bump the rev to the release
|
# this public repo, uv.lock pins the exact commit behind the tag. Bump the rev
|
||||||
# tag once the library tags one.
|
# when the library releases a new tag.
|
||||||
[tool.uv.sources]
|
[tool.uv.sources]
|
||||||
llm-ingestion-okf = { git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git", rev = "dae0bd1a2898b69f436a877538d67afd71e48ad8" }
|
llm-ingestion-okf = { git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git", rev = "v0.3.1" }
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = [
|
dev = [
|
||||||
|
|
@ -38,11 +38,5 @@ target-version = "py310"
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
strict = true
|
strict = true
|
||||||
|
|
||||||
# llm-ingestion-okf ships full inline type hints but (as of 0.1.0 @ dae0bd1a)
|
|
||||||
# no py.typed marker; follow its inline types instead of degrading to Any.
|
|
||||||
[[tool.mypy.overrides]]
|
|
||||||
module = "llm_ingestion_okf.*"
|
|
||||||
follow_untyped_imports = true
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
testpaths = ["tests"]
|
testpaths = ["tests"]
|
||||||
|
|
|
||||||
|
|
@ -113,16 +113,18 @@ class TestSecurityFrame:
|
||||||
manifest = _valid()
|
manifest = _valid()
|
||||||
manifest["extractions"][0]["max_rows"] = 1
|
manifest["extractions"][0]["max_rows"] = 1
|
||||||
case = _write_case(tmp_path, manifest, {"e.csv": "col\n1\n2\n"}) # 2 data rows > 1
|
case = _write_case(tmp_path, manifest, {"e.csv": "col\n1\n2\n"}) # 2 data rows > 1
|
||||||
with pytest.raises(SourceError, match="max_rows"):
|
with pytest.raises(SourceError) as exc:
|
||||||
materialize(case / "manifest.json", tmp_path / "bundle", INGESTED_AT)
|
materialize(case / "manifest.json", tmp_path / "bundle", INGESTED_AT)
|
||||||
|
assert exc.value.code == "max_rows_exceeded"
|
||||||
|
|
||||||
def test_query_escaping_root_is_refused(self, tmp_path: Path) -> None:
|
def test_query_escaping_root_is_refused(self, tmp_path: Path) -> None:
|
||||||
manifest = _valid()
|
manifest = _valid()
|
||||||
manifest["extractions"][0]["query"] = "../secret.csv"
|
manifest["extractions"][0]["query"] = "../secret.csv"
|
||||||
case = _write_case(tmp_path, manifest, {"e.csv": "col\n1\n"})
|
case = _write_case(tmp_path, manifest, {"e.csv": "col\n1\n"})
|
||||||
(case / "secret.csv").write_text("col\nx\n", encoding="utf-8")
|
(case / "secret.csv").write_text("col\nx\n", encoding="utf-8")
|
||||||
with pytest.raises(SourceError, match="escapes"):
|
with pytest.raises(SourceError) as exc:
|
||||||
materialize(case / "manifest.json", tmp_path / "bundle", INGESTED_AT)
|
materialize(case / "manifest.json", tmp_path / "bundle", INGESTED_AT)
|
||||||
|
assert exc.value.code == "path_escape"
|
||||||
|
|
||||||
def test_collision_with_non_ingest_file_fails(self, tmp_path: Path) -> None:
|
def test_collision_with_non_ingest_file_fails(self, tmp_path: Path) -> None:
|
||||||
case = _write_case(tmp_path, _valid(), {"e.csv": "col\n1\n"})
|
case = _write_case(tmp_path, _valid(), {"e.csv": "col\n1\n"})
|
||||||
|
|
@ -132,7 +134,8 @@ class TestSecurityFrame:
|
||||||
(bundle / "ingest-e.md").write_text(
|
(bundle / "ingest-e.md").write_text(
|
||||||
"---\ntype: reference\ntitle: hand\n---\n\nCurated.\n", encoding="utf-8"
|
"---\ntype: reference\ntitle: hand\n---\n\nCurated.\n", encoding="utf-8"
|
||||||
)
|
)
|
||||||
with pytest.raises(MaterializationError, match="collides"):
|
with pytest.raises(MaterializationError) as exc:
|
||||||
materialize(case / "manifest.json", bundle, INGESTED_AT)
|
materialize(case / "manifest.json", bundle, INGESTED_AT)
|
||||||
|
assert exc.value.code == "collision_unstamped"
|
||||||
# The curated file is untouched — never overwritten.
|
# The curated file is untouched — never overwritten.
|
||||||
assert "Curated." in (bundle / "ingest-e.md").read_text(encoding="utf-8")
|
assert "Curated." in (bundle / "ingest-e.md").read_text(encoding="utf-8")
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,9 @@ class TestDelegation:
|
||||||
) -> llm_ingestion_okf.IngestResult:
|
) -> llm_ingestion_okf.IngestResult:
|
||||||
calls["args"] = (manifest_path, bundle_dir, ingested_at)
|
calls["args"] = (manifest_path, bundle_dir, ingested_at)
|
||||||
calls["kwargs"] = kwargs
|
calls["kwargs"] = kwargs
|
||||||
return llm_ingestion_okf.IngestResult(written=(tmp_path / "ingest-e.md",))
|
return llm_ingestion_okf.IngestResult(
|
||||||
|
written=(tmp_path / "ingest-e.md",), stamp="e@0123456789abcdef"
|
||||||
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(ingest, "materialize_bundle", fake)
|
monkeypatch.setattr(ingest, "materialize_bundle", fake)
|
||||||
out = ingest.materialize(tmp_path / "manifest.json", tmp_path / "bundle", INGESTED_AT)
|
out = ingest.materialize(tmp_path / "manifest.json", tmp_path / "bundle", INGESTED_AT)
|
||||||
|
|
@ -153,6 +155,7 @@ class TestLibraryGuarantees:
|
||||||
manifest_path = tmp_path / "manifest.json"
|
manifest_path = tmp_path / "manifest.json"
|
||||||
manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
|
manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
|
||||||
bundle = tmp_path / "bundle"
|
bundle = tmp_path / "bundle"
|
||||||
with pytest.raises(ingest.SourceError, match="returned no columns"):
|
with pytest.raises(ingest.SourceError) as exc:
|
||||||
ingest.materialize(manifest_path, bundle, INGESTED_AT)
|
ingest.materialize(manifest_path, bundle, INGESTED_AT)
|
||||||
|
assert exc.value.code == "sql_no_columns"
|
||||||
assert not bundle.exists()
|
assert not bundle.exists()
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,9 @@ class TestTypedCellFailFast:
|
||||||
db = _db(tmp_path, [(1, 1.0, "x", b"\x00\x01")])
|
db = _db(tmp_path, [(1, 1.0, "x", b"\x00\x01")])
|
||||||
manifest_path = _write_manifest(tmp_path, _sql_manifest("SELECT d FROM t"))
|
manifest_path = _write_manifest(tmp_path, _sql_manifest("SELECT d FROM t"))
|
||||||
monkeypatch.setenv("SRC_DSN", str(db))
|
monkeypatch.setenv("SRC_DSN", str(db))
|
||||||
with pytest.raises(RenderError, match="unsupported SQL cell type"):
|
with pytest.raises(RenderError) as exc:
|
||||||
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
||||||
|
assert exc.value.code == "unsupported_cell_type"
|
||||||
|
|
||||||
|
|
||||||
class TestConnectorRuntime:
|
class TestConnectorRuntime:
|
||||||
|
|
@ -97,8 +98,9 @@ class TestConnectorRuntime:
|
||||||
) -> None:
|
) -> None:
|
||||||
monkeypatch.delenv("SRC_DSN", raising=False)
|
monkeypatch.delenv("SRC_DSN", raising=False)
|
||||||
manifest_path = _write_manifest(tmp_path, _sql_manifest())
|
manifest_path = _write_manifest(tmp_path, _sql_manifest())
|
||||||
with pytest.raises(SourceError, match="not set in the environment"):
|
with pytest.raises(SourceError) as exc:
|
||||||
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
||||||
|
assert exc.value.code == "connection_ref_unset"
|
||||||
|
|
||||||
def test_max_rows_cap_enforced_fail_fast(
|
def test_max_rows_cap_enforced_fail_fast(
|
||||||
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||||
|
|
@ -108,8 +110,9 @@ class TestConnectorRuntime:
|
||||||
manifest["extractions"][0]["max_rows"] = 1 # 2 rows > 1
|
manifest["extractions"][0]["max_rows"] = 1 # 2 rows > 1
|
||||||
manifest_path = _write_manifest(tmp_path, manifest)
|
manifest_path = _write_manifest(tmp_path, manifest)
|
||||||
monkeypatch.setenv("SRC_DSN", str(db))
|
monkeypatch.setenv("SRC_DSN", str(db))
|
||||||
with pytest.raises(SourceError, match="max_rows"):
|
with pytest.raises(SourceError) as exc:
|
||||||
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
||||||
|
assert exc.value.code == "max_rows_exceeded"
|
||||||
|
|
||||||
def test_connection_is_read_only(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
def test_connection_is_read_only(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
db = _db(tmp_path, [(1, 1.0, "x", None)])
|
db = _db(tmp_path, [(1, 1.0, "x", None)])
|
||||||
|
|
@ -117,5 +120,13 @@ class TestConnectorRuntime:
|
||||||
# database and surfaces as a typed SourceError.
|
# database and surfaces as a typed SourceError.
|
||||||
manifest_path = _write_manifest(tmp_path, _sql_manifest("UPDATE t SET a = 9"))
|
manifest_path = _write_manifest(tmp_path, _sql_manifest("UPDATE t SET a = 9"))
|
||||||
monkeypatch.setenv("SRC_DSN", str(db))
|
monkeypatch.setenv("SRC_DSN", str(db))
|
||||||
with pytest.raises(SourceError, match="readonly"):
|
with pytest.raises(SourceError) as exc:
|
||||||
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
materialize(manifest_path, tmp_path / "bundle", INGESTED_AT)
|
||||||
|
# `sql_failed` is the generic statement-failure code; read-onlyness is proven by
|
||||||
|
# the effect, not the message (message text is unstable from library v0.3.0).
|
||||||
|
assert exc.value.code == "sql_failed"
|
||||||
|
con = sqlite3.connect(db)
|
||||||
|
try:
|
||||||
|
assert con.execute("SELECT a FROM t").fetchall() == [(1,)] # write never landed
|
||||||
|
finally:
|
||||||
|
con.close()
|
||||||
|
|
|
||||||
6
uv.lock
generated
6
uv.lock
generated
|
|
@ -465,8 +465,8 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "llm-ingestion-okf"
|
name = "llm-ingestion-okf"
|
||||||
version = "0.1.0"
|
version = "0.3.1"
|
||||||
source = { git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git?rev=dae0bd1a2898b69f436a877538d67afd71e48ad8#dae0bd1a2898b69f436a877538d67afd71e48ad8" }
|
source = { git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git?rev=v0.3.1#692f2df2ba5aa160810b126dab3574cd297218b9" }
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mcp"
|
name = "mcp"
|
||||||
|
|
@ -608,7 +608,7 @@ dev = [
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [
|
requires-dist = [
|
||||||
{ name = "claude-agent-sdk", specifier = ">=0.2.111,<0.3" },
|
{ name = "claude-agent-sdk", specifier = ">=0.2.111,<0.3" },
|
||||||
{ name = "llm-ingestion-okf", git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git?rev=dae0bd1a2898b69f436a877538d67afd71e48ad8" },
|
{ name = "llm-ingestion-okf", git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git?rev=v0.3.1" },
|
||||||
{ name = "pydantic", specifier = ">=2" },
|
{ name = "pydantic", specifier = ">=2" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue