Add state_validity/unknown_state to MonitorPoint for state-machine strings - #24
Merged
Conversation
…rings Some string points represent a sequence (e.g. receiver tuning) where intermediate values mean VALID_WARNING and terminal values mean VALID_GOOD or VALID_ERROR. The legacy string path only offered membership-based err/warn lists (yielding meaningless _LOW/_HIGH variants) with an unlisted value silently falling through to VALID_ERROR. state_validity gives an explicit state->validity map with a configurable default (unknown_state) for unlisted states, while the legacy path is preserved unchanged when state_validity is not set. Co-Authored-By: Claude Fable 5 <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
state_validity(dict mapping state name → GOOD/WARNING/ERROR or a fullValiditymember name) andunknown_state(default"ERROR") constructor params toMonitorPoint, for string points whose values are named states in a sequence (e.g. receiver tuning:locking→ WARNING,tuned→ GOOD,failed→ ERROR) rather than a flat set of valid/invalid strings.state_validityis set,_string_validity()delegates to the new_state_machine_validity(); when unset, behavior is unchanged (falls through to the existingerr_low/err_high/warn_low/warn_high/valid_stringsmembership logic).strbefore the dict lookup, since a realsmax_pull()result is asmax.smax_data_types.SmaxStr— a dataclass with defaulteq=True, which makes__hash__ = Noneand so isn't usable as a dict key directly even though it compares equal to a plainstr.docs/monitorsystem_writer_design.md);feature/monitor-compute-engineis stacked on top and uses these schema fields.Test plan
uv run pytest src/slama/monitor/test/test_monitorpoint.py -v— newTestStateValiditycases pass (listed GOOD/WARNING/ERROR states, unlisted-state default, customunknown_state, fullValiditymember name acceptance, legacy-path regression, realSmaxStrhashability regression)uv run ruff check src/slama/monitor/monitorpoint.py— clean🤖 Generated with Claude Code