fix: preserve unavailable observations as gaps in stored trends - #87
Open
DivyamTalwar wants to merge 1 commit into
Open
DivyamTalwar wants to merge 1 commit into
DivyamTalwar wants to merge 1 commit into
Conversation
Unavailable table/activity sections have zero-valued numeric fields, which were persisted as measured trend values. Conversely, an observed zero connection count was discarded. Preserve missing observations as NULL and store actual zeros only with availability metadata. A counter reset may invalidate rates while preserving a positive current connection gauge, so keep that gauge independently. Leave unknown legacy zero connections as gaps and preserve positive legacy observations. Regression tests drive Save, Trend, SQLite reopen and serialized Context round trips. They fail on 282ffe8 and pass 20 race-enabled repetitions; full store, collector, why and CLI race tests pass with real dependencies. No schema migration, historical rewrite, collector SQL or JSON changes.
This was referenced Sep 22, 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.
What and why
Closes #86.
Keep unavailable table/activity measurements out of scalar trend columns and retain explicitly observed zero connection counts. Preserve the independently measured positive connection gauge when a counter reset invalidates rates, rather than discarding the whole Health section.
The regression drives actual
Save,Trend, SQLite reopen and Context JSON round trips. It also covers legacy metadata and the reset/gauge boundary used by #73. No existing historical rows are rewritten.Verification
Verified commit:
b866ab08a0281b5213b545207c3c4c8601d25cb4.282ffe8fdd7acdd7b6e1dbd8cf04c155401d3a92: extra zeros from unavailable sections and missing measured-zero connections.go test -race ./internal/store -run TestSaveTrendPreservesScalarAvailabilityAcrossReopen -count=20: passed.go test -race ./internal/store ./internal/collect ./internal/why ./cmd/pgbot: passed.bash scripts/gate.sh: passed on committed HEAD, including pinned lint, unit tests and all six release-target builds.go test -race ./...: passed; formatting andgit diff --checkclean.Scope and risk
This affects scalar columns extracted for newly saved observations only. It does not repair already-stored false zeros, change retention, introduce migrations or alter the model JSON contract. Tests use real SQLite and synthetic collector contexts; no live PostgreSQL failure is claimed. Positive current connection gauges remain usable even when sampled rates are unavailable. Revert this commit to restore the old extraction rules.
Checklist