Skip to content

fix: suppress baseline comparisons across statistics resets - #64

Open
DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/reset-safe-baseline-comparisons
Open

DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/reset-safe-baseline-comparisons

Conversation

@DivyamTalwar

Copy link
Copy Markdown
Contributor

What and why

Closes #61.

A detected statistics reset or server restart makes the two snapshots incomparable. The standalone diff path nevertheless calculated deltas, and the text renderer could print either those deltas or "nothing material changed" after its reset warning.

Reuse the existing StatsResetBetween contract in diff.Compute and stop rendering after the reset explanation. JSON retains its reset caveat and changes: []; ordinary comparisons and the independent eviction warning are preserved.

Verification

Verified commit: 0e9cecb8cafe087cdc5efc661c91ee067804dccb.

  • The new regression tests fail on base a1e6561e366455756c45a16a46647f882b3b6a1c for the reported behavior.
  • go test -race ./internal/diff ./internal/render ./cmd/pgbot -run 'TestCompute_|TestDiffReport_|TestResolveDiff_Reset' -count=20: passed.
  • Coverage includes the real SQLite snapshot store, offline resolver and CLI/MCP-shared JSON, first/later resets, restarts, comparable snapshots and text rendering.
  • bash scripts/gate.sh: passed on the committed HEAD, including build, vet, pinned lint, unit tests and six release-target builds.
  • go test -race ./...: passed; formatting and git diff --check are clean.
  • Additional identical-source-tree validation and dependency scanning: fork run. This commit changes author/message metadata only relative to that source tree.

Risk and rollback

The behavior changes only when the existing reset detector says comparison is unavailable. No PostgreSQL queries, dependencies, migrations or JSON field shapes change. Revert this commit to restore the previous behavior. The new store/JSON regression is database-independent; PostgreSQL-specific integration tests self-skip in the local suite.

Checklist

  • Committed-HEAD gate, full race tests and formatting pass.
  • Read-only and privacy invariants are unchanged.
  • JSON schema and finding catalog are unchanged.

Offline comparisons could expose cumulative deltas or report no material change after detecting a statistics reset or server restart. Apply the existing reset-suppression contract in Compute and terminate rendering after the unavailable-comparison explanation.

Regression coverage includes the real SQLite baseline store, CLI/MCP-shared JSON, first and later resets, restarts, normal comparisons and eviction notices. Existing JSON field shapes remain unchanged.

Closes pgrundev#61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline diff presents reset-crossing snapshots as valid comparisons

1 participant