Skip to content

[BUG] Divisions: allow both is_land and is_territorial to be true#546

Open
Alex Iannicelli (atiannicelli) wants to merge 6 commits into
mainfrom
atiannicelli/allow-both-is-land-is-territorial
Open

[BUG] Divisions: allow both is_land and is_territorial to be true#546
Alex Iannicelli (atiannicelli) wants to merge 6 commits into
mainfrom
atiannicelli/allow-both-is-land-is-territorial

Conversation

@atiannicelli

Copy link
Copy Markdown
Contributor

Summary

Replaces the @radio_group constraint (exactly one must be true) with a new @require_any_true constraint (at least one must be true) on DivisionArea and DivisionBoundary models. This allows both is_land and is_territorial to be true simultaneously.

Changes

  • New @require_any_true constraint in overture-schema-system — validates that at least one field in a group of bool fields is True, generating anyOf in JSON Schema (vs oneOf from @radio_group)
  • Updated DivisionArea and DivisionBoundary to use @require_any_true("is_land", "is_territorial")
  • Updated hand-written YAML schema (division_boundary.yaml) from oneOfanyOf
  • Removed bad-not-both counterexamples (now valid) and added both_land_territorial positive examples
  • Updated codegen model_constraints.py to handle the new constraint type

Closes #542

Replace @radio_group (exactly one must be true) with a new
@require_any_true constraint (at least one must be true) on
DivisionArea and DivisionBoundary models.

Changes:
- Add require_any_true constraint to overture-schema-system
- Update division_area.py and division_boundary.py to use it
- Change division_boundary.yaml schema from oneOf to anyOf
- Remove bad-not-both counterexample (now valid)
- Add both_land_territorial positive examples
- Update codegen model_constraints.py for new constraint type
- Regenerate baseline schemas

Closes #542

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Alex Iannicelli <atiannicelli@gmail.com>
@atiannicelli Alex Iannicelli (atiannicelli) changed the title Divisions: allow both is_land and is_territorial to be true [BUG] Divisions: allow both is_land and is_territorial to be true Jun 18, 2026
@atiannicelli Alex Iannicelli (atiannicelli) added the bug Something isn't working label Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

🗺️ Schema reference docs preview is live!

🌍 Preview https://staging.overturemaps.org/schema/pr/546/schema/index.html
🕐 Updated Jun 22, 2026 13:00 UTC
📝 Commit 3df9e21
🔧 env SCHEMA_PREVIEW true

Note

♻️ This preview updates automatically with each push to this PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Alex Iannicelli <atiannicelli@gmail.com>

Copilot AI left a comment

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.

Pull request overview

This PR updates the divisions schema to allow is_land and is_territorial to both be true by replacing the “exactly one true” constraint (@radio_group / oneOf) with an “at least one true” constraint (@require_any_true / anyOf) across the Pydantic models and the hand-written YAML schema.

Changes:

  • Add a new @require_any_true model constraint in overture-schema-system and export it.
  • Update DivisionArea / DivisionBoundary to use @require_any_true("is_land", "is_territorial").
  • Update the YAML + baseline JSON schemas and examples/counterexamples to reflect anyOf behavior and allow both flags to be true.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
schema/divisions/division_boundary.yaml Switches oneOfanyOf for land/territorial flags in the YAML schema.
packages/overture-schema-system/src/overture/schema/system/model_constraint/require_any_true.py Introduces the new model constraint and JSON Schema generation hook.
packages/overture-schema-system/src/overture/schema/system/model_constraint/init.py Exports require_any_true / RequireAnyTrueConstraint.
packages/overture-schema-divisions-theme/src/overture/schema/divisions/division_boundary.py Replaces @radio_group with @require_any_true.
packages/overture-schema-divisions-theme/src/overture/schema/divisions/division_area.py Replaces @radio_group with @require_any_true.
packages/overture-schema-codegen/src/overture/schema/codegen/extraction/model_constraints.py Adds description + field-affecting logic for the new constraint type.
packages/overture-schema-divisions-theme/tests/division_boundary_baseline_schema.json Updates generated baseline schema to use anyOf.
packages/overture-schema-divisions-theme/tests/division_area_baseline_schema.json Updates generated baseline schema to use anyOf.
examples/divisions/division_boundary/both_land_territorial.yaml Makes the “both true” example valid (removes expected-error, adjusts fields).
examples/divisions/division_area/both_land_territorial.yaml Adds a new valid “both true” example for division areas.
counterexamples/divisions/division_boundary/bad-not-both.yaml Removes a counterexample that is now valid under anyOf.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Iannicelli <atiannicelli@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Iannicelli <atiannicelli@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Alex Iannicelli <atiannicelli@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Alex Iannicelli <atiannicelli@gmail.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two comments:

  1. It might be useful to generalize require_any_true.
  2. The Python code doesn't use examples/ and counterexamples/ it uses reference/examples/ and reference/counterexamples/ - apologies for this inconsistency but could these be updated also?

@@ -0,0 +1,151 @@
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we generalize this slightly so that require_any_true takes a list of one or more Condition values? If that's workable then you could have, for this use case:

@require_any_true(FieldEqCondition('is_land', True), FieldEqCondition('is_territorial', True))
class DivisionArea(...):
    ...

And for other use cases you can create more complex requirements this way, like "either field A should be set to 'foo' or field B should be set to 'bar'".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working change type - minor 🤏 Minor schema change. See https://lf-overturemaps.atlassian.net/wiki/x/GgDa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Divisions: allow True for both is_land and is_territorial

3 participants