Skip to content

feat(breg): add bounded Polygon and MultiPolygon geometry fields - #2644

Open
jeremi wants to merge 3 commits into
mainfrom
feat/breg-polygon-2643
Open

jeremi wants to merge 3 commits into
mainfrom
feat/breg-polygon-2643

Conversation

@jeremi

@jeremi jeremi commented Nov 11, 2026

Copy link
Copy Markdown
Member

BReg can store points but cannot validate, index, query, or export plot and site boundaries. Add crs84-polygon fields that accept GeoJSON Polygon and MultiPolygon, retain the submitted coordinate and ring order, and use a generated PostGIS projection for topology validation and indexed bbox intersection.

Closes #2643.

Behavior

  • Require precision (0–9) and maximumPositions (4–10,000), with an optional CRS84 bbox. Validate closed 2D rings, coordinate bounds, precision, size, and topology. Reject invalid geometry and antimeridian-crossing edges without repairing submitted values.
  • Apply the same validation to record writes, Actions, and Proposals. Keep polygon storage independent of bbox grants; bbox reads retain existing field permissions and row boundaries.
  • Advertise a polygon-capable GIS profile only for caller-visible polygon collections. Extend Rust, Node, and Python geometry types and preserve Point compatibility.
  • Rebuild retained generated projections when polygon precision, bbox, or position bounds change, under the existing reviewed migration and rehearsal contract.
  • Extend the spatial acceptance project, generated authoring schemas, adopter tooling, and public references.

Verification

  • BReg library and compiler suites; bregctl library and CLI suites; Rust client tests; native Node (95) and Python (101) tests; TypeScript declarations and unified client synchronization.
  • Real PostgreSQL 17 / PostGIS 3.5 spatial storage, HTTP read, and reviewed migration suites: 25 passed. Coverage includes invalid topology, polygon-only storage, geometry intersection rather than envelope overlap, row/field authority, and retained-value contract tightening.
  • Authored native development journey with Polygon and MultiPolygon records: complete, with no pending activation or diagnostics.
  • BReg generated-contract and client-contract gates, affected-crate clippy, formatting, generated identifiers, CLI catalog and language-server checks, targeted documentation checks, and publication scans.

Security review

Malformed geometry is bounded before PostGIS evaluation, and the generated structural validator is immutable, strict, SECURITY INVOKER, and uses a fixed search path. Topology checks use the flags overload to suppress coordinate-bearing PostGIS notices. The patch preserves existing read authorization and explicit bbox grants; negative tests cover denied fields and row boundaries. Reviewed migrations reject retained values that violate the candidate polygon contract before activation.

Area derivation and cross-record spatial rules remain outside this field type. Cross-kind migrations use a new polygon field and reviewed backfill. Related #1827 tracks the separate Compose-template PostGIS detection.

Add governed CRS84 Polygon and MultiPolygon fields, PostGIS validation and bbox reads, reviewed spatial migrations, native client support, and authored acceptance coverage.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T05:19:00.082755Z f6c10fa New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Keep the existing local value type exception pointers on their schema branches and verify that polygons are accepted directly but refused as reusable scalar aliases.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ct change costs

Record the polygon feature and the client geometry type change in the BReg
changelog, with migration steps for Rust, TypeScript and Python. Say in the
spatial queries guide that changing a geometry field's precision, bbox or
maximumPositions is a field type change that needs a reviewed migration, and
what happens when a retained value violates a tightened contract.

Drop a Point validator assertion that pinned a precision-9 refusal of a valid
coordinate; issue #2645 tracks the validator.

BREAKING CHANGE: the geometry of a GeoJSON Feature in the Rust, Node.js and
Python clients is a union of Point, Polygon and MultiPolygon. In Rust, match
BRegGeoJsonGeometry::Point(point) before reading coordinates. In TypeScript,
narrow on geometry.type === "Point". In Python, type checkers see the union.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>

This branch has not been deployed

No deployments
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.

breg: polygon geometry fields for plot and site boundaries

1 participant