diff --git a/CHANGELOG.md b/CHANGELOG.md index fdff45a..8c5c07c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -166,6 +166,18 @@ code. ## Package releases +### 0.8.9 - 2026-12-01 + +`spacevalue quotes record` refuses, exit 1, unless the package runs from a +git checkout of itself. It writes into the package's own `quotes/` folder, +which for an installed copy is site-packages: there it fetched the closes, +wrote the snapshot and its SHA256SUMS line, printed "wrote ..." and exited +0, and the file was never committed, though a release is built only from a +committed snapshot. The README says to record in a clone. A dry run of +"publish prices" on main confirmed 0.8.8's provenance step: the manifest +built there names main's head commit, clean. Data contract unchanged at +1.22.1; no value moves. + ### 0.8.8 - 2026-12-01 A manifest's `source_commit` names the commit that built it. Every release diff --git a/README.md b/README.md index 0c7cf74..4fb06a9 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,11 @@ spacevalue quotes record # last finished close of each future spacevalue quotes check # every snapshot against SHA256SUMS ``` +Record in a clone (`pip install -e .`), and commit the new file: `record` +writes into the package's own `quotes/` folder, and refuses to when that +folder is not a git checkout, since a snapshot left in site-packages is never +committed and a release is built only from committed ones. + A snapshot holds the close as the exchange quoted it (per troy ounce, per pound), written so it reads back as the same float. It is never edited: `SHA256SUMS` records each file, and a changed byte fails the check. A newer diff --git a/spacevalue/__init__.py b/spacevalue/__init__.py index 58432ce..84f7097 100644 --- a/spacevalue/__init__.py +++ b/spacevalue/__init__.py @@ -33,7 +33,7 @@ # The PACKAGE release. Not the data contract: that is # `MineralValueConfig.pipeline_version`, stamped into every row. -__version__ = "0.8.8" +__version__ = "0.8.9" # Each public name, and the submodule that defines it. _LAZY = {name: "catalog" for name in ( diff --git a/spacevalue/cli.py b/spacevalue/cli.py index de51683..aa3c6b0 100644 --- a/spacevalue/cli.py +++ b/spacevalue/cli.py @@ -212,6 +212,15 @@ def main(argv=None) -> int: len(_quotes.list_snapshots(_catalog.QUOTES_DIR)), _quotes.SUMS_FILE)) return 1 if bad else 0 + # The snapshot lands in this package's quotes/ folder. For an + # installed copy that is site-packages, where it is never committed, + # and a release is built only from a committed snapshot. + if not _source_state()[0]: + print("FAIL quotes record writes into %s, which is not a git " + "checkout of spacevalue. Run it from a clone (pip install " + "-e .) and commit the new file." % _catalog.QUOTES_DIR, + file=sys.stderr) + return 1 set_verbose(True) path = _quotes.record_snapshot("metals", _catalog.metal_tickers(), _catalog.QUOTES_DIR) diff --git a/tests/test_quotes.py b/tests/test_quotes.py index de5692f..37d9f75 100644 --- a/tests/test_quotes.py +++ b/tests/test_quotes.py @@ -165,3 +165,26 @@ def test_live_that_quotes_passes_the_command(tmp_path, monkeypatch, argv): if argv[0] == "build": argv = argv + ["-o", str(tmp_path)] assert main(argv) == 0 + + +def test_record_refuses_outside_a_checkout(monkeypatch, capsys): + """An installed copy's quotes/ is in site-packages: a snapshot written + there is never committed, and a release is built only from committed ones.""" + from spacevalue import cli + called = [] + monkeypatch.setattr(cli, "_source_state", lambda: ("", None)) + monkeypatch.setattr(cli._quotes, "record_snapshot", + lambda *a, **k: called.append(a) or "x") + assert cli.main(["quotes", "record"]) == 1 + assert called == [], "nothing is fetched or written" + assert "checkout" in capsys.readouterr().err + + +def test_record_runs_in_a_checkout(monkeypatch, capsys): + from spacevalue import cli + called = [] + monkeypatch.setattr(cli, "_source_state", lambda: ("abc", False)) + monkeypatch.setattr(cli._quotes, "record_snapshot", + lambda *a, **k: called.append(a) or "path/metals-x.csv") + assert cli.main(["quotes", "record"]) == 0 + assert len(called) == 1 and "path/metals-x.csv" in capsys.readouterr().out