feat(api): expose the §5 provenance stamp on IngestResult
The stamp ({stem}@{sha256(raw)[:16]}) was computed internally but only
written into frontmatter, forcing consumers to recompute it from the
manifest bytes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
9ec25d27d0
commit
d3a3bccfbb
2 changed files with 14 additions and 2 deletions
|
|
@ -42,9 +42,11 @@ _MANAGED_LINE_RE = re.compile(r"^- \[(?P<label>[^\]]*)\]\((?P<target>[^)]+)\)$")
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class IngestResult:
|
class IngestResult:
|
||||||
"""The concept files written by one materialization run."""
|
"""The concept files written by one materialization run, and the §5
|
||||||
|
provenance stamp (`{stem}@{sha256(raw)[:16]}`) they were stamped with."""
|
||||||
|
|
||||||
written: tuple[Path, ...]
|
written: tuple[Path, ...]
|
||||||
|
stamp: str
|
||||||
|
|
||||||
|
|
||||||
def _render_frontmatter(frontmatter: dict[str, str]) -> str:
|
def _render_frontmatter(frontmatter: dict[str, str]) -> str:
|
||||||
|
|
@ -268,4 +270,4 @@ def materialize_bundle(
|
||||||
_update_index_lines(index_path, owned - staged_names, labels_by_target)
|
_update_index_lines(index_path, owned - staged_names, labels_by_target)
|
||||||
for extraction in manifest.extractions:
|
for extraction in manifest.extractions:
|
||||||
_link_in_index(bundle, generated_filename(extraction.id), extraction.title)
|
_link_in_index(bundle, generated_filename(extraction.id), extraction.title)
|
||||||
return IngestResult(written=written)
|
return IngestResult(written=written, stamp=stamp)
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,16 @@ def test_result_lists_written_concept_files(file_setup: tuple[Path, Path]) -> No
|
||||||
assert result.written == (bundle / "ingest-orders.md",)
|
assert result.written == (bundle / "ingest-orders.md",)
|
||||||
|
|
||||||
|
|
||||||
|
def test_result_exposes_manifest_stamp(file_setup: tuple[Path, Path]) -> None:
|
||||||
|
"""The §5 provenance stamp ({stem}@{sha256(raw)[:16]}) is returned on the
|
||||||
|
result so consumers never have to recompute it from the manifest bytes."""
|
||||||
|
manifest_path, bundle = file_setup
|
||||||
|
result = materialize_bundle(manifest_path, bundle, INGESTED_AT)
|
||||||
|
assert result.stamp == stamp_of(manifest_path)
|
||||||
|
content = (bundle / "ingest-orders.md").read_text(encoding="utf-8")
|
||||||
|
assert f"ingest_manifest: {result.stamp}\n" in content
|
||||||
|
|
||||||
|
|
||||||
def test_relative_root_resolves_against_manifest_dir(
|
def test_relative_root_resolves_against_manifest_dir(
|
||||||
tmp_path: Path, file_setup: tuple[Path, Path], monkeypatch: pytest.MonkeyPatch
|
tmp_path: Path, file_setup: tuple[Path, Path], monkeypatch: pytest.MonkeyPatch
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue