Operator ruling 2026-08-05, which settles decision (g): planning documents are generally never public, and what OUR OWN sessions generate does not go out on the forge at all. The example itself stays public so others can run the process. `.claude/projects/` is the Voyage session workbench -- 25 briefs/plans/reviews this project's own sessions produced. Untracked and gitignored, exactly as STATE.md already is, and for the same stated reason: this repo has a public mirror, so that class of material is local-only rather than tracked. The line is drawn at who wrote the document, and it is drawn deliberately: `docs/plan/`, `docs/research/` and `docs/rapport/` stay tracked. Those are curated, dated documents written for the repo's readers, three of them linked from the README as the decision record. Move that line if it was meant wider. Two files were NOT process artifacts and are not deleted. Both `build_fixture.py` scripts are cited by tracked tests (`test_ingest_golden_sql.py`, `test_ingest_golden_http.py`) as the documented rebuild path for byte-exact goldens -- reproduction code that had landed in the wrong directory. Moved next to the goldens they build; both docstrings updated, so no tracked file is left pointing into an untracked tree (verified: the only remaining `.claude/projects` string in a tracked file is the .gitignore rule itself). One prose reference in the dated Foundry auth recipe was dropped for the same reason. 652 tests still pass. Does NOT address the 27 of these already readable on open/ since the S12 release -- untracking stops future publication only. That retraction is a separate operator decision and is deliberately not taken here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GWsexbQjPo9rsV3aUE54ZS
47 lines
2 KiB
Python
47 lines
2 KiB
Python
"""I4 golden regression — the §11 golden extraction case for `sql`, byte-for-byte.
|
|
|
|
Mirrors tests/test_ingest_golden.py for the second source type. The case pins the §5 SQL type
|
|
rules AS RULES: SQL NULL → empty cell (never ``None``), REAL 4200.0 → ``4200.0`` (float form
|
|
preserved, not integer-coerced), non-integral 1200.5/89.9, and the escape order on the sql path
|
|
(``|`` → ``\\|``, ``\\`` → ``\\\\``). RED when ANY byte of the expected bundle diverges (spec
|
|
§11 "Golden regression" seam).
|
|
|
|
The fixture db is committed under ``fixture/`` (rebuild:
|
|
``examples/ingest-golden-sql/build_fixture.py``); the ``connection_ref`` env
|
|
var is set to it (the §4 run-time resolution). The db PATH never enters the bundle, so the
|
|
golden is checkout-location independent.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from portfolio_optimiser.ingest import materialize
|
|
|
|
GOLDEN = Path(__file__).resolve().parents[1] / "examples" / "ingest-golden-sql"
|
|
|
|
|
|
def _bundle_bytes(directory: Path) -> dict[str, bytes]:
|
|
return {p.name: p.read_bytes() for p in sorted(directory.iterdir()) if p.is_file()}
|
|
|
|
|
|
def test_golden_sql_extraction_is_bit_deterministic(
|
|
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
) -> None:
|
|
ingested_at = (GOLDEN / "ingested-at.txt").read_text(encoding="utf-8").strip()
|
|
monkeypatch.setenv("PORTEFOLJE_SQL_DSN", str(GOLDEN / "fixture" / "portefolje.sqlite"))
|
|
out = tmp_path / "bundle"
|
|
materialize(GOLDEN / "manifest.json", out, ingested_at=ingested_at)
|
|
|
|
expected = _bundle_bytes(GOLDEN / "expected-bundle")
|
|
actual = _bundle_bytes(out)
|
|
# File-SET equality first — catches extra AND missing files, not just diverging bytes.
|
|
assert actual.keys() == expected.keys()
|
|
for name, content in expected.items():
|
|
assert actual[name] == content, f"golden byte divergence in {name}"
|
|
|
|
# §10: a second run over the same output leaves every byte unchanged.
|
|
materialize(GOLDEN / "manifest.json", out, ingested_at=ingested_at)
|
|
assert _bundle_bytes(out) == expected
|