BecknTimeSeries v1.0: mandatory descriptors + @type rename#288
Merged
Conversation
…eSeries, normalize JSON-LD namespaces - payloadDescriptors is now required (minItems: 1) on BecknTimeSeries. payloadType stays open at this layer; consumer profiles close it and encode cross-field type-coverage as needed. - @type discriminator: BecknTimeSeries -> TimeSeries. Schema name and folder path stay BecknTimeSeries (versioned URL); only the JSON-LD payload value changes. - JSON-LD namespaces: * deg: https://schema.beckn.io/deg/ (broad, unversioned class IRIs) * dfp: https://schema.beckn.io/deg/DemandFlexPerformance/v2.0/ (versioned, schema-self property IRIs) Class IRI for the time-series envelope is deg:BecknTimeSeries (resolves to https://schema.beckn.io/deg/BecknTimeSeries) — a stable, unversioned reference that DemandFlexPerformance and any future consumer can point at without baking in v1.0. - Cross-field check ("every type used in intervals[].payloads[].type appears in payloadDescriptors[].payloadType") added to demand_flex_revenue.rego. Lives in the policy layer until kin-openapi upgrades to v0.136.0+ and a profile-level if/then/else block can carry it schema-side. - README rewritten: open-enum design, OpenADR sign-by-name convention (USAGE/INJECTION, UP_/DOWN_REGULATION_CAPACITY), pointer to consumer profiles for closure. - demand-flex examples now include payloadDescriptors and @type=TimeSeries; postman collections regenerated from updated examples. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three coordinated changes to
BecknTimeSeries v1.0and its only current consumer (DemandFlexPerformance v2.0):payloadDescriptorsis now required on everyBecknTimeSeriespayload (was optional).intervals[*].payloads[*].typemust be declared inpayloadDescriptors[*].payloadType— added to the policy layer (Rego). It belongs schema-side too, but kin-openapi <0.136.0 silently drops the JSON Schema 2020-12 keywords needed to express it; this PR keeps the schema portable and lets Rego do the enforcement until the validator catches up. See kin-openapi PR #1125 for the upgrade path.deg:namespace; property IRIs stay versioned per-schema.Why
payloadDescriptorswere optional before, which made the embedded units / currency / reading-type sidecar easy to forget — and impossible to validate against. Making them required closes that gap.The cross-field check ("descriptors cover every interval type") is the natural follow-on. It cannot be expressed in JSON Schema 2020-12 without enumerating every legal
payloadType, and we deliberately keep that set open at the BecknTimeSeries layer (OpenADR's convention). So the check lives in Rego today; when kin-openapi 0.136.0+ ships, a consumer profile (e.g.DemandFlexPerformance) that closes its own enum can move the check schema-side.The JSON-LD cleanup is incidental but worth doing now — the
bts:prefix was self-referential and prevented other schemas from cleanly referring to the BecknTimeSeries class.What changed
Schema —
specification/schema/BecknTimeSeries/v1.0/payloadDescriptorsminItems: 1@typeenum["BecknTimeSeries"]["TimeSeries"]payloadTypesetThe schema name in
components.schemasand the folder path stayBecknTimeSeries(versioned URLs are stable). Only the JSON-LD@typevalue used in payloads changes.JSON-LD — namespace convention
DEG had a split convention across schemas. This PR picks one and applies it to the two schemas that move:
Resulting class IRIs:
deg:BecknTimeSeries→https://schema.beckn.io/deg/BecknTimeSeriesdeg:DemandFlexPerformance→https://schema.beckn.io/deg/DemandFlexPerformanceOther DEG schemas already on this convention (e.g.
EnergyBillingSummaryCredential,EnergyMeterDataGB) needed no change. v2.0 schemas still using the old per-schemadeg:self-namespace can migrate incrementally.Policy —
specification/policies/demand_flex_revenue.regoNew violation rule:
Examples —
devkits/demand-flex/uc1-bdr-w-baselining/on-status-response-baselines.jsongainedpayloadDescriptors(was missing them; now required)on-status-response-{actuals,settled}.jsonalready had descriptors; only@typeupdatedSign convention (documented in README)
DEG follows OpenADR's "direction in the type name, magnitude positive" pattern —
USAGEvsINJECTION,UP_REGULATION_CAPACITYvsDOWN_REGULATION_CAPACITY— rather than signed scalars. Reserved forDELTA_*types only. Future PayloadType additions should follow this convention.Test plan
opa test specification/policies/demand_flex_revenue.rego specification/policies/demand_flex_revenue_test.rego— 8/8 passpython3 devkits/demand-flex/scripts/generate_postman_collection.py --role BPP— clean regenpython3 devkits/demand-flex/scripts/generate_postman_collection.py --role BAP— clean regen./devkits/demand-flex/uc1-bdr-w-baselining/workflows/run-arazzo.shagainst the running stack — will pass once merged tomain, because the BPP fetches schemas fromraw.githubusercontent.com/.../refs/heads/main/...at runtime. The three telemetry-bearing on-status steps NACK on the feature branch for that reason; non-telemetry steps (11/12) passed pre-merge.Migration notes for downstream consumers
@type: "BecknTimeSeries"must update to@type: "TimeSeries". (The field is optional, so consumers that omit it are unaffected.)payloadDescriptorsnow fails schema validation. Previously-shipped examples that did not include them need to be updated.🤖 Generated with Claude Code