Split out from #20, which noted this as worth pairing with the open-ended activation fix but left it out of #25 to keep that diff minimal ahead of the release.
Now that end_time is optional (#25), an activation can be open-ended — endTime genuinely absent, meaning "still in effect". Callers need to detect that shape, not just create it. The motivating case is the live bridge from #20: to close an interval you must first identify the open one.
Current state
The only way to ask "is this still open" is to reach into the protobuf directly:
still_open = not activation.HasField("endTime")
That is what doc/cookbook/machine-configuration.md currently shows. It works, but it pushes a protobuf presence check into user code for what is a first-class domain question, and it requires the caller to know that absent-vs-zero is the distinction that matters.
Suggested change
Add a convenience to GetConfigurationActivationApiResult (machine_config_client.py:477 neighborhood, alongside the existing configuration_activation property):
@property
def is_open(self) -> Optional[bool]:
"""True if the activation is open-ended (still in effect), None if there is no record."""
Returning Optional[bool] keeps it honest on the error path, where configuration_activation is already None — an is_open of False would wrongly imply a closed record exists.
Worth considering the same accessor on the query/iterate paths, which yield bare common_pb2.ConfigurationActivation objects rather than result wrappers. A module-level helper (is_open(activation) -> bool) may serve both shapes better than a property on one result class; that tradeoff is the main design question here.
Scope
- Additive and independent — no change to request building or the wire format.
- Unit tests for: open-ended record, bounded record, error/no-record case.
- Update the cookbook's "still open" recipe to use it, replacing the raw
HasField check.
Split out from #20, which noted this as worth pairing with the open-ended activation fix but left it out of #25 to keep that diff minimal ahead of the release.
Now that
end_timeis optional (#25), an activation can be open-ended —endTimegenuinely absent, meaning "still in effect". Callers need to detect that shape, not just create it. The motivating case is the live bridge from #20: to close an interval you must first identify the open one.Current state
The only way to ask "is this still open" is to reach into the protobuf directly:
That is what
doc/cookbook/machine-configuration.mdcurrently shows. It works, but it pushes a protobuf presence check into user code for what is a first-class domain question, and it requires the caller to know that absent-vs-zero is the distinction that matters.Suggested change
Add a convenience to
GetConfigurationActivationApiResult(machine_config_client.py:477neighborhood, alongside the existingconfiguration_activationproperty):Returning
Optional[bool]keeps it honest on the error path, whereconfiguration_activationis alreadyNone— anis_openofFalsewould wrongly imply a closed record exists.Worth considering the same accessor on the query/iterate paths, which yield bare
common_pb2.ConfigurationActivationobjects rather than result wrappers. A module-level helper (is_open(activation) -> bool) may serve both shapes better than a property on one result class; that tradeoff is the main design question here.Scope
HasFieldcheck.