Skip to content

core: derive legacy zone quantities from topology#512

Merged
Aymericr merged 1 commit into
mainfrom
fix/zone-quantity-topology
Jul 18, 2026
Merged

core: derive legacy zone quantities from topology#512
Aymericr merged 1 commit into
mainfrom
fix/zone-quantity-topology

Conversation

@Aymericr

@Aymericr Aymericr commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • derives wall surface from every overlapping detected room's indoor-facing spans, including both faces of internal partitions while excluding exterior faces
  • proves floor and flat volume from compatible slab/ceiling unions instead of requiring one exactly containing surface
  • supports pre-existing manual zones with legacy boundary and face-aligned surface offsets without project-specific migrations or persisted fields
  • adds regressions for adjacent notched slabs, multi-room zones, open semantic sub-zones, conflicting elevations, and legacy geometry drift

How to test

  1. Run bun test packages/core/src/lib/zone-quantities.test.ts and confirm all 13 focused cases pass.
  2. Run bun test packages/core/src and confirm all 509 Core tests pass.
  3. Open a pre-existing project with a manual zone spanning an interior partition or subdividing an open room, select the zone, and confirm wall/floor/volume values derive without inventing a wall along an open boundary.

Screenshots / screen recording

N/A — calculation and topology logic only; the existing zone quantity panel is unchanged.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Note

Medium Risk
Changes core measurement/quantity logic used in the zone inspector and Smart reports; behavior shifts for manual zones and multi-slab rooms, mitigated by extensive new tests and conservative unavailable paths.

Overview
Zone quantity reports now infer wall, floor, and volume from overlapping detected spaces and compatible surface unions instead of requiring an exact room polygon match and a single containing slab/ceiling.

Wall surface sums indoor-facing boundary spans from every overlapping space, clipped to the zone polygon (interior partitions count both faces; open sub-zones do not invent walls along unenclosed edges). Floor and ceiling use proveSurfaceCoverage: multiple slabs or ceilings are allowed when their union covers ≥95% of the zone and elevations/heights agree; conflicting elevations or insufficient coverage return explicit unavailable reasons. Enclosed-room classification uses mutual space–zone containment at the same threshold, or full boundary-wall proof; a zone can still be a footprint while wall (and sometimes floor/volume) values are available.

Polygon overlap/containment logic is tightened (midpoint sampling, coverage ratio grid), and measurements architecture docs are updated to match. New regressions cover notched adjacent slabs, multi-room suites, open half-room sub-zones, legacy boundary/surface drift, and conflicting slab elevations.

Reviewed by Cursor Bugbot for commit baf62c8. Bugbot is set up for automated code reviews on this repo. Configure here.

@Aymericr
Aymericr merged commit 2084892 into main Jul 18, 2026
3 checks passed
@Aymericr
Aymericr deleted the fix/zone-quantity-topology branch July 18, 2026 12:35

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit baf62c8. Configure here.

status: 'unavailable',
reason: `${labels.plural} covering this zone have different ${labels.datum}.`,
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incidental slabs poison coverage

Medium Severity

The proveSurfaceCoverage function incorrectly identifies covering surfaces. It includes any slab or ceiling with even minor overlap as a candidate, which can lead to issues with datum consistency or hole application from unrelated surfaces. This causes floor and volume quantities to be marked unavailable for zones that are otherwise fully covered by a compatible surface.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit baf62c8. Configure here.


return {
classification: wallSpans ? 'enclosed-room' : 'footprint',
classification: topologyEnclosesZone || boundaryWallSpans ? 'enclosed-room' : 'footprint',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Partial topology blocks wall fallback

Medium Severity

wallSpans always prefers topologyWallSpans whenever it is non-null, even if those spans only come from a partial space overlap and topologyEnclosesZone is false. A complete boundaryWallSpans result is then ignored, while classification can still become enclosed-room from that boundary evidence, so wall surface and boundary wall IDs can be undercounted for an enclosed zone.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit baf62c8. Configure here.

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