Repository navigation
Simplify the logical meter's formula plumbing - #64
Merged
shsms merged 9 commits intoOct 9, 2026
Merged
Conversation
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
shsms
force-pushed
the
logical-meter-formula-plumbing
branch
from
October 6, 2026 16:02
6b34c04 to
803ac5c
Compare
Marenz
reviewed
Oct 7, 2026
Marenz
left a comment
There was a problem hiding this comment.
Looks good overall, a few small things.
Without a lock file, `^0.6.2` already resolves to 0.6.3, which no longer clamps the consumer and producer formulas, so the producer display test failed. Require 0.6.3 and pin the unclamped formulas in the tests. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The following commits build on engine 0.2's `Formula` type. Users see two changes: NaN and infinite values now count as missing data, and formulas past the engine's operator limit are rejected. The actor's `calculate` call becomes `evaluate`; a missing key now reads `Unknown`, which the actor maps to `None`. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Use let-else in `push_to_resampler`, and make the test helper `next_sample` generic so the frequency test can reuse it. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Metrics now state their graph formula kind as a crate-private const instead of the public `Metric::FormulaType`. One match in the handle picks the graph method from that kind and the formula target, which removes the provider trait, its macros and the kind parameter on `GraphFormula`. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The formula engine works in f32 base units, and `BaseValue` builds typed quantities from them. As a crate-private supertrait of `Quantity` it stays hidden, but `Quantity` can no longer be implemented downstream. Used in the next commit. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The actor keeps one entry per distinct formula with a sink per subscriber, replacing the per-quantity maps and the downcast of the response channel. Formulas and resamplers nobody listens to are pruned on every tick. Each subscriber gets its own channel, so `subscribe()` no longer waits for the actor to reply. The handle now parses the graph formula, so a formula the engine rejects fails the handle method with `FormulaEngineError` instead of failing `subscribe()` with `ConnectionFailure`. A formula whose telemetry cannot be started is not registered, so its subscriber's stream closes. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The actor's per-tick bookkeeping had no coverage. Its methods are exercised directly with stub sinks, so the tests do not depend on the mock's stream tracking. A test-only disconnected client handle covers a subscription whose telemetry cannot be started. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
shsms
force-pushed
the
logical-meter-formula-plumbing
branch
from
October 8, 2026 14:27
803ac5c to
d449942
Compare
Marenz
approved these changes
Oct 9, 2026
Marenz
left a comment
There was a problem hiding this comment.
All three addressed, thanks. Verified locally on 1.99 (what CI uses): fmt, clippy --no-deps -D warnings, and clippy --all-targets -D warnings clean, 164 tests pass, and every commit from 19a6e1c on is green.
One non-blocking thing for later: drop_unused_resamplers runs every tick and recomputes engine_formula.components() per formula, which is a full tree walk plus a fresh HashSet each time. The set never changes, so it could live in SubscribedFormula, and the sweep only needs to run when evaluate_formulas actually dropped something.
This was referenced Oct 9, 2026
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.
Prepares the logical meter for evaluating composed formulas in the actor (#60, now split into a stack of three PRs; this is the first). It moves to formula engine 0.2 and component graph 0.6.3, picks graph formulas by a crate-private metric kind instead of per-kind provider impls, and replaces the actor's per-quantity maps and downcast response channel with per-subscriber sinks.
Changes
Depend on formula engine 0.2: missing components now read as unknown; NaN and infinity become missing data.(FormulaKind, FormulaTarget)in one match, replacingGraphFormulaProviderand its macros.subscribe()no longer waits for the actor.FormulaEngineError, instead of failingsubscribe().^0.6.2already resolved to it.Breaking
Metric::FormulaTypeandErrorKind::DroppedUnusedFormulasare removed,Quantityis sealed, and formula values change for NaN/infinite inputs, oversized graph formulas, and the no-longer-clamped consumer and producer formulas. See## Upgradingin RELEASE_NOTES.md.