@floless/app 0.122.0 → 0.123.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,7 +75,9 @@
75
75
  "visible": { "type": "boolean" },
76
76
  "opacity": { "type": "number", "minimum": 0, "maximum": 1 },
77
77
  "locked": { "type": "boolean", "description": "Freezes move/rotate/scale/delete/reload. Does NOT affect visibility or snapping — lock means 'do not let me move this by mistake', not 'stop using it'." },
78
- "snap": { "type": "boolean", "description": "INDEPENDENT of `visible`. A hidden reference still snaps unless this is false: hiding is a visual act (get it out of my way) and you still want to land on their grid intersection." }
78
+ "snap": { "type": "boolean", "description": "INDEPENDENT of `visible`. A hidden reference still snaps unless this is false: hiding is a visual act (get it out of my way) and you still want to land on their grid intersection." },
79
+ "colorMode": { "type": "string", "enum": ["file", "uniform", "custom"], "description": "How this reference is coloured. `file` — the DEFAULT when absent — paints each object the colour the IFC styles it with, falling back to the app's own grey for a file that authors none. `uniform` is that grey everywhere: the deliberate 'this is not your content' signal. `custom` paints the whole reference `color`. Absent meaning `file` is what lets a reference imported before colours existed adopt them on its next read instead of staying grey forever." },
80
+ "color": { "type": "string", "minLength": 7, "maxLength": 7, "description": "The custom colour, `#rrggbb`. REMEMBERED INDEPENDENTLY of `colorMode`, so switching to `file` and back does not lose the colour you picked. Only read when `colorMode` is `custom`." }
79
81
  }
80
82
  }
81
83
  }
@@ -2,7 +2,7 @@
2
2
  name: floless-app-steel-takeoff
3
3
  description: Read a structural steel drawing into an editable steel.takeoff/v1 contract in floless.app — the "Steel Takeoff" reader. Triggers on a pending floless `rebake` request for the `steel-model` app (queued from its "Re-read & re-bake ▸" button), or asks like "read this framing plan into a takeoff", "turn this structural drawing into a takeoff", "bake my drawing into steel-model", "extract members from this PDF". Teaches the host AI to READ a steel drawing (PDF/image) with its own vision at COMPOSE time, build a steel.takeoff/v1 contract (members + profiles + elevations + weights from AISC lookup), write it to the contract store, and hand control to the editor — no model in the run path, no API key.
4
4
  metadata:
5
- version: 0.15.0
5
+ version: 0.16.0
6
6
  ---
7
7
 
8
8
  # Steel Takeoff — read a drawing into a steel.takeoff/v1 contract
@@ -21,8 +21,29 @@ each learned from a real failure:
21
21
  column, and callout registers to it (and it is why columns stack across stories). **Reuse the real
22
22
  detector `web/grid-core.js` `gridFromDrawing`** — do NOT reimplement grid detection (a naive
23
23
  re-port produces sign-flipped spacings and spurious bays; the real detector anchors to bubble
24
- clusters, rejects impostor lines, and even reads printed labels). Run it over the grid-layer lines
25
- + bubbles (`*S-ANNO-GRID*`).
24
+ clusters, rejects impostor lines, and even reads printed labels).
25
+ - **Prefer scoping the detector's input to the grid layers — but NEVER drop the bubbles.** Pass the
26
+ grid-layer lines (`*GRID*`, `*GRCL*`, `*S-ANNO-GRID*`), **every `kind:"circle"` element on the
27
+ sheet**, and the label-like text. The circles are the detector's primary anchor (`anchored:
28
+ 'circles'`), and CAD sets outline their text — so a scope that keeps only lines and text usually
29
+ leaves it nothing to anchor to and it returns `null`, i.e. **no grid at all**. A missing grid is a
30
+ worse failure than a phantom line. If you cannot identify the grid layers with confidence, hand it
31
+ the sheet: §0's own rule ("the LAYER NAME is a hypothesis, not a fact") cuts both ways.
32
+ - **Know what actually produces a phantom line, because it is a two-stage rule, not a circle count.**
33
+ A collinear cluster of ≥3 circles is *necessary but not sufficient*: each bubble must also bind a
34
+ long line field that aims at its centre and stops at its edge, and the cluster only counts when at
35
+ least three — and at least half — of its members bind. (The detector never compares radii, so
36
+ "same-size" is not a criterion you can check.) The residual exposure is narrow and real: a column
37
+ of section/detail balloons that terminate long cut lines can survive the binding gate.
38
+ - **Verify by cross-reading the grid, not by hunting unanchored lines.** Every line the detector
39
+ returns is bound to an anchor by construction, so "a detected line with no bubble near it" is a
40
+ signature that cannot appear. The return is `{ grid, info }`: `info.v` / `info.h` are line **counts**
41
+ only (plus `anchored` and `labeled`) — the labels and spacings you actually compare live on `grid`
42
+ (`grid.labels_x` / `labels_y`, `grid.x` / `grid.y`). Compare those across plan sheets over the
43
+ extent the sheets share, and use the counts only as counts. One
44
+ coordinated set draws one grid, but **counts may legitimately differ**: partial plans, inserts and
45
+ enlarged plans show a documented subset. A disagreement in *spacing or labels* over shared extent
46
+ is the real defect; a smaller count on a partial plan is not.
26
47
  - **Columns are extracted, as sections, from the column linework** — match **EVERY `S-COLS*` layer, on
27
48
  EVERY xref**, not just `S-COLS-STEL` on the shared grid xref. (Matching only
28
49
  `…-grids|S-COLS-STEL` misses real columns — the seismic-joint "(N) COL ABOVE" pairs live on the
@@ -99,17 +120,56 @@ each learned from a real failure:
99
120
  unsized, and never present a roof as "missing beams" without opening every section and frame
100
121
  elevation that cuts it.** Cross-check the section/elevation member count against the plan; a bare `MF`
101
122
  mark or a suspiciously empty roof means a section is still unread — go read it.
123
+ - **BIND BY THE CALLOUT BUBBLE, NOT BY THE DETAIL'S TITLE.** A section or elevation is titled with where
124
+ it was **cut**; the callout bubbles drawn on the plans say where it **applies**. Those are different
125
+ facts, and the bubbles are the authoritative one. Two consequences, both common on real sets:
126
+ - **A title can be wrong and the set still be correct — but prove it before you decide that.** An
127
+ elevation titled "ALONG GRID `<x>`" where no grid `<x>` exists in the plan grid is a *discrepancy*,
128
+ not yet a verdict: callout numbers, target sheets and bubble marks are all commonly mis-read, so
129
+ re-read the title AND the bubble at high zoom and confirm the target sheet before concluding
130
+ anything. Prefer the bubble once geometry and repeated references corroborate it — then find the
131
+ plan member carrying that bubble and bind there. Never invent a grid to make a title true. If the
132
+ two still disagree after that, record the ambiguity in `read_notes` rather than declaring a
133
+ drafting slip.
134
+ - **One detail can size members in several places.** If the same `n/SHEET` bubble is drawn at two or
135
+ more locations, that detail governs **all** of them — a "typical" condition drawn once. Sizing only
136
+ the location named in the title leaves the others as false RFIs. Harvest the bubbles first, group
137
+ by target, and apply each detail everywhere its bubble appears.
138
+ - Say which bubble resolved each non-obvious binding in `read_notes` — that is what lets a reviewer
139
+ confirm the read without repeating it.
102
140
  - **Not every line the filter grabs is a gravity beam — but the LAYER NAME is a hypothesis, not a fact.**
103
141
  The Steel Filter pulls ALL linework into `members`. Layer naming is a per-firm CAD-template choice, so
104
142
  **census each candidate layer before you classify it**, and treat the legend as authoritative:
105
- - **Census, then decide.** For each layer, count how many of its elements are *member-scale strokes*
106
- versus *tiny end-glyph fills*. A layer that is nothing but long strokes and their arrowheads holds
107
- **members**, whatever its name implied. A layer that is overwhelmingly small fills sitting **on**
108
- other members holds **annotation**. Under the US NCS naming most sets follow, the beam layer
109
- (`*BEAM*`) and the bracing layer (`*BRAC*`) carry members while `*ANNO*` layers carry the symbols —
110
- use that as the *starting hypothesis*, never as the answer.
143
+ - **Census, then decide — and census into THREE classes, not two.** For each layer, sort its
144
+ elements into: *member-scale strokes*, *tiny end-glyph fills*, and **measurement/leader strokes**.
145
+ A layer that is nothing but long strokes and their arrowheads holds **members**, whatever its name
146
+ implied. A layer that is overwhelmingly small fills sitting **on** other members holds
147
+ **annotation**. Under the US NCS naming most sets follow, the beam layer (`*BEAM*`) and the bracing
148
+ layer (`*BRAC*`) carry members while `*ANNO*` layers carry the symbols — use that as the *starting
149
+ hypothesis*, never as the answer.
150
+ - **The third class is the one that gets modelled by mistake: DIMENSION ARROWS ARE MEMBER-SCALE.**
151
+ A dimension line is a full-length stroke on whatever layer the firm's template assigned it —
152
+ frequently a *member* layer — so "is it long?" cannot separate a 5-ft kicker from a 5-ft dimension.
153
+ These are **suspicion signals, not a rejection test** — take them together, never singly: an
154
+ **arrowhead at BOTH ends** (a member terminates at a joint, not in a pair of arrows); **witness /
155
+ extension lines** at the ends, perpendicular to the stroke; a nearby text run reading as a length
156
+ (`6'-0"`, `EQ`); a span that **exactly matches the clear gap between two parallel members** and
157
+ runs perpendicular to them; a run of **several parallel equal-length strokes evenly spaced** along
158
+ one line of framing. **The last two alone are NOT enough to reject**: an infill beam does span the
159
+ clear gap perpendicular to its supports, and a row of evenly spaced parallel members is what a
160
+ joist bay looks like. Reject only with corroboration — paired arrowheads or witness lines or
161
+ dimension text, plus the legend/layer semantics, plus the absence of any structural connection at
162
+ the ends. Crop one and LOOK before you keep *or* drop the family; a handful of phantom braces is
163
+ the usual outcome of skipping this check, and a deleted joist bay the usual outcome of over-applying
164
+ it. When it stays ambiguous, keep the member and say so in `read_notes` — a phantom brace is
165
+ visible to a reviewer, a silently deleted joist is not.
111
166
  - **NEVER drop a layer you have not censused.** Dropping a member layer deletes every member on it,
112
167
  silently, and nothing downstream will notice. If a layer is dropped, say which and why.
168
+ - **And the symmetric rule: NEVER KEEP a layer you censused only by stroke length.** Length alone is
169
+ not evidence of member-hood. A layer earns member status by *shape* — strokes that terminate at
170
+ other members, carry a size label, and are not bracketed by arrowheads. State, in `read_notes`,
171
+ what each kept steel layer actually contains and what you rejected from it; a layer that turns out
172
+ to carry no members at all is a normal and reportable result, not a failure.
113
173
  - **The legend defines the glyphs; this file does not.** A plan's PLAN NOTES block declares what each
114
174
  line symbol means — which end-glyph marks a moment connection, a braced-frame connection, a drag
115
175
  connection, a stiffener, a deck span, a lateral brace. **These differ between firms.** Read the
@@ -228,10 +288,13 @@ native/display coords):
228
288
  2. **Text** — `page.get_text("dict")`: per span keep `{ kind:"text", layer:<OCG>, w:0, color:<#hex>,
229
289
  text:<string>, bbox:[x0,y0,x1,y1] }`.
230
290
  2b. **Circles** — a closed bezier path whose bbox is round (width ≈ height, ≥ ~8 pt across) becomes
231
- `{ kind:"circle", cx:<centre x>, cy:<centre y>, r:<radius> }` in display space. These are the grid
232
- bubbles and callout balloons; the editor's **grid-from-drawing** detector (`web/grid-core.js`
233
- `gridFromDrawing`) anchors grid lines to them, so skipping circles silently disables the Grid
234
- panel's "From drawing" button.
291
+ `{ kind:"circle", layer:<OCG name>, cx:<centre x>, cy:<centre y>, r:<radius> }` in display space.
292
+ These are the grid bubbles and callout balloons; the editor's **grid-from-drawing** detector
293
+ (`web/grid-core.js` `gridFromDrawing`) anchors grid lines to them, so skipping circles silently
294
+ disables the Grid panel's "From drawing" button. **Carry `layer` on the circle too** — the schema
295
+ allows it, and it is what lets you tell a grid bubble from a callout balloon later. It is not what
296
+ makes §0's scoping possible: that predicate filters *lines* by layer and keeps **every** circle
297
+ unconditionally, precisely so a layer guess can never strand the detector without an anchor.
235
298
  3. **Per-sheet entry** — push `{ sheet:<number>, title:<name?>, page:{ w, h, bg_b64, rect }, steelBbox,
236
299
  elements:[…] }` onto `filter.sheets`. `bg_b64` is a dimmed raster of THIS sheet's framing area
237
300
  (**title block excluded** — CONFIDENTIAL, machine-local, never committed). **`page.rect` = the exact
@@ -275,6 +338,27 @@ native/display coords):
275
338
  the root `datum` block — the per-sheet registration in §1d is still yours to write**, and a migrated
276
339
  model usually has none of it yet. Everything else in this section is unchanged.
277
340
 
341
+ **Watch the payload — the write is capped at 25 MB and the filter block dominates it.** A framing plan
342
+ carries tens of thousands of elements; three sheets land in the low tens of MB and a larger set will
343
+ blow the cap outright, on either route above. Check the serialized size before you send, and if it is
344
+ close:
345
+
346
+ - **Exclude the title-block xref wholesale.** It is thousands of glyph strokes, it is never steel, and
347
+ it is CONFIDENTIAL anyway — dropping it is the right call regardless of size. Identify it as the
348
+ layer family living in the sheet-edge strip, not by name.
349
+ - **Trim coordinate precision** in the path strings to ~0.1 pt. At any realistic drawing scale that is
350
+ far finer than the linework, and it removes a large fraction of the bytes.
351
+ - Keep the per-sheet `bg_b64` raster modest — it is a dimmed backdrop the viewer renders at low
352
+ opacity, not a document scan.
353
+
354
+ **Size the trim against the LARGEST write, which is not this one.** The same 25 MB cap applies to the
355
+ `POST …/revision-read` commit in §9 — and that document carries this whole `filter` block *again*,
356
+ plus every member and any rasters. A set trimmed to just fit here will blow the cap at commit, which
357
+ is the one write with no second chance. Budget for that document.
358
+
359
+ Say what you excluded. Never trim by dropping *elements* to fit — that silently removes candidate
360
+ members and defeats the filter.
361
+
278
362
  ### 1c. Grid lines — read the printed grid (quick, per sheet)
279
363
 
280
364
  > **`steel.model/v2` models: SKIP this section for the PRE-READ pass — but carry the grid in the
@@ -540,9 +624,50 @@ Follow the methodology condensed here (full detail + every gotcha in
540
624
  tile's display origin and extent.
541
625
  3. **Geometry (exact).** `page.get_drawings()` → keep member-scale line segments (~8–45 ft) in
542
626
  display coords, tagged H/V/D. These are the candidate members and the snap targets.
543
- 4. **Labels (vision — parallel subagents).** Read section labels per tile; each subagent returns
544
- **normalized fractions [0..1]** (not pixel coordinates — pixels from a subagent are
545
- scale-ambiguous) plus orientation (`H`/`V`/`D`). Convert to display, dedup.
627
+ 4. **Labels — three sources, applied in order to WHATEVER EACH LABEL IS. They are not per-sheet modes.**
628
+ One sheet routinely mixes them (live text in a schedule block, outlined glyphs on the framing), so
629
+ run them as successive passes over the same sheet and never let the first one end the step:
630
+ 1. **Live text spans** — where `page.get_text("dict")` returns real spans, you already have the
631
+ string AND an exact bbox; take them, no vision pass needed for *those* labels. Keep the line's
632
+ direction (`line.dir`, or recover the quad) — a span bbox alone loses the orientation of rotated
633
+ text, and vertical labels are normal on a framing plan.
634
+ 2. **Outlined glyphs (the usual case)** — for every label the first pass did **not** cover, the text
635
+ is drawn as paths, so it is present in the vector data as a cluster of tiny glyph strokes.
636
+ Harvest those instead of asking vision where the label is; you get an **exact** bbox, orientation
637
+ and centre for free, and the read becomes text-only. That is the procedure below.
638
+ 3. **No vector text at all (a scan)** — the positional fallback at the end of this step, for
639
+ whatever the first two passes still left unread.
640
+
641
+ **Whichever sources a sheet uses, the dedicated skew / `D`-segment pass below is still mandatory.**
642
+ It is about geometry, not about how the text is stored, and it is the most-skipped step in this
643
+ section — reaching step 5 with live text in hand is not a reason to have skipped it.
644
+ 1. **Find the right layer, and verify it.** The label layer is a *hypothesis* exactly like a member
645
+ layer (§0). A name containing the member type (`*ANNO-BEAM*`) very often holds the beam **end
646
+ symbols** — connection arrowheads and diamonds — while the sizes sit on the plan's generic
647
+ `*ANNO-TEXT*`. **Render ~20 clustered runs from the candidate layer as a montage and confirm
648
+ they are text before building anything on it.** Thirty seconds; it fails loudly instead of
649
+ silently binding arrowheads to beams.
650
+ 2. **Cluster glyph strokes into runs.** Union-find over glyph bounding boxes, merging when the
651
+ horizontal and vertical gaps each fall under **their own** threshold (start at x ≈ 1 × glyph
652
+ height, y ≈ 0.5 × glyph height — one scalar for both axes cannot separate a wide label from two
653
+ stacked ones). Tune by the resulting histograms, not by guesswork: too small and `W16x26` splits
654
+ into `W1` + `6x26`; too large and two neighbouring labels merge. Check **both** — the width
655
+ histogram should show a clear mode at one-label width, and the **height** histogram a mode at one
656
+ text line. Width alone cannot see the commonest merge on a framing plan: a size above the beam
657
+ line and another below it, fusing into a normal-width, double-height run.
658
+ 3. **Montage and read row-major.** Crop each run, rotate vertical runs upright, and tile them into a
659
+ fixed grid (e.g. 5 columns × 9 rows). One vision pass reads ~45 labels. Index is `row*cols + col`
660
+ by construction, so the text binds back to an exact position with **no coordinate translation and
661
+ no normalized fractions to convert**. Chunk into several images if there are many runs.
662
+ 4. This same montage pattern reads **grid-bubble marks**, **callout numbers and target sheets**, and
663
+ **title-block sheet numbers for the whole set** (crop every sheet's title block, tile, read once
664
+ — that is the sheet index in one pass). Prefer it anywhere you need many small texts.
665
+
666
+ *Only on the third branch — no vector text at all* (a scan) — fall back to tiling the framing area
667
+ and reading labels positionally. **That is the one case where a reader reports a position**, and it
668
+ must be as **normalized fractions [0..1]**, never pixels, which are scale-ambiguous once an image is
669
+ downscaled. On the montage path no position is ever reported: it comes from the run's own bbox and
670
+ the tile index.
546
671
  - **Skew bays get their OWN dedicated pass — they are the most-skipped members.** A skewed/angled
547
672
  framing bay read together with the orthogonal grid loses its diagonal members (the orthogonal
548
673
  pass "swallows" them, and free-hand label positions don't bind to the diagonal lines).
@@ -563,11 +688,46 @@ Follow the methodology condensed here (full detail + every gotcha in
563
688
  pile of unbound `D` segments means skew is still missed.
564
689
  5. **Bind** each label to the nearest matching segment (within tolerance, orientation penalty on
565
690
  mismatch). **Bind `D` labels to `D` segments** (don't let a diagonal label grab a nearby
566
- orthogonal grid line). Segments that remain unbound are the coverage queue (the human's markup
567
- worklist) — a pile of unbound `D` segments means skew was missed; go back to step 4.
568
- 6. **Work-point extend.** Extend each bound segment's drawn-short ends to the centerline
569
- intersection of connecting members (line–line intersection, capped reach). This closes joints
570
- and is skew-proof.
691
+ orthogonal grid line). Assign **greedily by ascending distance**, so a near-miss cannot steal a
692
+ segment that another label owns outright.
693
+ - **One-to-one applies PER ANNOTATION TYPE, not per segment.** At most one competing *profile
694
+ size* may win a segment — but a segment legitimately carries a size **and** an `MF`/`BF` mark,
695
+ a detail tag, a connection note and an elevation callout at the same time (step 8's dedupe rule
696
+ exists precisely because "a W-size + its `MF` mark" bind to the same line). A blanket
697
+ one-label-one-segment rule silently discards whichever of those two arrives second.
698
+ - **Nearest-wins is unsafe between close parallels — flag, don't guess.** A label sitting between
699
+ two parallel members binds to whichever is marginally closer, and "marginally" is often a couple
700
+ of px. Treat a binding as **ambiguous whenever the runner-up segment is within ~2× the winning
701
+ distance** and the two candidates are parallel. Do not silently take the nearest: resolve it by
702
+ evidence (which member does the label's leader touch? which one has no other label?) or leave the
703
+ member unbound for the coverage queue. A confidently wrong size is worse than an RFI.
704
+ - **A member whose ONLY label is a mark** (`MF`/`BF`, a frame member with no printed size) should be
705
+ resolved from the **schedule or elevation by grid geometry** — geometry against a named grid line
706
+ is stronger evidence than proximity to a text run. **But this does not outrank a printed size:**
707
+ where the plan prints a W-size on the beam, §0's rule stands — read the printed size and keep the
708
+ mark as `mf: true`. (The scorer agrees: `mf: true` marks the **profile** factor as
709
+ schedule-assumed — it does not touch the elevation factor, which depends only on `tosDef` — and
710
+ that alone caps an otherwise-high member at **med**. So preferring the schedule where the plan
711
+ states the size both contradicts §0 and costs confidence.)
712
+ - Segments that remain unbound are the coverage queue (the human's markup worklist) — a pile of
713
+ unbound `D` segments means skew was missed; go back to step 4.
714
+ 6. **Work-point extend — ALONG THE MEMBER'S OWN AXIS, never toward a nearby line.** Extend each bound
715
+ segment's drawn-short ends to the centerline intersection of connecting members: intersect the
716
+ member's **infinite line** with the other member's infinite line and move the endpoint to that
717
+ parameter along its own direction vector (capped reach). This closes joints and is skew-proof.
718
+ - **Never snap an endpoint to the nearest point on another line.** That moves the end *laterally*,
719
+ pivoting the member off the line it was drawn on. It looks identical on screen, but it severs the
720
+ geometric link between the member and the filter linework it came from. The guard tests two
721
+ things — near-zero cross product (parallel within a few degrees) **and every filter endpoint
722
+ within a couple of px of the member's line** — and it is the second that a lateral snap trips,
723
+ long before the angular one does. Do not reassure yourself with the angle: a sub-degree rotation
724
+ on a long member is already several px of offset at the far end. Preserve the direction vector
725
+ and both checks pass for free.
726
+ - **You do not have to wait for the commit to find out.** `POST …/score` returns
727
+ `filterMismatchCount` and up to ten `filterMismatchSamples` (`{id, sheet}`) — the same count the
728
+ revision-read guard rejects on. Check it **before** you post: a non-zero count is that rejection,
729
+ one step earlier and with the offending member ids. Only if you skip that check does this surface
730
+ as "member line(s) not backed by the saved Steel Filter selection" at commit.
571
731
  7. **AISC lookup for weights — look up EVERY distinct designation; NEVER read the weight off the name.**
572
732
  Call the `steel-detailer-us` agent's `lookup` verb for **every** distinct profile in the takeoff →
573
733
  `plf`, and build `weights: { profile → plf }`. Do **not** derive plf from the designation: the trailing
@@ -601,8 +761,17 @@ Follow the methodology condensed here (full detail + every gotcha in
601
761
  `~/.aware` rules can vanish on agent re-update (gotcha §6); if every member comes back weightless,
602
762
  restore `rules/aisc-shapes-v15.json` into the installed agent dir.
603
763
  8. **Dedupe coincident members — by FOOTPRINT *and* ORDERED ELEVATION, never by footprint alone.**
604
- Two labels binding the same segment (a W-size + its `MF` mark, or overlapping tile reads) emit
605
- coincident members that double-count the BOM. But two members can legitimately share a footprint —
764
+ **First, don't create the duplicate: MERGE the annotations, then dedupe what is left.** Step 5 binds
765
+ a size, a mark, a detail tag and a connection note to the *same* segment on purpose — emit them as
766
+ **one** member carrying all of those facts (`profile` *and* `mf: true`), never one member per label.
767
+ This matters because the deduper **deletes** the losing id rather than merging it: emit a `W16x26`
768
+ member and a separate `MF` member on one line and "a real profile beats an `MF`/blank" drops the
769
+ `MF` member outright, silently losing `mf: true` — which is supposed to be persistent and survive
770
+ AISC resolution. Dedupe is for genuinely coincident *members* (overlapping tile reads, repeated
771
+ passes), not for annotations of one member.
772
+
773
+ What remains after that merge still needs deduping: overlapping tile reads emit coincident members
774
+ that double-count the BOM. But two members can legitimately share a footprint —
606
775
  a beam stacked over a beam, and (critically) **the two legs of an X-brace, which project onto the
607
776
  same plan line**. Collapsing on work-points alone silently destroys one of them. Use the exact rule
608
777
  the editor and server use (`redundantDups` / `redundantDupIds`):
@@ -660,13 +829,17 @@ Follow the methodology condensed here (full detail + every gotcha in
660
829
  note. The invariant is the ORDER: find the callouts, fit the surface, then place members.
661
830
 
662
831
  **Hard-won gotchas (from the guidance spec § 6 — do not skip these):**
663
- - **Text is outlined, not real text.** `get_text()` returns almost nothing. Everything textual
664
- needs vision.
832
+ - **Text is usually outlined, not real text.** On most sets `get_text()` returns almost nothing and
833
+ everything textual needs vision. **Check rather than assume** — some sets do ship live spans, and
834
+ where they exist they are exact and free (step 4, first branch). Never *conclude* from an empty
835
+ `get_text()` on one sheet that the whole set is outlined.
665
836
  - **Pages may be rotated (e.g. 270°).** Work entirely in display space via
666
837
  `page.rotation_matrix`. Never mix native/display coords — this is the single biggest source of
667
838
  misplaced members.
668
- - **Subagent reads must return normalized fractions, one pass, no sub-cropping.** Pixel coords
669
- from a subagent collapse after downscaling.
839
+ - **When a subagent reports a POSITION — the scan-only fallback of step 4 — it must be normalized
840
+ fractions, one pass, no sub-cropping.** Pixel coords from a subagent collapse after downscaling.
841
+ The live-text and montage branches of step 4 are exempt: neither asks a reader for a position at
842
+ all (it comes from the span/run bbox and the tile index), and the montage path sub-crops by design.
670
843
  - **`MF` / `BF` are marks, not profiles.** No AISC section until resolved from Frame Elevations
671
844
  by grid + level. Leave as `rfi` and `mf: true` until auto-resolved or the user picks.
672
845
  - **AISC rules can vanish.** Verify `steel-detailer-us` with a known section before a full run
@@ -773,9 +946,41 @@ plans could claim it. Emit it **exactly once**:
773
946
  - else the **upper** level's plan if usable, with `floor:'below'`;
774
947
  - else **no member** — a `read_notes` entry.
775
948
 
776
- *Usable* means that plan's own filtered `S-COLS*` linework resolves a column footprint at **each** end
777
- grid, registered to its grid. It does **not** mean the plan owns a column *member* — a column is stored
778
- once as a single continuous member, so most plans legitimately hold none.
949
+ *Usable* means **both** of these hold on that plan:
950
+
951
+ 1. its own filtered `S-COLS*` linework resolves a column footprint at **each** end grid, registered to
952
+ its grid — it does **not** mean the plan owns a column *member*, since a column is stored once as a
953
+ single continuous member and most plans legitimately hold none; **and**
954
+ 2. its own filtered linework contains a **line running along the brace's plan work-line** — in
955
+ practice the brace-frame beam the X sits under.
956
+
957
+ **Condition 2 is the one that gets missed, and on a v1 contract it is the one the server enforces.** A
958
+ vertical brace is `role:'beam'`, so the revision-read guard requires a saved filter segment backing its
959
+ work-line — a plan that has the columns but draws no beam along that line (a foundation plan, typically)
960
+ will resolve condition 1, pass your own checks, and then be **rejected at commit** with "member line(s)
961
+ not backed by the saved Steel Filter selection". Check `filterMismatchCount` from `POST …/score` first
962
+ (§3) and you see it before the commit does. When the lower level fails condition 2, that is exactly what
963
+ the `floor:'below'` fallback is for: own the brace on the upper plan, which does draw the beam.
964
+
965
+ **Two limits on that enforcement — do not treat the guard as your only check.**
966
+ - **The member-to-filter half does not cover `steel.model/v2`.** The scoring route refuses v2, and the
967
+ backing test walks `plans[].members`, whereas a v2 model keeps members at the root — so
968
+ `filterMismatchCount` is always 0 there and no server check ties a v2 member to the linework.
969
+ (Filter *presence* is still enforced on both: `filterMissing` reads the top-level `contract.filter`.)
970
+ On the v2 arm of §9 the visual verification of §2c is not a nicety, it is the only check that the
971
+ members match the drawing.
972
+ - **It skips short members.** A plan line under the guard's minimum filter-segment length (~35 px) is
973
+ neither backed nor flagged, so a brace in a narrow bay is unverified either way.
974
+
975
+ **Before you conclude a plan fails condition 2, confirm the beam is absent from the DRAWING** — not
976
+ merely from the *kept selection*. The test runs against the saved filter segments, so a brace-frame beam
977
+ that is plainly drawn still fails it when its layer was switched off in §1b, or when it is drawn as
978
+ dash-dot strokes each under the length minimum. That is a filter-selection gap, fixed in §1b — never a
979
+ reason to drop the brace. Dropping a real member is the more expensive error: the fall-through below
980
+ emits **no member at all**.
981
+
982
+ Generalise the principle: **any derived member must be owned by the plan whose linework actually
983
+ contains its plan line**, not merely by the plan that is conceptually "below" it.
779
984
 
780
985
  **Emit a `read_notes` entry and NO member** when the end grids are absent from `plan.grid`, when no plan
781
986
  resolves a column centre at an intersection, when the upper level is `VARIES` and the sheet's `T.O. STEEL`
@@ -788,6 +993,45 @@ BOM. Key each note `brace:<id> — <reason>`, rebuild them from the source on **
788
993
  that have become resolvable — never carry a stale note forward), and **state them in the hand-off**
789
994
  (step 6): nothing else surfaces `read_notes` to the user.
790
995
 
996
+ ### 2c. VERIFY THE READ BY LOOKING AT IT — mandatory, before you assemble anything
997
+
998
+ Everything above is inference: layer → kind, label → member, mark → size. Numeric checks confirm a
999
+ contract is *well-formed*; they cannot tell you it is *right*. The only check that catches a label on
1000
+ the wrong beam, a dimension arrow modelled as a brace, or a whole layer silently missing is rendering
1001
+ what you built on top of what the drawing shows and reading it.
1002
+
1003
+ **Do this before §3 scoring and before the member-read write (§5 / §9).** It does **not** defer the
1004
+ earlier writes: §1b's filter block and §1c/§1d's grid and datum are upstream of the member read and are
1005
+ mandatory before it — this section cannot run until members exist. It costs one render and one look per
1006
+ region.
1007
+
1008
+ 1. For 2–3 representative regions of **each** plan — include at least one dense/typical bay and one
1009
+ irregular area (skewed wing, joint, stair, roof step) — render the source sheet as the background.
1010
+ 2. Draw **every member you built** in that region over it: the work-line, and its resolved profile
1011
+ printed at the midpoint in a small box. Use one colour for resolved, a contrasting one for RFI /
1012
+ unbound, and a third for derived members (braces) that have no label of their own.
1013
+ 3. **Read the image.** Every printed profile must match the drawing text lying beside that same line.
1014
+ You are looking for four specific failures:
1015
+ - a printed size that disagrees with the adjacent text → **label bound to the wrong member**;
1016
+ - a drawn member with no line under it → **fabricated or mis-extended geometry**;
1017
+ - a drawing line that reads as a framing member with no member drawn over it → **a dropped layer
1018
+ or a missed bind**;
1019
+ - a member sitting on a dimension string or leader → **census failure (§0)**.
1020
+ 4. Fix and re-render until the region reads clean. **Say in the hand-off that you did this and what
1021
+ you checked** — "verified N regions across M sheets" is a real statement about the read's quality;
1022
+ an aggregate score without it is not.
1023
+
1024
+ Do the same for any **derived** geometry (vertical braces, columns placed from clustered footprints).
1025
+ Derived members are the ones no label will ever contradict, so a visual check is the *only* check they
1026
+ get — and for a **vertical brace that means TWO checks, against two different drawings**, because the
1027
+ brace is drawn on a frame elevation while it is *owned* by a plan (§2b):
1028
+
1029
+ 1. against its **brace-frame elevation** — topology, profile and end elevations;
1030
+ 2. against the **plan** — its projected work-line lands on the plan line that owns it, and that line is
1031
+ present in the saved filter selection (§2b condition 2).
1032
+
1033
+ Rendering a brace only over the plan checks the second and silently assumes the first.
1034
+
791
1035
  ### 3. Honor `target_confidence` — score, then LOOP to the goal
792
1036
 
793
1037
  Read the app's `target_confidence` input (default 70). The user may also set a **per-read override**
@@ -805,7 +1049,10 @@ the server, never by eyeballing. Per-member bands (full method in
805
1049
  Aggregate = the **tons-weighted** average of those band weights over the non-RFI members (RFI are
806
1050
  excluded from the average and counted separately as the headline drag).
807
1051
 
808
- **The score endpoint is your gauge — call it, don't guess:**
1052
+ **The score endpoint is your gauge — call it, don't guess.** *(v1 documents only: the route refuses
1053
+ `steel.model/v2` rather than answering about a model it cannot read. On the v2 arm of §9 there is no
1054
+ score to loop against — hold yourself to §2c's visual verification and the §6 hand-off instead of
1055
+ looping on a number.)*
809
1056
 
810
1057
  ```
811
1058
  POST http://localhost:<port>/api/contract/steel-model/score?project=<projectId>
@@ -820,8 +1067,11 @@ did not ask about, returned with no error. This route is the gauge the read-loop
820
1067
  STOP reading, so a confident number about the wrong model is the worst possible answer. It is safe to
821
1068
  omit only when there is genuinely no project.
822
1069
 
823
- Returns `{ score, target, meetsTarget, gap, rfiCount, counts, worklist, filterMissing }` — the SAME
824
- aggregate the editor's Confidence chip shows. `worklist` is the rfi/low/med members dragging the score,
1070
+ Returns `{ score, target, meetsTarget, gap, rfiCount, counts, worklist, filterMissing,
1071
+ filterBackedMembers, filterMismatchCount, filterMismatchSamples }` — the SAME aggregate the editor's
1072
+ Confidence chip shows. **The last three are your pre-flight for the §9 commit**: `filterMismatchCount`
1073
+ is exactly what the revision-read guard refuses on, and `filterMismatchSamples` names up to ten
1074
+ offending members, so a non-zero count here is a commit rejection you can still fix cheaply. `worklist` is the rfi/low/med members dragging the score,
825
1075
  worst-first (heaviest first within a band), each with a `reason`. (Omit `contract` to score the stored
826
1076
  one — that is the read the `?project=` scope governs.)
827
1077
 
@@ -908,7 +1158,7 @@ Important optional fields:
908
1158
  "role": "column",
909
1159
  "rot": 0,
910
1160
  "rfi": false,
911
- "col": { "bos": 0, "tos": 198, "note": "", "detail": "" }
1161
+ "col": { "bos": 0, "tos": 198, "tosDef": false, "note": "", "detail": "" }
912
1162
  },
913
1163
  {
914
1164
  "id": "vb-<detail>-<grid>-<endA>_<endB>-<lo>_<hi>-a", // one leg of an X; its partner is …-b with the elevations transposed
@@ -958,6 +1208,29 @@ Key field rules:
958
1208
  - Elevations are **decimal inches** (canonical); the editor accepts/displays ft-in strings.
959
1209
  `tosDef: false` means the value came from a drawing callout; `true` means it follows the plan
960
1210
  default.
1211
+ - **A COLUMN carries its own flag: `col.tosDef`, and it is a SWITCH, not an annotation.** Get this
1212
+ one wrong and you lose the number, not just a confidence point.
1213
+ - **Emit `col.tosDef: false` whenever `col.tos` carries an explicit read value — near callout or
1214
+ distant, it makes no difference.** On the v1→v2 conversion (§9), a `tosDef` that is anything
1215
+ other than `false` makes the migration **substitute the sheet's `default_tos` and never read
1216
+ your `col.tos` at all** — and if the sheet declares no `default_tos`, the elevation lands
1217
+ `unknown`. A column whose top you actually read then ships at the wrong height, silently, into
1218
+ the model, the 3D view and the BOM.
1219
+ - **Emit `true` only when you emit no `tos` at all** and the top genuinely rides the plan default.
1220
+ That is what the surrounding rule already says — `false` = came from a drawing callout,
1221
+ `true` = follows the plan default — and it is about the **top only**.
1222
+ - **`bos` is not governed by this flag.** The migration always treats `col.bos` as authored, so
1223
+ how well-sourced the base is has no bearing on `tosDef`. Condition it solely on where the top
1224
+ came from.
1225
+ - *Then* the confidence effect, which is the smaller reason to care: the scorer reads
1226
+ `ends[].tosDef` for beams and `col.tosDef` for columns, and treats a column's elevation as
1227
+ *assumed* unless `col.tosDef` is explicitly `false` — worklist reason naming it a plan default
1228
+ (currently "plan default (UNO) — no local callout"). That makes an otherwise resolved,
1229
+ unverified, non-duplicate column band **med** rather than high; a `verified` flag, an RFI
1230
+ profile or a duplicate footprint still take precedence. The aggregate is tonnage-weighted, so
1231
+ the cost scales with the column share of the takeoff.
1232
+ - Say which rule you used in `read_notes`, e.g. "column tops taken from the nearest T.O. STEEL
1233
+ callout within N ft; beyond that, the plan default (emitted with no `tos`)".
961
1234
  - `rfi: true` means no AISC size resolved — excluded from the BOM. `mf: true` marks a
962
1235
  moment-frame member (persistent; survives AISC resolution).
963
1236
  - **`read_notes` (top-level `string[]`) is where what you could NOT resolve goes.** An ambiguous label,
@@ -1258,13 +1531,35 @@ one store and precondition the other.
1258
1531
 
1259
1532
  ### 6. Hand off to the user
1260
1533
 
1261
- **Precondition:** `POST …/score` returns `filterMissing: false` (the Filter node was baked in 1b and the
1262
- member read bound to it). If it's still `true`, you are not done — return to step 1b. Do not present a
1263
- takeoff whose filter was skipped as finished.
1534
+ **Preconditions — both, not either:**
1535
+ 1. The filter is present and the member read is bound to it. **How you establish that depends on the
1536
+ contract type, because `/score` refuses v2** (§3) — do not call it and read a refusal as a pass:
1537
+ - **`steel.takeoff/v1`** — `POST …/score` returns `filterMissing: false` **and
1538
+ `filterMismatchCount: 0`**. If `filterMissing` is still `true`, you are not done: return to step
1539
+ 1b. A non-zero `filterMismatchCount` is the §9 commit rejection arriving early — read
1540
+ `filterMismatchSamples` and fix those members (§2 step 6, §2b) before handing off.
1541
+ - **`steel.model/v2`** — there is no score call to make. Confirm the contract carries a usable
1542
+ top-level `filter` yourself, and hold it to **a non-empty `filter.sheets[]`** — what §1b produces.
1543
+ *That is stricter than the guard*, deliberately: the guard's `filterMissing` is satisfied by a
1544
+ non-empty `sheets[]` **or** a legacy single-page `filter.page`, so a pre-multisheet contract slips
1545
+ through it while still being below this skill's standard. If you find only `filter.page`, re-run
1546
+ §1b and emit the per-sheet block rather than passing it along. There is no v2 equivalent of
1547
+ `filterMismatchCount` — the backing test walks `plans[].members`, which a v2 model does not have —
1548
+ so **nothing server-side ties a v2 member to the linework** and precondition 2 carries that weight
1549
+ alone.
1550
+
1551
+ Either way: do not present a takeoff whose filter was skipped as finished.
1552
+ 2. The **visual verification of §2c has been done** and the regions read clean. A score is a statement
1553
+ about evidence *recorded*, not evidence *correct* — do not hand off a takeoff you have not looked at.
1264
1554
 
1265
1555
  Tell the user:
1266
1556
  - What you read (e.g. "read 14 beams, 6 columns and 9 braces on the two framing plans; 3 MF members
1267
1557
  await Frame-Elevation resolution; aggregate confidence 78% — above your 70% target").
1558
+ - **What you verified and how** — the regions you rendered and checked (§2c), and any binding you
1559
+ resolved by evidence rather than proximity. This is what separates "the numbers look fine" from
1560
+ "I looked at it".
1561
+ - **Which layers you kept, dropped, or found to hold no members** (§0 census), in one line each. A
1562
+ steel-named layer that turned out to be dimensions or legend glyphs is a result the user needs.
1268
1563
  - **Every `read_notes` entry, in plain English** — what could not be resolved and why (an unplaceable
1269
1564
  brace, a missing half-grid, an unsupported brace topology). Nothing in the UI shows `read_notes`, so
1270
1565
  this hand-off is the only place the user learns what was left out. Never let an omission pass silently.
@@ -39,7 +39,17 @@ const parseInches = (raw) => {
39
39
  return NaN;
40
40
  };
41
41
 
42
- /** mm per display px for a plan scale (matches steel-3d-core kOf). */
42
+ /**
43
+ * mm per display px for a plan scale — THE one implementation of the plan display scale.
44
+ *
45
+ * It lives in this leaf module because five copies of `FT_MM / (ptPerFt > 0 ? ptPerFt : 1)` had grown
46
+ * (here, steel-3d-core's `kOf`, steel-model-adapter's and steel-model-commands' `scaleOf`, and inline
47
+ * in steel-plan-transform and server/contract-to-scene), each carrying a comment telling the next
48
+ * reader to keep it in lock-step with the others by hand. They all import this now.
49
+ *
50
+ * A missing, zero or negative `pt_per_ft` reads as 1 pt/ft rather than dividing by it, so an
51
+ * unscaled sheet degrades to a 1:1 map instead of putting Infinity or a mirrored scale into geometry.
52
+ */
43
53
  export const mmPerPx = (ptPerFt) => FT_MM / (ptPerFt > 0 ? ptPerFt : 1);
44
54
 
45
55
  /** One length token → mm, or NaN. Accepts 25' | 25'-6 1/2" | 6 1/2" | 1/2" | 7.5m | 6096 (mm) | 6096mm; leading '-' negates. */
@@ -11,6 +11,8 @@
11
11
  * needs it).
12
12
  */
13
13
 
14
+ import { mmPerPx } from './grid-core.js';
15
+
14
16
  export const FT_TO_MM = 304.8;
15
17
  export const IN_TO_MM = 25.4;
16
18
 
@@ -124,15 +126,17 @@ export function projectedFootprintHitsRect2d(points, rect, windowMode) {
124
126
  return true;
125
127
  }
126
128
 
127
- const kOf = (ptPerFt) => FT_TO_MM / (ptPerFt > 0 ? ptPerFt : 1);
128
-
129
129
  const nz = (n) => n + 0; // normalize -0 → 0 (negating 0 yields -0, which surprises equality checks)
130
130
 
131
- /** display-space wp point → scene mm [x,y] (Y flipped, matching contractToScene.dispToMm). */
132
- export function dispToMm(pt, ptPerFt) { const k = kOf(ptPerFt); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
131
+ /**
132
+ * display-space wp point → scene mm [x,y] (Y flipped). THE one display→mm conversion: the adapter and
133
+ * server/contract-to-scene each used to carry their own copy of `[x·k, -y·k]`, with a comment on each
134
+ * naming the others as mirrors to keep by hand.
135
+ */
136
+ export function dispToMm(pt, ptPerFt) { const k = mmPerPx(ptPerFt); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
133
137
 
134
138
  /** scene mm point [x,y,…] → display-space wp [px,py] (inverse of dispToMm). */
135
- export function planPointToWp(p, ptPerFt) { const k = kOf(ptPerFt); return [nz(p[0] / k), nz(-p[1] / k)]; }
139
+ export function planPointToWp(p, ptPerFt) { const k = mmPerPx(ptPerFt); return [nz(p[0] / k), nz(-p[1] / k)]; }
136
140
 
137
141
  /**
138
142
  * The px→ft scale and default T.O.S of the plan that OWNS a member, resolved from the SAME per-plan
@@ -878,7 +882,7 @@ export function selectedLengthLabelAnchors(labels, members, geometryOf) {
878
882
  * Snap targets from v2 members — the v2 sibling of `snapCandidates`, emitting the identical record shapes
879
883
  * so `snapPoint`'s precedence table and `candidatePoint` need no v2 case.
880
884
  *
881
- * WHY THIS IS NOT `snapCandidates(members, 304.8, 0, excludeId)`. That nearly works — `kOf(304.8)` is 1 —
885
+ * WHY THIS IS NOT `snapCandidates(members, 304.8, 0, excludeId)`. That nearly works — `mmPerPx(304.8)` is 1 —
882
886
  * and is wrong twice: it would still negate Y (v2 coordinates are already world), and it would still read
883
887
  * `m.wp`/`m.col`/`m.ends`, which a v2 member does not have. A v2 member routed through the v1 function
884
888
  * does not throw; it yields NaN candidates that snap silently to nowhere. Silence is the failure mode.