Skip to content

feat(common): ESPI FB-scope parser + Function Block catalog (#122 PR A)#136

Merged
dfcoffin merged 1 commit into
mainfrom
feature/issue-122-grant-subscription-wiring
May 28, 2026
Merged

feat(common): ESPI FB-scope parser + Function Block catalog (#122 PR A)#136
dfcoffin merged 1 commit into
mainfrom
feature/issue-122-grant-subscription-wiring

Conversation

@dfcoffin
Copy link
Copy Markdown
Contributor

PR A — ESPI FB-scope parser + Function Block catalog

Foundation PR for the #122 grant→subscription wiring. Adds the shared value object and authoritative Function Block catalog that every downstream PR (B–F) consumes. No behavior change to existing code — purely additive in openespi-common.

What's here

New package org.greenbuttonalliance.espi.common.scope:

  • FunctionBlock — authoritative in-code catalog of NAESB ESPI 4.0 §REQ.21.4.2.1.3.1 ScopeFBTerms. Each constant carries id, FunctionBlockCategory, optional ServiceKind, and the spec title. Static byId / categoryOf / serviceKindOf lookups tolerate uncatalogued ids. Only active FBs are enumerated; DEPRECATED_IDS records spec-deprecated ids so they resolve to DEPRECATED rather than UNKNOWN.
  • FunctionBlockCategoryBASE / COMMODITY / ENERGY_DATA_SHAPE / CUSTOMER_PII (the load-bearing four that drive resolution + enforcement) plus INTERACTION / BULK_TRANSFER / AUTHORIZATION / ADMINISTRATION / PLATFORM / DEPRECATED / UNKNOWN.
  • EspiScope — FB-agnostic immutable record parser for the FB=4_5_15;IntervalDuration=3600;BlockDuration=monthly;HistoryLength=13 grammar. Carries any FB id (future/deprecated/unknown) without error and derives commodityServiceKinds(), functionBlocksIn(category), includesCustomerPii(), includesEnergyData().

Spec accuracy (GBA-confirmed table, May 2026)

  • FB_71 does not exist — the table ends at FB_70; customer/PII = 54–62. (Corrects a prior assumption.)
  • FB_56/57 retitled (Retail Customer Billing Information / AccountAgreement Information).
  • SFTP bulk FB_34 & FB_66 are deprecated; only REST bulk (35, 67) remain active.
  • FB_29 (Temperature) is COMMODITY with no ServiceKind — the ESPI XSD ServiceKind enumeration has no temperature value (documented standard gap).
  • FB_36 is deprecated but still wired as SCOPE_FB_36_* in DataCustodian SecurityConfiguration — flagged for the enforcement PR (F) to fix.

Design notes

Tests

50 unit tests (EspiScopeTest, FunctionBlockTest), all green — including catalog guard tests (id uniqueness/range, deprecated-vs-active disjointness, commodity→ServiceKind mapping with the FB_29 exception) and parser robustness (case-insensitive keys, whitespace/stray-segment tolerance, null/blank + non-integer rejection, immutability).

Refs #122.

🤖 Generated with Claude Code

Foundation for grant→subscription resolution and resource-server enforcement.
New package org.greenbuttonalliance.espi.common.scope:

- FunctionBlock: authoritative catalog of NAESB ESPI 4.0 §REQ.21.4.2.1.3.1
  ScopeFBTerms (id, category, optional ServiceKind, spec title) with
  tolerant byId/categoryOf/serviceKindOf lookups. Only active FBs are
  enumerated; DEPRECATED_IDS records spec-deprecated ids so they resolve to
  DEPRECATED rather than UNKNOWN.
- FunctionBlockCategory: BASE / COMMODITY / ENERGY_DATA_SHAPE / CUSTOMER_PII
  (load-bearing) + INTERACTION / BULK_TRANSFER / AUTHORIZATION /
  ADMINISTRATION / PLATFORM / DEPRECATED / UNKNOWN.
- EspiScope: FB-agnostic record parser for the FB=…;IntervalDuration=…;
  BlockDuration=…;HistoryLength=… grammar, deriving commodityServiceKinds(),
  functionBlocksIn(category), includesCustomerPii(), includesEnergyData().

Spec accuracy (per GBA-confirmed table): FB_71 does not exist (customer/PII
= 54–62); FB_56/57 retitled; SFTP bulk FB_34/FB_66 deprecated (REST 35/67
remain); FB_29 Temperature is COMMODITY with no ServiceKind (XSD gap).

The parser carries any FB id (future/deprecated/unknown) without error; the
catalog is consulted only for semantics. openespi-authserver stays scope-opaque
and keeps no dependency on this package — FB semantics live solely in the DC.

50 unit tests (EspiScopeTest, FunctionBlockTest), all green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dfcoffin dfcoffin merged commit 2662b48 into main May 28, 2026
4 checks passed
@dfcoffin dfcoffin deleted the feature/issue-122-grant-subscription-wiring branch May 28, 2026 04:04
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