portfolio-optimiser/examples/ingest-golden-http/build_fixture.py
Kjell Tore Guttormsen 392f8493da chore(repo): planning artifacts become local-only; fixture builders become code
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
2026-08-05 10:08:17 +02:00

36 lines
1.6 KiB
Python

"""Build the I6 http golden fixture: examples/ingest-golden-http/{fixture/status, fixture/report,
ingested-at.txt}.
Regenerable throwaway (mirrors the I4 sql builder). The http golden does NOT commit a live
response — the fixture files ARE the canned payloads a mock ``get`` returns (no socket, no
credentials: ``credential_ref`` is null). Payloads are authored as RAW bytes so the verbatim
backslashes in ``c:\\temp\\cache`` and ``backslash \\`` survive exactly: a normal Python string
literal would turn ``\\t`` into a TAB and ``\\c`` into a literal backslash-c, silently corrupting
the fenced-not-escaped discriminator the golden test depends on. LF-only, so the golden is
platform-stable.
"""
from __future__ import annotations
from pathlib import Path
GOLDEN = Path(__file__).resolve().parents[3] / "examples" / "ingest-golden-http"
def main() -> None:
fixture = GOLDEN / "fixture"
fixture.mkdir(parents=True, exist_ok=True)
# 1 line; a raw | and \ discriminate fenced-verbatim rendering from table-escaping.
status = rb'{"service": "billing", "state": "degraded | partial", "path": "c:\temp\cache"}'
(fixture / "status").write_bytes(status + b"\n")
# 3 lines (<= max_rows); pipe + backslash kept verbatim inside the fence.
report = (
b"baseline ok\n" + rb"pipe | and backslash \ kept verbatim" + b"\n" + b"end of report\n"
)
(fixture / "report").write_bytes(report)
(GOLDEN / "ingested-at.txt").write_bytes(b"2026-07-04T12:00:00Z\n")
print(f"built {fixture}/status, {fixture}/report + ingested-at.txt")
if __name__ == "__main__":
main()