Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spacevalue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
9 changes: 9 additions & 0 deletions spacevalue/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions tests/test_quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading