core: derive legacy zone quantities from topology#512
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ 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}.`, | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit baf62c8. Configure here.
|
|
||
| return { | ||
| classification: wallSpans ? 'enclosed-room' : 'footprint', | ||
| classification: topologyEnclosesZone || boundaryWallSpans ? 'enclosed-room' : 'footprint', |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit baf62c8. Configure here.


What does this PR do?
How to test
bun test packages/core/src/lib/zone-quantities.test.tsand confirm all 13 focused cases pass.bun test packages/core/srcand confirm all 509 Core tests pass.Screenshots / screen recording
N/A — calculation and topology logic only; the existing zone quantity panel is unchanged.
Checklist
bun devbun checkto verify)mainbranchNote
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.