Skip to content

Compose: decode stored geometry coordinates; fix cell-target description and unit example - #736

Merged
amarcozzi merged 1 commit into
mainfrom
735-compose-contract-fixes
Oct 16, 2026
Merged

amarcozzi merged 1 commit into
mainfrom
735-compose-contract-fixes

Conversation

@amarcozzi

Copy link
Copy Markdown
Contributor

Closes #735

Changes

  • Grid decodes source.operations (grids/schema.py). Compose stores inline-geometry condition coordinates JSON-encoded for Firestore. Grid decoded them only for top-level modifications, so a compose grid with a geometry condition returned "coordinates": "[[[...]]]" as a string in source on create, GET and list. It now decodes source.operations the same way inventories decode source.modifications. The worker already handles both forms (griddle/modifications.py), so it doesn't change.
  • target description (grids/modification_models.py, both spatial condition models): cell doesn't mean "any overlap matches" for every operator. intersects matches any cell the geometry touches, within only cells entirely inside it, and outside only cells it doesn't touch. This matches the griddle mask logic.
  • unit_override compose example (grids/compose/examples.py): it wrote fuel_load.1hr in g/m**2, which the output-key check rejects with a 422. It now multiplies a live herb load by a 67 % literal (derived kg*%/m**2) and writes it as kg/m**2.

Contract

Response shape fix: compose source.operations[*].conditions[*].geometry.coordinates is now a nested list, not a string. This is a bug fix, but clients reading the string form would see the change. The SDK keeps source as a dict, so it's unaffected.

Ripples

  • FastFuels-Web#373 (compose how-to): recapture compose_grids/responses/geometry_condition_created.json after this deploys.
  • SDK and webapp client: no changes needed.

Verification

  • New Grid schema test: decodes source.operations geometry. It fails without the fix.
  • New compose router test: a geometry condition comes back as nested lists from both create and GET.
  • pytest tests/resources/grids/compose/ tests/resources/grids/test_schema.py against a local server: 141 passed
  • pytest tests/resources/grids/test_modifications_router.py plus compose: 129 passed

… and unit example (#735)

Grid now decodes stringified inline-geometry coordinates in
source.operations, so compose grids with geometry conditions return
nested-list GeoJSON on create, GET and list. The spatial target
description says what cell does for each operator: intersects matches
any touched cell, within only cells entirely inside, outside only
untouched cells. The unit_override compose example wrote fuel_load.1hr
in g/m**2, which the output-key check rejects; it now scales a live herb
load by a percent literal and writes kg/m**2.
@amarcozzi
amarcozzi merged commit c125e3e into main Oct 16, 2026
1 check passed
@amarcozzi
amarcozzi deleted the 735-compose-contract-fixes branch October 16, 2026 21:27
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.

Compose: decode stored geometry coordinates; fix cell-target description and unit example

1 participant