diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4512e..772f3aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -166,6 +166,14 @@ code. ## Package releases +### 0.8.6 - 2026-11-19 + +`spacevalue build` now writes `.manifest.json` beside the CSV: package +version, data contract, catalog date, destination, quote snapshot (or live), +source commit and the CSV's sha256, with `release_tag` null because a +standalone build is not a release (General_Research rc-776). `release` is +unchanged. Data contract unchanged at 1.22.1; no value moves. + ### 0.8.5 - 2026-11-19 Comments and CITATIONS.md only; data contract unchanged at 1.22.1. The diff --git a/CITATIONS.md b/CITATIONS.md index bc0045b..cdeb778 100644 --- a/CITATIONS.md +++ b/CITATIONS.md @@ -335,4 +335,7 @@ to rc-771). The delta-v rows themselves are spacecost's, cited there. ## Citing this package Cite the release you used, by its tag (`prices-YYYY-MM-DD` for the tables, -`vX.Y.Z` for the code), and the data contract stamped in its rows. +`vX.Y.Z` for the code), and the data contract stamped in its rows. A table +from `spacevalue build` is not a release: its `
.manifest.json` gives +the package version, data contract, quote snapshot and source commit to cite +instead (General_Research rc-776). diff --git a/spacevalue/__init__.py b/spacevalue/__init__.py index afdd5ce..35d0484 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.5" +__version__ = "0.8.6" # 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 30c7f2e..6dc55b8 100644 --- a/spacevalue/cli.py +++ b/spacevalue/cli.py @@ -20,6 +20,7 @@ import argparse import dataclasses +import json import os import sys @@ -28,12 +29,44 @@ from . import __version__ from . import catalog as _catalog -from .release import build_release, check_release +from .release import _sha256, _source_commit, build_release, check_release _PREVIEW = ["name", "kind", "price_usd_per_kg", "price_basis", "value_route", "live_price_source", "annual_market_kg"] +def write_build_manifest(cfg, table) -> str: + """Write `
.manifest.json` beside a standalone build's CSV. + + WHAT TO CITE, TRAVELLING WITH THE TABLE. CITATIONS.md asks for the + package release beside the data contract, and the CSV's rows carry only + the contract (General_Research rc-776). A standalone build is not a + release, so `release_tag` is null and says so; `release` writes the + full manifest.json. Values are untouched: this file only names the build. + """ + out_dir = cfg.resolved_output_dir() + csv_path = os.path.join(out_dir, cfg.catalog_filename) + stem = os.path.splitext(cfg.catalog_filename)[0] + path = os.path.join(out_dir, stem + ".manifest.json") + manifest = { + "release_tag": None, + "release_tag_note": "a standalone build, not a published release", + "package_version": __version__, + "pipeline_version": cfg.pipeline_version, + "catalog_date": str(table["catalog_date"].iloc[0]), + "delivery_destination": cfg.delivery_destination, + "quote_snapshot": cfg.quote_snapshot or None, + "live_quotes": bool(cfg.use_yfinance), + "source_commit": _source_commit() or None, + "file": {"name": cfg.catalog_filename, "rows": int(len(table)), + "sha256": _sha256(csv_path)}, + } + with open(path, "w", encoding="utf-8", newline="\n") as fh: + json.dump(manifest, fh, indent=2) + fh.write("\n") + return path + + def _parser() -> argparse.ArgumentParser: p = argparse.ArgumentParser( prog="spacevalue", @@ -110,7 +143,9 @@ def main(argv=None) -> int: if args.command == "build": set_verbose(not args.quiet) cfg = _config(args, output_dir=args.output_dir) - _catalog.build_mineral_value_catalog(cfg) + table = _catalog.build_mineral_value_catalog(cfg) + if len(table): + write_build_manifest(cfg, table) if args.quiet: print(os.path.join(cfg.resolved_output_dir(), cfg.catalog_filename)) return 0 diff --git a/tests/test_quotes.py b/tests/test_quotes.py index e06cc56..cef574a 100644 --- a/tests/test_quotes.py +++ b/tests/test_quotes.py @@ -100,3 +100,22 @@ def test_the_default_build_needs_no_network(tmp_path, monkeypatch): use_metals_api=False) t = catalog.build_mineral_value_catalog(cfg) assert t["live_price_source"].isna().all() + + +def test_a_standalone_build_names_what_to_cite(tmp_path, monkeypatch): + """`spacevalue build` leaves a manifest beside its CSV (rc-776).""" + import json + import os + import spacevalue + from spacevalue.cli import main + monkeypatch.setitem(sys.modules, "yfinance", None) + assert main(["build", "cislunar", "--quotes", "metals-2026-10-07", + "-o", str(tmp_path), "-q"]) == 0 + names = os.listdir(str(tmp_path)) + man = [n for n in names if n.endswith(".manifest.json")] + assert len(man) == 1, names + m = json.load(open(os.path.join(str(tmp_path), man[0]), encoding="utf-8")) + assert m["package_version"] == spacevalue.__version__ + assert m["release_tag"] is None and m["quote_snapshot"] == "metals-2026-10-07" + assert m["delivery_destination"] == "cislunar" + assert m["file"]["name"] in names and len(m["file"]["sha256"]) == 64