rust(fix): tell callers when get_data returned decimated data - #774
Open
rowenwu wants to merge 2 commits into
Open
rust(fix): tell callers when get_data returned decimated data#774rowenwu wants to merge 2 commits into
rowenwu wants to merge 2 commits into
Conversation
The tool description recommended decimation for exactly the work the API warns against, and the result never said what rate was applied. Together those let an agent compute a standard deviation on plot data and report it as fact. Guidance. `sample_ms` is now documented as 0 unless the data will be used exclusively to draw a picture, with LTTB named and the consequence spelled out: counts, means, standard deviations and trends taken off decimated output are wrong, and the error depends on where bucket boundaries fall, so it cannot be corrected afterwards. An oversized result is answered by narrowing the time range or the channel set, not by decimating. The two prompt flows that told the agent to pick a rate to suit the run length now pass 0, since both end in statistics. Reporting. `Metadata.sampled_ms` arrives on every data page and was being dropped. `get_data` now surfaces `sample_ms_applied` and `decimated`, always present so raw and unchecked cannot be confused, and the next_step text says plainly that a decimated file cannot be analysed. The rate is tracked as a range rather than a single value because the API ignores `sample_ms` for data types it cannot sample: one request can come back decimated for a double channel and raw for a string one. Reporting whichever page landed last would describe half the file, so a mixed result reports the decimated half and sets `mixed_sample_rates`.
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.
What
get_datarecommended decimation for exactly the work the underlying API warns against, and never reported what rate it actually applied. Together those let an agent compute statistics on plot data and report them as fact.sift/data/v2/data.protodocuments thatsample_msapplies LTTB, and that0"is recommended for external data analysis where full fidelity is required, as opposed to plotting where downsampling is typically sufficient." The tool description said the reverse and never named the algorithm.Why it matters
LTTB selects shape-defining extremes rather than representative samples, so second-moment and trend statistics drawn from decimated output are wrong. Measured on one channel over one throttle window, raw against a 10 Hz pull:
The error depends on where bucket boundaries fall relative to the analysis window, so it cannot be corrected after the fact. Bucketing the raw series and comparing each returned sample against its bucket, 50.3% matched the bucket minimum and 49.8% the maximum, which is LTTB working as designed.
Changes
Guidance.
sample_msis documented as0unless the data will be used exclusively to generate a visualization, with LTTB named and the consequence stated. An oversized result is answered by narrowing the time range or the channel set, not by decimating. The two prompt flows that told the agent to pick a rate to suit the run length now pass0, since both end in statistics.Reporting.
Metadata.sampled_msarrives on every data page and was being dropped. The result now carriessample_ms_appliedanddecimated, always present so raw and unchecked cannot be confused, and thenext_steptext says plainly that a decimated file cannot be analysed.The rate is tracked as a range rather than a single value because the API ignores
sample_msfor data types it cannot sample: one request can come back decimated for a double channel and raw for a string one. Reporting whichever page landed last would describe half the file, so a mixed result reports the decimated half and setsmixed_sample_rates.Verification
cargo test -p sift_mcp— 511 pass, 3 new:get_data_reports_the_applied_sample_rate— a decimated pull reports its rate and setsdecimatedget_data_reports_raw_when_nothing_was_decimated— a raw pull reports itself as raw, rather than as "no rate reported"get_data_flags_a_file_that_mixes_decimated_and_raw_channels— a mixed file reports the decimated half and flags the mixcargo clippy -p sift_mcp --all-targetsis clean apart from one pre-existing warning inreport_templates.Note for reviewers
This changes agent behaviour, not just documentation. Anything downstream that assumed
get_datawould decimate by default for large pulls will now receive raw samples unless it asks otherwise.