Skip to content

feat(features/client): gate writes on remote Write() support#251

Open
andig wants to merge 1 commit into
enbility:devfrom
andig:feat/consistent-write-operation-gate
Open

feat(features/client): gate writes on remote Write() support#251
andig wants to merge 1 commit into
enbility:devfrom
andig:feat/consistent-write-operation-gate

Conversation

@andig

@andig andig commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Consistently applies the write-capability gate introduced for the HVAC/Setpoint helpers in #247 to the pre-existing client write helpers:

  • loadcontrol.WriteLimitData
  • deviceconfiguration.WriteKeyValues
  • timeseries.WriteData
  • smartenergymanagementps.WriteData

Each now returns api.ErrNotSupported unless the remote server feature advertises operation.Write().

Why

Follow-up to the consistency discussion in #247 (comment). Previously these helpers fetched Operations()[fn] only to decide WritePartial() and never gated on Write(), so a write to a read-only remote was serialized and sent, then rejected remotely, instead of failing fast locally.

Breaking

Minor breaking (as flagged in the PR-247 discussion): callers writing to a remote that does not advertise write support now receive ErrNotSupported instead of the write being attempted.

Tests

  • One read-only negative case per helper (new readOnly toggle in the client test helper) asserting ErrNotSupported.
  • Usecase test setups (eg/lpc, eg/lpp, cem/cevc, cem/ohpcf, usecases/internal) now advertise Write() on remote features, matching real devices. Without this the gate caused those write tests to fail — and made internal.Test_WriteLoadControlLimits hang awaiting a response that no longer came.

Full ./usecases/... ./features/... ./api/... ./service/... suite passes (26 packages, exit 0).

🤖 Generated with Claude Code

Consistently apply the write-capability gate introduced for the HVAC/
Setpoint helpers in enbility#247: the client write helpers now return
api.ErrNotSupported unless the remote server feature advertises
operation.Write().

Affected helpers:
- loadcontrol.WriteLimitData
- deviceconfiguration.WriteKeyValues
- timeseries.WriteData
- smartenergymanagementps.WriteData

Previously these fetched Operations()[fn] only to decide WritePartial()
and never checked Write(), so a write to a read-only remote was sent and
rejected remotely instead of failing fast locally. This is a minor
breaking change: callers writing to remotes that do not advertise write
support now get ErrNotSupported.

Tests: add a read-only negative case per helper (new readOnly toggle in
the client test helper); update usecase test setups (eg/lpc, eg/lpp,
cem/cevc, cem/ohpcf, internal) to advertise Write() on remote features
as real devices do.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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