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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ code.

## Package releases

### 0.8.6 - 2026-11-19

`spacevalue build` now writes `<table>.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
Expand Down
5 changes: 4 additions & 1 deletion CITATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<table>.manifest.json` gives
the package version, data contract, quote snapshot and source commit to cite
instead (General_Research rc-776).
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.5"
__version__ = "0.8.6"

# Each public name, and the submodule that defines it.
_LAZY = {name: "catalog" for name in (
Expand Down
39 changes: 37 additions & 2 deletions spacevalue/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import argparse
import dataclasses
import json
import os
import sys

Expand All @@ -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 `<table>.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",
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/test_quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading