Skip to content

feat(analysis): statistics rounded past 2^53 carry changed.rounded, and the browser download says numbers written as null (#2371) - #3010

Merged
Mavrick-F merged 3 commits into
opengeos:mainfrom
Mavrick-F:feat/rounding-loss-codes
Nov 26, 2026

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Two more notices now carry loss codes, so a strict run (rustgis-cli run --strict), Python's warnings and MCP's losses see them by code. No new codes.

Where Notice Code
Dissolve, Summarize Within, Summary Statistics, Pivot Table, Spatial Join results rounded from whole numbers past 2^53, which a decimal field can't hold exactly changed.rounded
Export Layer, browser download numbers that aren't finite (NaN, infinity), written to GeoJSON as null dropped.value
  • The rounding count holds only results that came out rounded: a statistic whose exact value is whole and differs from the decimal written. changed.rounded's help now names this case.
  • The browser download didn't say the null numbers at all. It now says them as the desktop export does, once the browser takes the file. A refused download says nothing.

Kept plain on purpose

  • "N whole numbers written as text … past the 64-bit integer range … read as decimals, so statistics of them may be rounded": whether a statistic is rounded isn't known, so it isn't counted as a loss.

Testing

  • The statistics tests check the rounding notice with its code, and the clean cases check that nothing is said, coded or not.
  • A new test downloads a layer with a NaN to GeoJSON: an accepted download says dropped.value, a refused one says nothing.
  • On the box: the analysis crate's unit tests, the loss-code guide test and the download tests. The fork's CI ran the full gate.

UI evidence

No new UI. The rounding notice now shows as a warning, as other coded losses do.

Related issue

Part of #2371.

Summary by CodeRabbit

  • Improvements
    • Rounded statistical results beyond the exact integer range are now reported as data losses, separately from messages about large whole numbers written as text.
    • Downloads that contain non-finite numbers written as null now report the loss after the download is accepted.
    • Loss notices appear alongside results from Dissolve, Summarize Within, Summary Statistics, Pivot Table, and Spatial Join.
  • Documentation
    • Guidance now explains that decimal fields may not preserve whole-number precision beyond 2^53 and suggests retaining the source or using a higher-precision format.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9955c337-4b86-4761-b86c-015a0eddb70a
Commits

Reviewing files that changed from the base of the PR and between 322139a and c09050d.

Files selected for processing: 1

  • crates/ui-egui/src/lib.rs

No actionable comments were generated in the recent review.

Walkthrough

Analysis tools return rounded statistic results as ChangedRounded losses, while retaining text-range notices as messages. Web exports report a DroppedValue loss for non-finite values written as null only after a download is accepted.

Changes: Loss reporting

Layer / File(s) Summary
Rounded statistic loss reporting
crates/analysis/src/tools.rs, crates/analysis/tests/integration/*, crates/data/src/loss.rs, docs/cli.md
Dissolve, Summarize Within, Summary Statistics, Pivot Table, and Spatial Join return rounded statistic notices as ChangedRounded losses. Notices for large whole numbers read from text remain messages. Tests and guidance cover the codes and notice ordering.
Accepted web export loss notification
crates/engine/src/cmd/share.rs, crates/ui-egui/src/lib.rs
The web export reports DroppedValue losses for non-finite values written as null after download acceptance. The loss notification helper is public. Tests cover accepted and rejected downloads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Possibly related issues

  • opengeos/RustGIS issue 2922: The PR gates the browser GeoJSON loss notice on download acceptance, matching the issue’s stated notice-gating behavior.
  • opengeos/RustGIS issue 2371: The PR reports ChangedRounded and DroppedValue loss codes, covering part of the proposed loss-notice work.

Possibly related PRs

  • opengeos/RustGIS#1253: Both PRs address rounding notices for whole-number results in Dissolve and Summarize Within.
  • opengeos/RustGIS#1388: Both PRs address rounding notices for Pivot Table statistics above 2^53.
  • opengeos/RustGIS#2979: Both PRs attach loss codes to tool notices and update related documentation and tests.

Suggested reviewers: giswqs, pawelkra, deniial00

Merge Risk: Minimal · previous review 32213

This change adds the existing changed.rounded loss code to rounded-statistic notices and a dropped.value notice to accepted browser GeoJSON downloads. The behavior is additive, so a failure would show up as a missing or uncoded notice, not data loss. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: statistics rounded past 2^53 now carry the changed.rounded loss code, and the browser download notice for numbers written as null is also covered. It is long (129 char…
Description check Passed The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the two loss-code changes and what was kept plain. Testing lists the statistics te…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: statistics rounded past 2^53 now carry the changed.rounded loss code, and the browser download notice for numbers written as null is also covered. It is long (129 characters) and bundles two changes, but both appear in the changeset and the title does not describe anything absent from it.

Full details: Description check

Explanation

The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the two loss-code changes and what was kept plain. Testing lists the statistics tests, the new download test, and the commands run. UI evidence states that no new UI was added, which matches the template's 'No visible UI change.' line. The Related issue section says 'Part of #2371', which fits the template. The description is complete, although the UI section does not carry the required line verbatim.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the numbers bright
Then marks the rounded sums just right
A download waits for yes to land
Then nulls are noted, neat and planned
The burrow hums with losses clear
And hops along to code review cheer

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e88ea0db-6d19-4292-b607-830fb128a5ce
Commits

Reviewing files that changed from the base of the PR and between a757b09 and 322139a.

Files selected for processing: 7

  • crates/analysis/src/tools.rs
  • crates/analysis/tests/integration/spatial_join_merge.rs
  • crates/analysis/tests/integration/summary_fields.rs
  • crates/data/src/loss.rs
  • crates/engine/src/cmd/share.rs
  • crates/ui-egui/src/lib.rs
  • docs/cli.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.

Comment thread crates/ui-egui/src/lib.rs Outdated
ds.push(Some(Geometry::Point(Coord::new(3.0, 4.0))), vec![Value::Float(1.5)]);
let id = app.session.map_mut().add_dataset(ds);
let mark = app.session.notice_mark();
let _ = app.run("ui.exportLayer", json!({"layer": id, "format": "geojson"}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new download test only covers lossy input (a NaN), and it discards the result of app.run(...). Two gaps:

  1. AGENTS.md ("Test both ways") asks for a clean case: a layer with no non-finite numbers should give no written as null notice, on an accepted download. Nothing here checks that, so a notice that fires on every GeoJSON download would pass.
  2. The refused branch expects an empty notice list, but with let _ = it also passes if the export itself errored before the download was attempted. Accepted-branch runs should unwrap() the result (or assert it is Ok), so a failed export can't look like "nothing said".

Suggest adding a third case with Value::Float(1.5) in both rows and expecting vec![], and asserting the run result in the accepted branch.

Category: agents-md

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c09050d: a third case downloads finite numbers only and expects no notice, and an accepted download must succeed (unwrap).

) });
}
messages.extend(rounded_notice(&rounded, out.fields.get(first_added..).unwrap_or_default()));
let (said, rounded) = rounded_notice(&rounded, out.fields.get(first_added..).unwrap_or_default());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, left for the release quality pass: after this change rounded holds a Vec<LossMessage> rather than the rounding counts, and said holds the messages. The shadowing works (the right side is evaluated first), but a name like (notices, rounded_losses) would read more clearly. The same pattern repeats at the Summarize Within, Summary Statistics, Pivot Table and Spatial Join call sites.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass: a naming point, no change in behaviour.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Reviewed the seven changed files against AGENTS.md. I found no bugs or security issues. The rounding notices and the download notice are wired to their loss codes, and the code is the same on every path that checked it.

Bugs

  • None found. Checked the five rounded_notice call sites (Dissolve, Summarize Within, Summary Statistics, Pivot Table, Spatial Join): each now passes its losses through losses and keeps its plain notices in messages. The ChangedRounded code reaches the notice path in gp.rs (around 4134), so strict runs and Python see it.
  • Confidence: high.

Security

  • None found.

Performance

  • None significant. The new numbers_written_as_null call in the browser download adds one scan of the features, the same shape as the existing desktop path in share.rs.

Quality

  • Inline (buffered): in tools.rs the rounded name is reused for a list of losses, and said holds messages. Naming nit, left for the release quality pass.
  • Not inline: in ui-egui/src/lib.rs the download arm shadows ext with download_ext, but the write still uses the dialog format. numbers_written_as_null returns 0 for zip, so the result is correct today. A reader may still trip on it. Left for the release quality pass.
  • Confidence: high on the naming points.

AGENTS.md

  • Inline (buffered): the new download test in ui-egui/src/lib.rs only covers lossy input. AGENTS.md asks for "test both ways", so a clean layer with no non-finite numbers should show no notice. Also, let _ = app.run(...) discards the export result, so the refused-download branch passes even if the export failed. Confidence: medium-high.

Twins checked

  • rounded_notice: all five callers are updated, and no other overlay tool uses it.
  • Null-number notice: the desktop export (share.rs), share/table.rs and workflows.rs already report it. The browser download was the only path missing it, and this PR adds it.
  • Browser Shapefile download: not changed by this PR, and it is outside the scope of the change.

Behaviour change to note

  • The rounding results now arrive as coded losses, so a strict run (--strict) will refuse them. That is what the PR intends. The order of the notices in the output also changed, and the tests were updated to match.

Prior concerns

  • No existing review threads, so none were left alone.

Change size

Compared with main (merge base 66c8856 to PR head 322139a).

Measure Value
Files changed 7 (0 added, 7 modified, 0 removed, 0 renamed)
Size before 1.62 MB
Size after 1.62 MB
Total size change +2.8 KB
File Before After Change
crates/ui-egui/src/lib.rs 560.5 KB 562.4 KB +1.9 KB
crates/analysis/src/tools.rs 946.3 KB 946.8 KB +567 B
crates/analysis/tests/integration/summary_fields.rs 54.5 KB 54.8 KB +259 B
crates/data/src/loss.rs 14.9 KB 15.0 KB +44 B
docs/cli.md 15.6 KB 15.6 KB +44 B
crates/analysis/tests/integration/spatial_join_merge.rs 16.4 KB 16.4 KB +16 B
crates/engine/src/cmd/share.rs 47.6 KB 47.6 KB -7 B

@Mavrick-F
Mavrick-F enabled auto-merge November 26, 2026 05:40
Comment thread crates/ui-egui/src/lib.rs
ds.push(Some(Geometry::Point(Coord::new(3.0, 4.0))), vec![Value::Float(1.5)]);
let id = app.session.map_mut().add_dataset(ds);
let mark = app.session.notice_mark();
let run = app.run("ui.exportLayer", json!({"layer": id, "format": "geojson"}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier thread on this test asked for the run result to be checked, and the fix covers only the accepted branch. The refused branch still discards run, so if the export fails before the download is attempted, that case gives the same empty notice list and passes. The refused case only tests that a refused download says nothing, so the export itself should succeed there too. Checking run in both branches would close that gap. I haven't confirmed that app.run returns Ok when the browser refuses the download (self.download returns false and the arm continues), so if it doesn't, the refused case should assert the error instead. The filter on "written as null" also matches on text; filtering on the loss code alone would be more robust.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass: a stricter test for code that works. The refused case still checks that a refused download says nothing.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Scope: 7 files, +131/−81. The PR routes five statistics tools' rounding notices through LossCode::ChangedRounded, and makes the browser download say when non-finite numbers are written as null. I could not compile or run the tests (no shell), so everything below is from reading the code.

Bugs

  • None found. The losses threading is correct in all five call sites (Dissolve, Summarize Within, Summary Statistics, Pivot Table, Spatial Join). losses is mut where it's extended, and the shadowing order is valid. Confidence: high.

Security

  • None found. Confidence: high.

Performance

  • None found. numbers_written_as_null is one linear scan over borrowed features, with no copy. Confidence: high.

Quality

  • Test gap in feature_download_says_numbers_written_as_null (crates/ui-egui/src/lib.rs:9834, inline comment posted). The earlier thread asked for the run result to be checked. The fix covers only the accepted branch, and the refused branch still discards run, so an export that fails early would pass. The notice filter also matches on text rather than the loss code. Confidence: high that the gap exists; medium on whether app.run returns Ok for a refused download, which the comment says to confirm.

AGENTS.md

  • None found. Checked:
    • Never silent: both notices now carry a code, and the browser download reports null numbers once the browser accepts the file, matching the desktop path (share.rs:780, table.rs:159, workflows.rs:2625).
    • Test both ways: the clean case (Value::Float(1.5), no notice) is covered.
    • Docs: the changed.rounded guide text in docs/cli.md matches loss.rs.
    • Twins: all five Rounded::new sites now go through rounded_notice, and no other tool emits the rounding notice.
    • Wasm: the new browser-side code only calls rustgis_data/rustgis_engine functions that are not desktop-only.
    • Row accessors: ds.features is passed as a slice, the same pattern already used in share.rs, so I don't expect a cargo xtask rows change.

Earlier concerns: I left one alone, the rounded_notice naming nit, which was already answered as a quality-pass item. I treated the accepted-branch part of the download-test thread as addressed and re-raised only the refused-branch remainder.

Change size

Compared with main (merge base 66c8856 to PR head c09050d).

Measure Value
Files changed 7 (0 added, 7 modified, 0 removed, 0 renamed)
Size before 1.62 MB
Size after 1.62 MB
Total size change +3.0 KB
File Before After Change
crates/ui-egui/src/lib.rs 560.5 KB 562.6 KB +2.1 KB
crates/analysis/src/tools.rs 946.3 KB 946.8 KB +567 B
crates/analysis/tests/integration/summary_fields.rs 54.5 KB 54.8 KB +259 B
crates/data/src/loss.rs 14.9 KB 15.0 KB +44 B
docs/cli.md 15.6 KB 15.6 KB +44 B
crates/analysis/tests/integration/spatial_join_merge.rs 16.4 KB 16.4 KB +16 B
crates/engine/src/cmd/share.rs 47.6 KB 47.6 KB −7 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3010/
Web app https://preview.rustgis.app/pr-3010/app/
Commit c09050d

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 26, 2026
Merged via the queue into opengeos:main with commit b144e4b Nov 26, 2026
30 checks passed
@Mavrick-F
Mavrick-F deleted the feat/rounding-loss-codes branch November 26, 2026 06:35
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