Skip to content

feat: timeseries schema v2 — published geography and sectorSegment - #974

Merged
jacobvjk merged 5 commits into
epic/v2from
feat/timeseries-v2-schema
Oct 6, 2026
Merged

jacobvjk merged 5 commits into
epic/v2from
feat/timeseries-v2-schema

Conversation

@jacobvjk

@jacobvjk jacobvjk commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #915 (benchmark data v2 schema). First of three stacked PRs: schema → importer → download and plots.

What changes

Two row changes in the new src/schema/pathwayTimeseries.v2.json:

  • geography is the publication's own label, exactly as the pathway's metadata declares it: Global, a region key (e.g. ASEAN, Southeast Asia), or a declared ISO2 country. v1's closed enum couldn't hold those labels, so 7 of 16 files carried a label their metadata didn't declare, and the UI needed spelling folds (Data: IEA pathways spell the same region two ways across metadata and timeseries #945).
  • sectorSegment (required list) names the segments of the row's sector that the value covers. It uses the same vocabulary as data availability, but no sentinels, because a data row always covers a known segment. It replaces the per-metric "sector scope" (removed in the third PR).

Both rules depend on metadata in other files, so the new src/utils/validateTimeseries.ts enforces them from npm run schema:check.

Data

scripts/codemod-timeseries-v1-to-v2.ts migrated all 16 files. Values were checked identical before and after. Per file it changed only:

  • $schema
  • sectorSegment: ["Power generation"] on every row, which is what v1 meant for every Power metric
  • geography, via an explicit per-pathway table:
    • ACE South East Asia → ASEAN
    • IEA-APS/STEPS-2024 South East Asia → Southeast Asia

JRC's three files publish a South East Asia series that their metadata didn't declare. The region is now declared in the JRC metadata.

The member list (ID, MY, TH, VN plus the existing "Rest South East Asia" members, which include MN, KP and TW as JRC defines that region) is confirmed by @jacobvjk.

Checked

  • schema:check passes. On a scratch copy, a wrong label and a foreign segment are both reported.
  • ACE, IEA and JRC detail pages now plot their regional series with no fallback note. Checked locally in Chrome.
  • The generated index changes only by the relabelled geographies.

🤖 Generated with Claude Code

jacobvjk and others added 3 commits October 6, 2026 10:33
…rSegment

Two row changes (#915):

- geography is an open string that must be a label the pathway's
  metadata declares: Global, a region key in the publication's own
  wording, or a declared ISO2 country. v1's closed enum could not hold
  labels such as "ASEAN" or "Southeast Asia", so files carried a label
  their metadata did not declare and the UI needed spelling folds (#945).
- sectorSegment (required) lists the segments of the row's sector the
  value covers, from the dataAvailability vocabulary but without its
  sentinels: a data row always covers a known segment. It replaces the
  per-metric sector scope.

Both rules need the metadata in other files, so validateTimeseries runs
them from schema:check. It shares "declared geography" with the
keyFeatures check by extracting declaredGeographies from
validateScopes, and reports a mistake repeated over many rows once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/codemod-timeseries-v1-to-v2.ts changes three things per file
and nothing else (values verified identical):

- $schema becomes the v2 id
- every row gains sectorSegment ["Power generation"], which is what v1
  meant: the taxonomy gave every Power metric that sector scope, and
  every row is Power
- geography becomes the label the metadata declares, via an explicit
  per-pathway table: ACE "South East Asia" -> "ASEAN", IEA-APS/STEPS
  "South East Asia" -> "Southeast Asia"

JRC's three files publish a "South East Asia" series that their
metadata did not declare. Per Jacob, the region is declared instead
(members: ID, MY, TH, VN plus the "Rest South East Asia" members, to be
confirmed against GECO).

build-timeseries-files.ts accepts v2 files; the index changes only by
the relabelled geographies. ACE, IEA and JRC detail pages now plot
their regional series without a fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Expected version change and release notes

🚨 WARNING: This PR is not expected to trigger a new version

To trigger a version bump, use at least one conventional commit message in this branch. See: https://www.conventionalcommits.org/en/v1.0.0/

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-974.westus2.2.azurestaticapps.net

@jacobvjk

jacobvjk commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

JRC "South East Asia" confirmed by @jacobvjk: the region is declared in the three JRC metadata files with members ID, MY, TH, VN plus JRC's "Rest South East Asia" members (BN, KH, LA, MN, MM, KP, PH, SG, TW), as in this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The v2 schema permits invalid pathway ID lists and contains power technology values that cannot validate.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Introduces timeseries schema v2, aligning row geography and sector segments with pathway metadata.

Changes:

  • Adds v2 schema, types, cross-file validation, and tests.
  • Migrates 16 timeseries datasets and updates geography metadata/indexes.
  • Adds migration tooling, documentation, and v2 build support.
File Description
src/​schema/​pathwayTimeseries.v2.json Defines the v2 schema.
src/​types/​pathwayTimeseries.v2.d.ts Adds generated v2 types.
src/​utils/​validateTimeseries.ts Validates geography and sector segments.
src/​utils/​validateTimeseries.test.ts Tests cross-file validation.
src/​utils/​validateScopes.ts Shares declared-geography logic.
scripts/​schema-check-files.ts Runs v2 cross-file checks.
scripts/​codemod-timeseries-v1-to-v2.ts Migrates v1 datasets.
scripts/​codemod-timeseries-v1-to-v2.test.ts Tests migration behavior.
scripts/​build-timeseries-files.ts Recognizes v2 datasets.
src/​data/​README.md Documents v2 authoring and migration.
src/​data/​index.gen.ts Updates indexed geography labels.
src/​data/​asean-centre-for-energy/​ATS-2024_timeseries.json Migrates ACE ATS data.
src/​data/​asean-centre-for-energy/​BAS-2024_timeseries.json Migrates ACE BAS data.
src/​data/​asean-centre-for-energy/​CNS-2024_timeseries.json Migrates ACE CNS data.
src/​data/​asean-centre-for-energy/​RAS-2024_timeseries.json Migrates ACE RAS data.
src/​data/​iea/​IEA-APS-2024_timeseries.json Migrates IEA APS data.
src/​data/​iea/​IEA-NZE-2024_timeseries.json Migrates IEA NZE data.
src/​data/​iea/​IEA-STEPS-2024_timeseries.json Migrates IEA STEPS data.
src/​data/​jetp-id/​JETP-CIPP-2023_timeseries.json Migrates JETP data.
src/​data/​jrc/​JRC-GECO-1-5-2025.json Declares JRC regional geography.
src/​data/​jrc/​JRC-GECO-NDC-LTS-2025.json Declares JRC regional geography.
src/​data/​jrc/​JRC-GECO-REFERENCE-2025.json Declares JRC regional geography.
src/​data/​jrc/​JRC-GECO-1-5-2025_timeseries.json Migrates JRC 1.5°C data.
src/​data/​jrc/​JRC-GECO-NDC-LTS-2025_timeseries.json Migrates JRC NDC-LTS data.
src/​data/​jrc/​JRC-GECO-REFERENCE-2025_timeseries.json Migrates JRC reference data.
src/​data/​transitionzero/​TZ-BAU-2024_timeseries.json Migrates TransitionZero BAU data.
src/​data/​transitionzero/​TZ-EBAU-2024_timeseries.json Migrates TransitionZero EBAU data.
src/​data/​transitionzero/​TZ-ISG-2024_timeseries.json Migrates TransitionZero ISG data.
src/​data/​transitionzero/​TZ-REGI-2024_timeseries.json Migrates TransitionZero REGI data.
src/​data/​uts-isf/​UTS-ISF-OECM-2024_timeseries.json Migrates UTS-ISF data.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/schema/pathwayTimeseries.v2.json
Comment thread src/schema/pathwayTimeseries.v2.json
An empty list made validateTimeseries' geography check vacuously pass
and left the importer no pathway to place a new file next to; a repeated
id produced duplicate entries in the timeseries index (#974 review).
All 16 current files already comply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Expected version change and release notes

🚨 WARNING: This PR is not expected to trigger a new version

To trigger a version bump, use at least one conventional commit message in this branch. See: https://www.conventionalcommits.org/en/v1.0.0/

jacobvjk added a commit that referenced this pull request Oct 6, 2026
From the #975 review:

- A duplicate dataset id used to skip the file's remaining checks, so a
  second problem in the same file only surfaced on the next run. Every
  check now runs before the file is skipped.
- A new file is named after its id, so an id with "/" or a leading "."
  could write outside the pathway's folder. Such ids are now an error.
- A missing metadata path is an explicit error rather than a fallback
  to a guessed folder (unreachable today: unknown pathway ids are
  rejected, and #974 now requires a non-empty pathwayId).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-974.westus2.2.azurestaticapps.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The migration codemod can emit invalid v2 documents for empty or duplicate pathway ID lists.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Low severity Correct validator caller documentation

src/​utils/​validateTimeseries.ts:7

This comment says the validator runs from scripts/import-benchmark-data.ts, but that script does not exist in this change and the only production caller is scripts/schema-check-files.ts. Remove the future-caller claim so the documented enforcement path matches the current codebase.

Comment thread scripts/codemod-timeseries-v1-to-v2.ts
v1 allowed an empty or repeated pathwayId list; v2 rejects both, and an
empty list would make relabel's "declared by every pathway" check pass
vacuously. The codemod now stops on either instead of writing an
invalid v2 file (#974 review). The 16 migrated files were unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Expected version change and release notes

🚨 WARNING: This PR is not expected to trigger a new version

To trigger a version bump, use at least one conventional commit message in this branch. See: https://www.conventionalcommits.org/en/v1.0.0/

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-974.westus2.2.azurestaticapps.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The schema, validation, migrations, and tests are consistent; the remaining feedback concerns only a stale documentation reference.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Remove nonexistent importer integration claim

src/​utils/​validateTimeseries.ts:7

This module comment says the validator runs from scripts/import-benchmark-data.ts, but that script is not present in this PR and the only non-test caller is scripts/schema-check-files.ts. Remove the nonexistent integration claim until the importer PR adds it.

"technology": {
"description": "Technology represented in this record (e.g., Solar, Wind, or null if sector-level only).",
"type": ["string", "null"],
"enum": [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from Codex:

P2 — pathwayTimeseries.v2.json (line 112): the parent technology enum excludes geothermal, hydrogen, and battery, while the power-specific branch permits them. JSON Schema combines both constraints, so those values are rejected for Power rows. I confirmed this with Ajv using geothermal. Add them to the parent enum (and regenerate types), or remove them from the power branch.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed. This bug predates the PR (v1 has the same lists) and is tracked as #977. It is fixed in #979, which is stacked on this PR so the schema change itself stays reviewable. That fix:

  • makes the Power list exactly the Power technology keys in timeseriesTaxonomy.ts, which the plots and CSV download look every row up in
  • adds geothermal and energyStorage to the parent enum. Storage is energyStorage, per cookbook decision 0020, rather than battery.
  • drops battery and hydrogen. Hydrogen is not a Power technology in the taxonomy.
  • adds a schema test that keeps the two lists in agreement and checks that every Power value is in the parent enum, which is the AJV case you confirmed

No current data uses any of these values, so no data files change. Happy to fold #979 into this PR if you would rather review them together.

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.

3 participants