feat(ingest): I3 — D7-speil av ingest (filkatalog/CSV), bygget fra commons-spec alene
Speiler MAF I2 fra shared/ingest-spec.md alene: manifest → CSV-konnektor → materialisert OKF-bundle, byte-identisk med den delte golden-fasiten. - ingest.py: ManifestContract (pydantic, fail-fast, file-kilde, verdict-reservasjon §3, id-grammatikk, max_rows), CSV-konnektor (boundary-checked fail-closed), materialisering (§5-frontmatter eksakt rekkefølge, markdown-tabell m/ escaping, LF-only, SHA-256 manifest-stamp), index-generering (§6), replacement §3/§5. - okf.py: _parse_index_entry — tolererer frontmatterløs index (method-spec §3: index rendres via body = summary, ikke som typet concept-fil). Golden var spec-konform; D7-okf var strengere enn standarden. Scoped: non-index concept- filer krever fortsatt type (honesty-test). - examples/ingest-golden-file/: repo-lokal golden (byte-frossen kopi av I2s fasit). - Speiltester (I2s load-bearing-sett, alle detach-bevist røde): golden byte-fasit + mutasjonskontroller · provenance/navigability/verdict-reservasjon/re-ingest-safety · kontrakt fail-fast/max_rows/boundary/kollisjon · spec-integritet §11. - docs/2026-07-04-I3-brief.md: brief + de to operatør-avgjorte beslutningene. Suite 239 passed uten nøkkel/nettverk (189 + 50 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 nå, SQL/HTTP senere). Endringen er dokumentert i docs/2026-07-04-I3-brief.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MM6BWb1hWmJZuXFZ7rjxT
This commit is contained in:
parent
dc2345e134
commit
e03bd79876
15 changed files with 958 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ from dataclasses import dataclass
|
|||
from pathlib import Path
|
||||
|
||||
_INDEX_FILENAME = "index.md"
|
||||
_INDEX_TYPE = "index"
|
||||
_VERDICT_TYPE = "verdict"
|
||||
# (reference) the intra-bundle cross-link pattern, per §3 Step 1.
|
||||
_CROSSLINK_PATTERN = re.compile(r"\]\(([^)]+\.md)\)")
|
||||
|
|
@ -70,19 +71,40 @@ def parse_concept_file(path: Path) -> ConceptFile:
|
|||
)
|
||||
|
||||
|
||||
def _parse_index_entry(index_path: Path) -> ConceptFile:
|
||||
"""Parse the bundle entry point, tolerating a frontmatter-less index (§3 Step 1).
|
||||
|
||||
method-spec §3 Step 1 renders the index as "the index body (the summary)" and
|
||||
treats every OTHER file as a "non-index concept file" (`## {type}: {title}`
|
||||
section) — so the index is NOT a concept file, and it MAY omit frontmatter: a
|
||||
generated index carrying only ``bundle_summary`` + cross-links (ingest spec §6,
|
||||
frozen in the ingest golden) is valid. A frontmatter-ful index (the curated
|
||||
convention, ``type: index``) still parses normally, its extra fields preserved.
|
||||
When frontmatter is absent, the whole file is the body and ``type`` defaults to
|
||||
``index`` so downstream ``.type`` reads never raise.
|
||||
"""
|
||||
text = index_path.read_text(encoding="utf-8")
|
||||
lines = text.splitlines()
|
||||
if lines and lines[0].strip() == "---":
|
||||
return parse_concept_file(index_path)
|
||||
return ConceptFile(path=index_path, frontmatter={"type": _INDEX_TYPE}, body=text.strip())
|
||||
|
||||
|
||||
def navigate_bundle(bundle_dir: Path) -> list[ConceptFile]:
|
||||
"""Navigate from ``index.md`` — deterministic order: index first, links first-seen.
|
||||
|
||||
Targets containing a path separator are out-of-bundle and skipped; resolution is
|
||||
boundary-checked against the bundle directory (fail-closed); broken links are
|
||||
skipped, never raised. Repeated links are de-duplicated.
|
||||
skipped, never raised. Repeated links are de-duplicated. The index entry point
|
||||
may omit frontmatter (``_parse_index_entry``); non-index concept files still
|
||||
require ``type``.
|
||||
"""
|
||||
index_path = bundle_dir / _INDEX_FILENAME
|
||||
if not index_path.is_file():
|
||||
raise FileNotFoundError(
|
||||
f"bundle has no entry point: missing {_INDEX_FILENAME} in {bundle_dir}"
|
||||
)
|
||||
index = parse_concept_file(index_path)
|
||||
index = _parse_index_entry(index_path)
|
||||
bundle_root = bundle_dir.resolve()
|
||||
concepts = [index]
|
||||
seen = {_INDEX_FILENAME}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue