Skip to content

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

Merged
jeremi merged 4 commits into
mainfrom
feat/breg-polygon-2643
Nov 11, 2026
Merged

jeremi merged 4 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-11T06:32:32.995151Z 2c1f526 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>
@jeremi
jeremi added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
The spatial fixture journeys gained two service-area creates and an
area-map bbox read, but the production-executor test still listed
credentials for the old steps only, so the credential inventory no
longer matched the suite and the PostgreSQL lane refused it.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
@jeremi
jeremi enabled auto-merge November 11, 2026 06:30
@jeremi
jeremi added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@jeremi
jeremi added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 54f0d46 Nov 11, 2026
72 checks passed
@jeremi
jeremi deleted the feat/breg-polygon-2643 branch November 11, 2026 08:28
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