Repository navigation
Description
Problem
_typed_control_totals in the producer builds ReportingControlTotalRecord dataclasses. That class re-declares the schema's name and value patterns and the 32-character unit bound by hand, and serializes with its own to_wire(). The SDK already ships the generated model for the same schema: adcp.types.ReportingControlTotal, with ReportingControlTotal1 (integer) and ReportingControlTotal2 (decimal) carrying the same patterns. The patterns match today. When the schema changes, the generated model picks up the change on the next sync, and the hand-written copy does not.
Evidence
All references are to main at 47084e83a.
-
src/adcp/reporting/ledger/producer.py:243-265:_typed_control_totalsconstructsReportingControlTotalRecord(total.name, total.value, total.value_type, total.unit or units.get(total.name))for each manifest total. -
src/adcp/reporting/evidence.py:196-232:ReportingControlTotalRecord.__post_init__re-declares the patterns:if re.fullmatch(r"[A-Za-z][A-Za-z0-9_.:-]{0,127}", self.name) is None: ... pattern = ( r"-?(?:0|[1-9][0-9]*)" if self.value_type == "integer" else r"-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?" ) ... _public_text(self.unit, maximum=32)
-
src/adcp/types/domains/core/reporting_control_total.py:13-57:ReportingControlTotal1andReportingControlTotal2declarepattern='^[A-Za-z][A-Za-z0-9_.:-]{0,127}$',pattern='^-?(?:0|[1-9][0-9]*)$',pattern='^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$', andmax_length=32onunit. -
src/adcp/types/__init__.py:171:ReportingControlTotalis a public export. -
No module under
src/adcp/reporting/ledger/row_*.py,producer.py, orevidence.pyimportsadcp.types. Two other ledger modules do (consumer_status.py:460,status_server.py:12), so the dependency direction is established.
Suggested fix
Construct ReportingControlTotal instances in _typed_control_totals and hash their wire form. Keep ReportingControlTotalRecord as a thin adapter (or alias) while the retained evidence column and from_wire depend on it, and delete the duplicated regexes from __post_init__. This is protocol shape, so it is independent of the storage layer.
Introduced in #1459.
Activity