Skip to content

feat(schema): structured source tag on processes (schema 0.2.0) - #4

Merged
lbougan merged 1 commit into
mainfrom
feat/source-column
Oct 1, 2026
Merged

lbougan merged 1 commit into
mainfrom
feat/source-column

Conversation

@lbougan

@lbougan lbougan commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Why

Which upstream source supplied a row was recorded only as free text (the sector description and the citation sentence in comment). That is the BAFU ToU citation, not a machine-readable tag: a consumer could not select rows by source, and sentier-brightway concatenated every folder into a database named bafu-2026. That is correct only while the inventory is 100 % BAFU.

Sector-based storage stays (decision of 2026-08-07, no source-named folders or files). This adds per-row provenance so folders can mix sources and consumers can select by it.

What (schema 0.2.0)

  • processes.parquet: source (required, lower-kebab <publisher>-<edition>, e.g. bafu-2026) and source_version (optional, e.g. v1), placed after process_type. Exchanges inherit provenance through process_id, so exchange.yaml only gains a header note.
  • metadata.json: required sources list (pattern-checked, unique, non-empty); schema_version 0.2.0.
  • scripts/validate.py: the distinct processes.source values must equal sources, both directions. This makes metadata.json a trustworthy index, so a consumer can pick folders without opening parquet.
  • data/: all 11 sectors regenerated by sentier-importers (run_bafu_local.py at sentier-importers 732ba80) with source = bafu-2026, source_version = v1. Every pre-existing column and row is unchanged; the exchanges.parquet files are byte-identical to main (same hashes in sentier-brightway's pin file).
  • README and data/README.md: provenance rule rewritten, source-id convention documented.

Verification

$ python scripts/validate.py
OK — 11 sector folder(s) validate against the schema contracts.

With a throwaway folder whose sources says other-1 but whose parquet says bafu-2026, the validator reports both directions:

- 98-throwaway/processes.parquet: source values not declared in metadata.json sources: ['bafu-2026']
- 98-throwaway/metadata.json: sources declared but absent from processes.parquet: ['other-1']

Compatibility

Breaking for a reader that rejects unknown columns or requires the 0.1.0 metadata shape. Known reader: sentier-brightway, pinned by commit and updated in its own feat/source-column branch. Please merge without squash so the pinned commit 2837e1b stays reachable; otherwise the brightway PR re-pins to the squash commit.

Landing order

  1. sentier-dev/sentier-importers feat/source-column (emits the columns)
  2. this PR
  3. sentier-dev/sentier-brightway feat/source-column

Rows were tagged with their upstream dataset only in free text (the ToU
citation in `comment`), so a consumer could not select by source and
sentier-brightway imported the whole inventory as "bafu-2026". This adds:

- processes.parquet: `source` (required, datasource id, edition only,
  e.g. bafu-2026) and `source_version` (optional, e.g. v1), after
  process_type. Exchanges inherit through process_id.
- metadata.json: required `sources` list; schema_version 0.2.0.
- scripts/validate.py: `sources` must equal the distinct processes.source
  values, both directions, so consumers can select folders by metadata
  without opening parquet.
- data/: all 11 sectors regenerated by sentier-importers
  (run_bafu_local.py at 732ba80) with source=bafu-2026, source_version=v1.
  Every pre-existing column and row is unchanged; exchanges.parquet files
  are byte-identical to main.
- README, data/README.md: provenance rule and source-id convention.
@lbougan
lbougan merged commit c5aee15 into main Oct 1, 2026
2 checks passed
@lbougan
lbougan deleted the feat/source-column branch October 1, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant