The staircase calculator existed (_calc_generic_floor_item handles the
"staircase" key: volume_per_level x (structural_levels - 1)) but no item with a
"staircase" key was present in DRAWING_ITEMS_MAP, so compute_all_quantities never
called it — staircase concrete was silently absent (0) from every BOQ.
Added the "staircase_1st" item to the super-structure page. Verified on real
saved projects: G+1 -> 5.2 m3, G+2 -> 10.4 m3, single-storey -> 0 (correct). On
the training villa with a known BOQ this lands at 5.2 vs a real 6 m3 (-13%,
within +-15%).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix: bound internal-wall over-read to a realistic ratio (photos 2 & 3)
Verified against the user's actual saved project (id 1140002) loaded from the DB
state_data, not a re-run:
- Internal blockwork was inflated because the vector wall measurement over-reads
(707 m of internal wall on a 355 m2 floor — 2x the floor area in metres). The
guard capped at 0.8x area which still let ~284 m through. Tightened to 0.55x
(internal partition run is empirically ~0.4-0.5x floor area) and flagged as
ESTIMATED. On 1140002 internal block 200 mm 653 -> 357 m2 and 100 mm 263 ->
405 m2, so 100 mm partitions now correctly exceed 200 mm walls.
- Finishes (thermal block, dry/wet flooring, wall tiles, skirting) were already
correct and are unchanged.
Confirmed on four real saved villas: internal walls settle at a realistic
~0.53-0.55 m/m2 with 100 mm dominating; columns/slabs/beams all sane.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix: roof-column "Err" root cause + bound impossible column/beam/slab reads
Diagnosed on a real ARCH+STR villa (measured, not assumed):
- Roof column concrete showed "Err": the floor-item dispatch prefix was
"col_roof_" (trailing underscore) but the item key is "col_roof", so
startswith() never matched -> no calculator -> None -> UI "Err". Fixed the
prefix. (col_roof now computes, e.g. 3.36 m3.)
- _g() now coerces non-numeric field values (e.g. "VARIES") to the default
instead of raising, so one bad extracted string can't blank a whole item.
Per the user's chosen policy (bounded estimate + clear warning) for values the
tool cannot measure reliably from the drawing, each of these is scaled to a
geometry-based limit and flagged "ESTIMATED - please confirm":
- Beam length over-read: when the vector engine can't find a beam's text mark
and the AI reads a near-cumulative figure (e.g. B1 = 369 m on an 83 m villa),
the floor's beams are scaled to the grid limit (~2.5x perimeter). Slab now
exceeds beam again (91.7 vs 25.1, was 91.7 vs 46).
- Column v…
fix: eliminate systematic over/under-estimation found across training villas
Validated the QTO engine on real ARCH+STR villa drawings and fixed the
recurring quantity errors (general, anchored to gf_area — not per-project):
- Tie-beam length under-read: the vector measure only tags beam segments
within ~0.5 m of a "TBn" label, so sparsely-labelled (or unlabelled) plans
gave a few fragments (e.g. 28 m -> 3.4 m3 concrete). Floor the length to a
realistic network (~2.2x perimeter, calibrated from a well-labelled villa
measured at 2.23x) when it falls below 1.5x the perimeter. Well-labelled
plans (measured 128.6 m) are left untouched.
- Excavation / backfill / anti-termite / road-base blown up 6-13x: root cause
was longest_length/longest_width latching onto the largest dimension line on
the sheet (plot boundary / setback chain) instead of the building. Scale the
overall footprint back to ~1.25x the ground-floor area (keeping aspect ratio)
when it exceeds 1.4x. Excavation e.g. 2213 -> 687 m3.
- Roof plan not detected -> roof waterproofing & roof…
fix(qto): tighten roof/floor area clamp to the building footprint (all villas)
The previous 1.6x threshold was too loose: a roof read at ~250 m2 on a ~166 m2
footprint passed the gate and gave roof waterproofing ~300 m2 (near the whole
building's total BUA, which is physically impossible for a single roof). A villa
roof covers ONE floor's footprint, so cap roof_slab_area to footprint x 1.2 and
each floor's slab area to footprint x 1.3 (anchored to the reliable ground-floor
area). General across every villa, not one project.
Verified on the real villa (GF 166 m2): correct read -> roof WP 221; a 250/1476
over-read -> capped to 239 (was 300 / 1772).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(qto): clamp over-read roof / slab areas to the building footprint
A roof-plan (or slab-plan) extraction that captured the whole sheet / site plan
produced roof_slab_area several-fold too large — inflating BOTH roof
waterproofing (1772 m2) and roof slab concrete (384 m3) on a ~270 m2 villa.
roof_slab_area (project level) and every floor's slab area are now clamped to a
generous multiple (1.6x) of the ground-floor footprint, with a review flag.
Verified: roof WP 1772->324, roof slab concrete 384->67.5.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
When the same floor plan is classified on two pages, their internal-wall
lengths were summed into the project total that the ground floor then used —
inflating internal blockwork ~10× (e.g. 5296 m² on a 270 m² floor). The system
now clamps each floor's internal wall length (10/20 cm split + total) to a
generous floor-area ceiling (0.8 × area), so a classification duplicate can no
longer blow up the quantity; realistic layouts are untouched and the clamp is
flagged for review. Makes the engine resilient to classification errors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(calculations): fix column counts and mm conversions falling back to 0.21, fix missing slab area propagation
perf: eliminate Step 3 hangs by shrinking max PNG DPI to 50 for all blueprints, preventing massive network timeouts when sending images to Gemini. Increased concurrent extraction workers to 8 to slash processing time.
fix: massive OpenCV performance optimization. Prevented infinite hang during Step 3 by resizing A0 blueprints before morphology and disabling pure Python loops over 100k+ noise contours.
Fix BOQ columns and empty 2nd floor: added column length/width defaults to VerifyStep and fallback logic in _columns_for_floor; hide empty upper floor sections from BOQ