Skip to content

fix: respect sequence direction and effective bounds - #102

Open
DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/respect-sequence-direction-bounds
Open

DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/respect-sequence-direction-bounds

Conversation

@DivyamTalwar

Copy link
Copy Markdown
Contributor

What and why

Addresses the descending/cycling sequence item in #21 without closing the umbrella audit.

Sequence diagnostics assumed an ascending positive range, omitted negative ranges and ignored cycle semantics and owning-column lower bounds. Preserve the SQL top-50 bound and deterministic risk ordering while calculating position in the increment direction across the effective sequence/owner range. Integer subtraction precedes floating-point conversion so narrow spans near int64 extremes are not lost.

Persist optional floor, increment, cycle and column-limit metadata through the JSON contract; regenerate schema 1.3.0 and update the existing finding documentation. A cycle wholly within its usable owner range is excluded, but cycling alone does not exempt a sequence whose owning column can overflow. Legacy snapshots retain their existing stored ratio and rendering.

Verification

Verified commit: fcc72d22401ead45d788dbf88a42c55739bbf1a1.

  • Regression tests fail on unchanged upstream behavior for descending/cross-zero ranges, extreme integer bounds, cycling and metadata round trips.
  • Affected collector, findings and model race suites pass with the real dependencies.
  • Actual sequence-collector integration passes without skips on disposable PostgreSQL 14, 16 and 18, including bounded selection and owning-column cases.
  • bash scripts/gate.sh passes on committed HEAD: build, vet, pinned lint, tests and all six release-platform builds.
  • go test -race ./... passes; formatting and git diff --check are clean.

Scope, risk and rollback

The percentage is a position within effective bounds, not an exact number of calls remaining; PostgreSQL can expose cached sequence values. No target database writes, new dependencies or database migrations are introduced. Existing JSON field shapes remain, with optional metadata added and the schema regenerated. Other open additive-schema PRs may require version reconciliation when merged; this PR does not incorporate their changes. Revert this commit to restore the prior collector calculation and finding behavior.

Checklist

  • Committed-HEAD gate and full race suite pass.
  • Collector SQL remains read-only; inspected queries are never executed.
  • Privacy and deterministic-finding invariants preserved.
  • Additive model metadata, regenerated schema and existing finding documentation included.

Sequence diagnostics assumed ascending positive ranges and ignored cycling and owning-column lower bounds. Retain bounded SQL risk ordering, derive direction-aware position without signed overflow, and preserve semantic metadata through JSON. Safe in-range cycles are excluded; narrow owners remain guarded.

Verification: actual collector fixtures pass on PostgreSQL 14, 16 and 18; affected race suites pass. The fixture uses the explicit database connection helper. The additive schema is regenerated. No production data is modified; revert this commit to restore prior calculation.
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.

1 participant