@floless/app 0.137.4 → 0.138.1

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.
Files changed (47) hide show
  1. package/dist/floless-server.cjs +48371 -27278
  2. package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
  3. package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
  4. package/dist/schemas/steel.model.v2.schema.json +218 -27
  5. package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
  6. package/dist/skills/floless-app-rfi/SKILL.md +410 -0
  7. package/dist/skills/floless-app-routines/SKILL.md +7 -2
  8. package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
  9. package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
  10. package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
  11. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
  12. package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
  13. package/dist/templates/floless-workspace-knowledge.flo +20 -4
  14. package/dist/templates/steel-model.flo +27 -15
  15. package/dist/web/app.css +559 -131
  16. package/dist/web/app.js +216 -54
  17. package/dist/web/aware.js +982 -128
  18. package/dist/web/checkpoint-standard.js +218 -0
  19. package/dist/web/commands-filter.js +23 -0
  20. package/dist/web/commands-shell.js +237 -5
  21. package/dist/web/commands-steel.js +172 -47
  22. package/dist/web/connection-review-client.js +2 -2
  23. package/dist/web/display-units.js +243 -0
  24. package/dist/web/grid-core.js +470 -56
  25. package/dist/web/grid-display.js +344 -0
  26. package/dist/web/index.html +106 -66
  27. package/dist/web/instructor-reporter.js +5 -0
  28. package/dist/web/instructor.js +175 -33
  29. package/dist/web/json-schema-subset.js +145 -25
  30. package/dist/web/steel-3d-core.js +124 -140
  31. package/dist/web/steel-3d-view.js +352 -100
  32. package/dist/web/steel-catalog-picker.js +98 -15
  33. package/dist/web/steel-detail-refs.js +1 -1
  34. package/dist/web/steel-editor.html +6458 -915
  35. package/dist/web/steel-filter.html +404 -57
  36. package/dist/web/steel-model-adapter.js +1 -1
  37. package/dist/web/steel-model-commands.js +71 -64
  38. package/dist/web/steel-model-v2-client-validation.js +10 -3
  39. package/dist/web/steel-model-v2-commands.js +268 -76
  40. package/dist/web/steel-model-v2-projection.js +18 -17
  41. package/dist/web/steel-plan-transform.js +13 -13
  42. package/dist/web/steel-plan-view-id.js +1 -7
  43. package/dist/web/steel-read-confidence.js +454 -5
  44. package/dist/web/steel-units.js +17 -3
  45. package/dist/web/steel-view-generation.js +21 -7
  46. package/dist/web/workspaces.js +2178 -497
  47. package/package.json +4 -1
@@ -5,21 +5,29 @@
5
5
  * lift into AWARE viewer-3d, while the native model geometry remains Steel-specific.
6
6
  *
7
7
  * Coordinate map MUST match server/contract-to-scene.ts (the bake) so editing-space == render-space:
8
- * scene is mm, Z-up. mmX = dispX·k, mmY = -dispY·k (k = FT_TO_MM / pt_per_ft, Y flipped),
9
- * mmZ = elevation_inches · IN_TO_MM. planPointToWp is the inverse (editing-only; the bake never
10
- * needs it).
8
+ * scene is mm, Z-up. mmX = dispX·k, mmY = -dispY·k (k IS the view's `mm_per_px`, Y flipped),
9
+ * mmZ = the MEMBER's own T.O.S/B.O.S, ALREADY in millimetres, and NOT the plan's `elevation_mm` cut
10
+ * plane. It used to be inches times IN_TO_MM, back when the editor ran an inches-canonical sub-world;
11
+ * there is no conversion on this axis any more. planPointToWp is the inverse (editing-only; the bake
12
+ * never needs it).
11
13
  */
12
14
 
13
- import { mmPerPx } from './grid-core.js';
15
+ import { sheetScaleMm } from './grid-core.js';
14
16
 
15
17
  // Defined once in the leaf `steel-units` module and re-exported here, because this file is the seam a
16
18
  // dozen consumers already import them from and `grid-core` (which this file imports) needs them too.
17
19
  // IMPORTED and then exported, NOT `export … from`: a pure re-export publishes the names without
18
- // creating local bindings, and this module USES both of them (memberGeometry, POSITION_OFFSET_SNAP_MM).
19
- // The first cut wrote the re-export form and every consumer still resolved them perfectly — while
20
- // memberGeometry threw `IN_TO_MM is not defined` at run time. The full suite found it; nothing smaller did.
21
- import { FT_TO_MM, IN_TO_MM } from './steel-units.js';
22
- export { FT_TO_MM, IN_TO_MM };
20
+ // creating local bindings, and this module USES them (FT_TO_MM in the level helpers, IN_TO_MM in
21
+ // POSITION_OFFSET_SNAP_MM). The first cut wrote the re-export form and every consumer still resolved
22
+ // them perfectly — while memberGeometry threw `IN_TO_MM is not defined` at run time. The full suite
23
+ // found it; nothing smaller did.
24
+ //
25
+ // `memberGeometry` was IN_TO_MM's other local caller until the editor went metric and its elevations
26
+ // stopped needing conversion. The remaining one below is a real quarter-INCH drag quantum, not a unit
27
+ // conversion in disguise — which is why it spells the constant rather than the number, and why this
28
+ // file leaves the geometry guard's literal ratchet at zero.
29
+ import { FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M } from './steel-units.js';
30
+ export { FT_TO_MM, IN_TO_MM, LB_PER_FT_TO_KG_PER_M };
23
31
 
24
32
  /** Atomic capability marker: storage, readers, authoring and shipped guidance advance together. */
25
33
  export const POSITION_BASIS_CAPABILITY_VERSION = 1;
@@ -163,19 +171,24 @@ export function reexpressMemberPlacement(member, refFrom, refTo, target, extents
163
171
  * `allowJs` without `checkJs`, so a typo'd entry (`['MC', 'c']`) or a malformed one still compiles —
164
172
  * verified. `section-kind.test.ts` validates the table's shape for that reason.
165
173
  *
166
- * Tees (`WT`/`ST`/`MT`) deliberately carry no entry: there is no 'T' kind, so they ride their parent
167
- * letter and draw as an I. That is the long-standing behaviour and is left exactly as it was — a tee
168
- * outline is its own change, not part of the prefix-shadowing fix below. Note that ADDING a tee entry
169
- * here WOULD silently take every `WT` away from 'I': "a new family cannot un-reach an existing one" is
170
- * about each family's own prefix still matching, not about the designations it currently attracts.
174
+ * There is no 'T' kind: a tee's real outline is its catalogue-supplied `displaySection` (the `tee`
175
+ * branch of `sectionTopology`), never this fallback classifier. So US `WT`/`ST`/`MT` carry no entry and
176
+ * ride their parent letter to 'I'; the UK tees `UKT`/`TEE` have no I-parent-letter to ride, so they need
177
+ * an explicit entry — mapped to 'I' for the SAME reason, the nearest drawable fallback for a tee with no
178
+ * displaySection. This is the fallback kind only; a resolved tee always draws from its displaySection.
179
+ * EHS carries no entry either: an ellipse has no member of the SectionKind union, so it stays BOX here
180
+ * and is refused as geometry upstream (`displaySectionForRow` → unsupported-custom), never drawn.
171
181
  *
172
182
  * @type {ReadonlyArray<readonly [string, SectionKind]>}
173
183
  */
174
184
  export const SECTION_FAMILIES = [
175
185
  ['W', 'I'], ['M', 'I'], ['S', 'I'], ['HP', 'I'], // US I-family
176
186
  ['UC', 'I'], ['UB', 'I'], ['UKC', 'I'], ['UKB', 'I'], ['IPE', 'I'], ['HE', 'I'], // UK/EU I-family
177
- ['C', 'C'], ['MC', 'C'], ['PFC', 'C'], // channels
178
- ['L', 'L'], // angles
187
+ ['UKBP', 'I'], // UK bearing pile (also rides UKB)
188
+ ['RSJ', 'I'], ['JUMBO', 'I'], // UK: Rolled Steel JOIST is an I; JUMBO heavy column
189
+ ['UKT', 'I'], ['TEE', 'I'], // UK tees ride to I like US WT/ST/MT — real tee outline is the displaySection's
190
+ ['C', 'C'], ['MC', 'C'], ['PFC', 'C'], ['UKPFC', 'C'], ['RSC', 'C'], // channels (UKPFC does NOT start with PFC)
191
+ ['L', 'L'], ['UKA', 'L'], ['RSA', 'L'], // angles (UK equal/unequal + legacy RSA)
179
192
  ['HSS', 'TUBE'], ['PIPE', 'TUBE'], ['TS', 'TUBE'], ['TUBE', 'TUBE'], ['HSQ', 'TUBE'],
180
193
  ['SHS', 'TUBE'], ['RHS', 'TUBE'], ['CHS', 'TUBE'], // hollow sections
181
194
  ];
@@ -364,6 +377,12 @@ export function projectPointOnSegment3d(p, a, b, rule) {
364
377
  return projectOnSegment(p, a, b, rule, 3);
365
378
  }
366
379
 
380
+ /** The visible frontmost solid is the only member a direct 3D command may act on. */
381
+ export function selectedFrontmostHit(hits, selectedId) {
382
+ const hit = Array.isArray(hits) ? hits[0] : null;
383
+ return hit?.object?.userData?.id === selectedId ? hit : null;
384
+ }
385
+
367
386
  /**
368
387
  * Convert a parameter measured along the projected screen segment back to the
369
388
  * linear parameter on its world segment. Perspective projection divides each
@@ -443,10 +462,10 @@ const nz = (n) => n + 0; // normalize -0 → 0 (negating 0 yields -0, which surp
443
462
  * server/contract-to-scene each used to carry their own copy of `[x·k, -y·k]`, with a comment on each
444
463
  * naming the others as mirrors to keep by hand.
445
464
  */
446
- export function dispToMm(pt, ptPerFt) { const k = mmPerPx(ptPerFt); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
465
+ export function dispToMm(pt, mmPerPx) { const k = sheetScaleMm(mmPerPx); return [nz(pt[0] * k), nz(-pt[1] * k)]; }
447
466
 
448
467
  /** scene mm point [x,y,…] → display-space wp [px,py] (inverse of dispToMm). */
449
- export function planPointToWp(p, ptPerFt) { const k = mmPerPx(ptPerFt); return [nz(p[0] / k), nz(-p[1] / k)]; }
468
+ export function planPointToWp(p, mmPerPx) { const k = sheetScaleMm(mmPerPx); return [nz(p[0] / k), nz(-p[1] / k)]; }
450
469
 
451
470
  /**
452
471
  * The section outline itself: local points centred on the origin, x = width, y = depth, closed, plus an
@@ -491,7 +510,7 @@ export function sectionOutlinePts(kind, w, d, thk) {
491
510
  // The `Math.min(…*0.5, …)` clamps are not decoration — the floors (6, 5) are FLAT minimums so an
492
511
  // ESTIMATED section still reads at small zoom, and on a small section at a coarse scale the floor
493
512
  // exceeds the section itself. Unclamped, the inner corner runs past the outline and the drawn footprint
494
- // comes out BIGGER than the member: an L4X4X3/8 at pt_per_ft 12 measured 5"x5" instead of 4"x4".
513
+ // comes out BIGGER than the member: an L4X4X3/8 at 12 pt/ft measured 5"x5" instead of 4"x4".
495
514
  const tf = real('tf', hd) ?? Math.min(d * 0.5, Math.max(d * 0.10, 6));
496
515
  const tw = real('tw', hw) ?? Math.min(w * 0.5, Math.max(w * 0.10, 5));
497
516
  return { outer: [[-hw, -hd], [hw, -hd], [hw, -hd + tf], [tw / 2, -hd + tf], [tw / 2, hd - tf], [hw, hd - tf],
@@ -524,7 +543,7 @@ export function sectionOutlinePts(kind, w, d, thk) {
524
543
  // `r` is returned ALONGSIDE the points and is not redundant: the polygon is INSCRIBED, so its widest
525
544
  // point between two vertices is `r·cos(π/ROUND_SEGMENTS)`. Measuring the points would put a pipe's flush
526
545
  // face a fraction inside its own steel, silently, at exactly the rolls where no vertex lines up with the
527
- // axis being measured. `sectionExtents` and `rolledExtent` read `r`; anything that DRAWS reads the points.
546
+ // axis being measured. `sectionExtents` reads `r`; anything that DRAWS reads the points.
528
547
  //
529
548
  // `kind` cannot be derived from the designation: `sectionKindOf` matches a literal prefix and answers
530
549
  // TUBE for `HSS6X6X3/8` (rectangular) and `HSS6.625X0.280` (round) alike — only the numerics separate
@@ -623,8 +642,8 @@ export function sectionTopology(displaySection, w, d, fallbackKind = 'BOX') {
623
642
  *
624
643
  * `fitScale` is the THIRD thing `worldToSheetPx` does and the easiest to forget, because it is 1 on every
625
644
  * well-registered sheet: it is the ratio between the distance the sheet's two controls actually span in
626
- * world and the distance their pixels imply at the sheet's stated `pt_per_ft`. A sheet registered at twice
627
- * its declared scale carries every work point at half the pixels — and an outline sized from `pt_per_ft`
645
+ * world and the distance their pixels imply at the sheet's stated `mm_per_px`. A sheet registered at twice
646
+ * its declared scale carries every work point at half the pixels — and an outline sized from `mm_per_px`
628
647
  * alone, as this one is, then draws the section at twice the size of the member it belongs to. (Found by
629
648
  * adversarial review; the first cut of this function dismissed it as a pre-existing sizing question, which
630
649
  * it was — right up until this became the one place that claims to map world into sheet px.)
@@ -636,92 +655,25 @@ export function sectionOutlinePx(pts, rotDeg, sheetRotRad = 0, fitScale = 1) {
636
655
  return pts.map(([x, y]) => [nz(x * cs - y * sn), nz(-(x * sn + y * cs))]);
637
656
  }
638
657
 
639
- /**
640
- * The px→ft scale and default T.O.S of the plan that OWNS a member, resolved from the SAME per-plan
641
- * list that feeds 3D snap candidates (`api.membersByPlan()`).
642
- *
643
- * Why it reads that list rather than taking the active plane's scale: 3D snap targets are built from
644
- * every sheet in each sheet's own scale, while a drag/endpoint commit used to invert through the
645
- * ACTIVE sheet's scale. Editing an off-active-sheet member whose sheet has a different `pt_per_ft` (or
646
- * a different `default_tos`) therefore wrote a mis-scaled `wp`. Sharing one source makes the target and
647
- * the commit incapable of disagreeing.
648
- *
649
- * `fallback` is used when the id is unknown (a not-yet-loaded contract, or a member outside the plan
650
- * list) so a lookup miss can never throw out of a pointer handler.
651
- */
652
- export function planScaleIndex(byPlan, fallback) {
653
- const ix = new Map();
654
- for (const pl of byPlan || []) {
655
- if (!pl || !Array.isArray(pl.members)) continue;
656
- const scale = {
657
- ptPerFt: pl.ptPerFt > 0 ? pl.ptPerFt : 1,
658
- defaultTosMm: pl.defaultTosMm != null ? pl.defaultTosMm : (fallback ? fallback.defaultTosMm : 0),
659
- };
660
- for (const m of pl.members) if (m && typeof m === 'object' && !ix.has(m)) ix.set(m, scale);
661
- }
662
- return ix;
663
- }
664
-
665
- /**
666
- * O(1) lookup into a `planScaleIndex`, keyed by the member OBJECT. Unknown member → `fallback`
667
- * (may be undefined; callers guard).
668
- *
669
- * Keyed by object, never by `m.id`: member ids are only SHEET-unique by contract — that is the whole
670
- * reason `contractWithExportScopedMemberIds` namespaces them for export and the editor keeps a separate
671
- * `planeOfMember` that resolves by identity. Keying this index by bare id would resolve the second of
672
- * two same-id members through the FIRST sheet's scale, which is the very class of bug this seam exists
673
- * to remove.
674
- */
675
- export function planScaleOf(index, member, fallback) {
676
- const s = index && typeof index.get === 'function' ? index.get(member) : null;
677
- return s || fallback;
678
- }
679
-
680
- /**
681
- * A member's centreline resolved through the plan that OWNS it.
682
- *
683
- * This composition is exported (rather than left inline in the view) so the OWNING-PLAN wiring is
684
- * unit-testable: asserting `planScaleOf`'s return value alone would still pass if a call site
685
- * regressed to the active sheet's scale, because the bug was never in the pure lookup — it was in
686
- * which scale got handed to `memberGeometry`.
687
- */
688
- export function memberGeometryInOwnPlan(m, index, fallback) {
689
- const s = planScaleOf(index, m, fallback) || { ptPerFt: 1, defaultTosMm: 0 };
690
- return memberGeometry(m, s.ptPerFt, s.defaultTosMm);
691
- }
692
-
693
- /**
694
- * Alt-drag T.O.S levels across EVERY sheet, each sheet resolved in its OWN default elevation.
695
- * Taking the active sheet's member list with some other sheet's default would report unset-T.O.S
696
- * members at an elevation they are not drawn at.
697
- */
698
- export function elevationLevelsByPlan(byPlan, fallback, excludeMember) {
699
- const set = new Set();
700
- for (const pl of byPlan || []) {
701
- if (!pl || !Array.isArray(pl.members)) continue;
702
- const dtos = pl.defaultTosMm != null ? pl.defaultTosMm : (fallback ? fallback.defaultTosMm : 0);
703
- // Exclude by OBJECT, not by id: ids are only sheet-unique, so excluding by id would silently drop
704
- // every same-id member on every other sheet from the level set.
705
- const members = excludeMember ? pl.members.filter((m) => m !== excludeMember) : pl.members;
706
- for (const z of elevationLevels(members, pl.ptPerFt, dtos, undefined)) set.add(z);
707
- }
708
- return [...set].sort((a, b) => a - b);
709
- }
710
-
711
658
  /**
712
659
  * member → its 3D centerline `{ kind, line:[[x,y,z],[x,y,z]] }` in mm, matching contractToScene's
713
660
  * from/to. Beam: work-line at T.O.S. Column: vertical at the plan point, bos→tos.
714
661
  */
715
- export function memberGeometry(m, ptPerFt, defaultTosMm = 0) {
716
- const a = dispToMm(m.wp[0], ptPerFt), b = dispToMm(m.wp[1], ptPerFt);
662
+ export function memberGeometry(m, mmPerPx, defaultTosMm = 0) {
663
+ const a = dispToMm(m.wp[0], mmPerPx), b = dispToMm(m.wp[1], mmPerPx);
717
664
  if (m.role === 'column') {
718
- const bos = m.col && m.col.bos != null ? m.col.bos * IN_TO_MM : 0;
719
- const tos = m.col && m.col.tos != null ? m.col.tos * IN_TO_MM : defaultTosMm;
665
+ // NO CONVERSION. These arrive in world millimetres now; they used to be the projection's inches and
666
+ // this was the multiplication back. It is the single most dangerous line in the metric change: a
667
+ // stale `* IN_TO_MM` here puts every column 25.4x too high in 3D while the contract stays correct,
668
+ // so nothing on screen looks like a unit bug — it looks like a modelling one. The projection's
669
+ // fields were RENAMED (`tos` -> `tosMm`) precisely so this site could not keep compiling unchanged.
670
+ const bos = m.col && m.col.bosMm != null ? m.col.bosMm : 0;
671
+ const tos = m.col && m.col.tosMm != null ? m.col.tosMm : defaultTosMm;
720
672
  return { kind: 'column', line: [[a[0], a[1], bos], [a[0], a[1], tos]] };
721
673
  }
722
674
  const e = m.ends || [];
723
- const z0 = e[0] && e[0].tos != null ? e[0].tos * IN_TO_MM : defaultTosMm;
724
- const z1 = e[1] && e[1].tos != null ? e[1].tos * IN_TO_MM : defaultTosMm;
675
+ const z0 = e[0] && e[0].tosMm != null ? e[0].tosMm : defaultTosMm;
676
+ const z1 = e[1] && e[1].tosMm != null ? e[1].tosMm : defaultTosMm;
725
677
  return { kind: 'beam', line: [[a[0], a[1], z0], [b[0], b[1], z1]] };
726
678
  }
727
679
 
@@ -1093,9 +1045,13 @@ export function dominantAxis3d(a, b, axesMap) {
1093
1045
  * merges, or refuses inconsistent registration — not implementation tuning. Revisit with data; never widen one to
1094
1046
  * make a demo pass.
1095
1047
  *
1096
- * The cut-plane quantum is the existing authoring quantum (grid-core's gridLevelKey rounds to 1/16").
1097
- * The de-dup distance is 1/4": measured column coincidence after removing the registration offset was
1098
- * 0.7 mm median / 1.76 mm worst, so ~3.6x headroom, and it stays far below any real member spacing.
1048
+ * The cut-plane quantum is 1/16" and it is JUSTIFIED BY THE MEASUREMENT, not by the authoring lattice:
1049
+ * column coincidence after removing the registration offset was 0.7 mm median / 1.76 mm worst, so
1050
+ * 1.5875 mm is the distance below which two elevations are the same drafted plane. This comment used to
1051
+ * say it WAS grid-core's `gridLevelKey` quantum; the two were the same number by coincidence and are
1052
+ * separate rules now. `gridLevelKey` is a millimetre-based identity handle (grid-core's `LEVEL_SAME_MM`
1053
+ * decides level identity, at 0.5 mm); this is a physical drafting-drift tolerance and is unchanged.
1054
+ * The de-dup distance is 1/4": same measurement, ~3.6x headroom, far below any real member spacing.
1099
1055
  */
1100
1056
  export const MODEL_V2_TOL = Object.freeze({
1101
1057
  CUT_PLANE_MM: 1.5875, // 1/16" — a member includes a sheet elevation within this
@@ -1114,7 +1070,7 @@ export const MODEL_V2_TOL = Object.freeze({
1114
1070
  //
1115
1071
  // They bound the pick, NOT the registration: the transform is fitted from the grid, so a pick within
1116
1072
  // tolerance moves nothing. What they bound is the evidence — the picks are the only measurement that
1117
- // sees the drawing at all, and so the only check on `grid.origin` and `pt_per_ft`. Two picks a
1073
+ // sees the drawing at all, and so the only check on `grid.origin` and `mm_per_px`. Two picks a
1118
1074
  // baseline apart therefore bound a scale error to ±(REFUSE_PT / baselinePt), which is why the reader
1119
1075
  // skill tells the AI to choose the FURTHEST intersection: a longer baseline is a better measurement.
1120
1076
  CONTROL_CHECK_REPORT_PT: 2, // 1/36" on the printed sheet — past ordinary reading error, worth saying
@@ -1123,6 +1079,18 @@ export const MODEL_V2_TOL = Object.freeze({
1123
1079
 
1124
1080
  /** The §5.2a elevation union: `{known:mm}` | `{unknown:true, rfiRef?}`. */
1125
1081
  export function isUnknownElev(e) { return !!e && e.unknown === true; }
1082
+ /**
1083
+ * PLACED, BUT NOT PROVEN (#1155) — the server put this member somewhere so it would be built, and
1084
+ * said out loud that the drawings did not settle it.
1085
+ *
1086
+ * It carries a real `known`, so anything that only asks "is there a number?" builds it, which is the
1087
+ * whole point. Anything that asks "is this height EVIDENCE?" has to ask this too — pricing it,
1088
+ * scoring it, aligning another member to it, or hanging a connection off it are all decisions that
1089
+ * must not be made from a guess.
1090
+ */
1091
+ export function isAssumedElev(e) { return !!e && e.assumed === true; }
1092
+ /** Either spelling of "nobody has confirmed this height". */
1093
+ export function isUnresolvedElev(e) { return isUnknownElev(e) || isAssumedElev(e); }
1126
1094
  /** The known elevation in mm, or null when unknown/malformed. Never returns 0 for "unknown". */
1127
1095
  export function knownZ(e) { return e && typeof e.known === 'number' && Number.isFinite(e.known) ? e.known : null; }
1128
1096
 
@@ -1512,41 +1480,6 @@ export function sectionExtents(outline) {
1512
1480
  return { lo: [loX, loY], hi: [hiX, hiY] };
1513
1481
  }
1514
1482
 
1515
- /**
1516
- * How far the ROLLED section reaches along one world axis — the outline's support function at `rotDeg`.
1517
- *
1518
- * This is what a flush face needs while the composition still measures against the WORLD axes (slice 1a):
1519
- * the section is rolled about the reference line, so `top` has to hold the rolled steel's topmost fibre
1520
- * on the line, and the topmost fibre moves with the angle. Slice 1b replaces the whole question with
1521
- * `positionOffsetVector`, which measures on the section's own axes and needs no angle at all.
1522
- *
1523
- * `axis` picks which world direction to measure: 'depth' is the one the section's local +y rolls into
1524
- * (world up for a beam), 'width' the one local +x rolls into.
1525
- *
1526
- * A ROUND section is pinned to its exact radius at every roll — its support function genuinely is `r` in
1527
- * every direction, and measuring the inscribed polygon instead would report `r·cos(π/48)`.
1528
- *
1529
- * @param {{outer:[number,number][], round?:boolean, r?:number}} outline
1530
- * @param {number|undefined} rotDeg
1531
- * @param {'depth'|'width'} axis
1532
- * @returns {{lo:number, hi:number}} signed extremes along that axis
1533
- */
1534
- export function rolledExtent(outline, rotDeg, axis) {
1535
- if (outline.round) return { lo: -outline.r, hi: outline.r };
1536
- // A non-finite rot reads as 0. This value moves a member's COORDINATES, not just its facing, so an
1537
- // Infinity would reach Math.cos → NaN → NaN endpoints — which the degeneracy guard cannot catch
1538
- // (`NaN < 1` is false) and which serialize to `null` for the viewer and both native writers alike.
1539
- const th = ((typeof rotDeg === 'number' && isFinite(rotDeg) ? rotDeg : 0) * Math.PI) / 180;
1540
- const c = Math.cos(th), s = Math.sin(th);
1541
- let lo = Infinity, hi = -Infinity;
1542
- for (const [x, y] of outline.outer) {
1543
- const v = axis === 'width' ? x * c - y * s : x * s + y * c;
1544
- if (v < lo) lo = v;
1545
- if (v > hi) hi = v;
1546
- }
1547
- return { lo, hi };
1548
- }
1549
-
1550
1483
  /**
1551
1484
  * Where a named face puts the section relative to the reference line, on ONE axis, in section
1552
1485
  * coordinates. `top`/`left` put that face ON the line, so the steel hangs off the other side — the
@@ -1754,7 +1687,10 @@ export function positionOffsetVector(frame, ex, depthFace, widthFace, rotDeg, wi
1754
1687
  }
1755
1688
 
1756
1689
  // The ¼" / 5° snaps the 3D Profile Position gizmo applies to a dragged offset / roll (Shift = free).
1757
- export const POSITION_OFFSET_SNAP_MM = 25.4 / 4;
1690
+ // `IN_TO_MM / 4`, not `25.4 / 4`: the quantum IS a quarter of an inch, so it should say so in the one
1691
+ // vocabulary the repo has for that fact. Writing the number spelled the same digits as a unit
1692
+ // conversion while meaning something else, which is exactly what the geometry guard is watching for.
1693
+ export const POSITION_OFFSET_SNAP_MM = IN_TO_MM / 4;
1758
1694
  export const POSITION_ROT_SNAP_DEG = 5;
1759
1695
 
1760
1696
  /** Round `value` to the nearest multiple of `step` (the gizmo's ¼"/5° drag snap); `step<=0` = free. */
@@ -1871,6 +1807,54 @@ export function quantizeMm(v) {
1871
1807
  return typeof v === 'number' && isFinite(v) ? Math.round(v * 1e9) / 1e9 : NaN;
1872
1808
  }
1873
1809
 
1810
+ /**
1811
+ * Turn an endpoint preview into the immutable host commit payload. Returning null means the gesture is
1812
+ * incomplete or quantises back to its drag-start point, so the caller restores the canonical overlay.
1813
+ */
1814
+ export function worldEndpointCommit(pending) {
1815
+ if (!pending || pending.world !== true || typeof pending.id !== 'string'
1816
+ || (pending.end !== 0 && pending.end !== 1)
1817
+ || !Array.isArray(pending.orig) || pending.orig.length !== 3
1818
+ || !Array.isArray(pending.newPt) || pending.newPt.length !== 3
1819
+ || !pending.orig.every(Number.isFinite) || !pending.newPt.every(Number.isFinite)
1820
+ || pending.state?.available !== true || pending.state.id !== pending.id
1821
+ || !Number.isSafeInteger(pending.state.generation)
1822
+ || !pending.state.fingerprint || typeof pending.state.fingerprint !== 'object'
1823
+ || Array.isArray(pending.state.fingerprint)
1824
+ || !pending.state.fingerprint.from || !pending.state.fingerprint.to) return null;
1825
+ if (!pending.newPt.some((v, i) => quantizeMm(v) !== quantizeMm(pending.orig[i]))) return null;
1826
+ return {
1827
+ id: pending.id,
1828
+ end: pending.end,
1829
+ point: pending.newPt.slice(),
1830
+ state: pending.state,
1831
+ };
1832
+ }
1833
+
1834
+ /** Resolve an endpoint drag without discarding the elevation of a 3D snap. */
1835
+ export function endpointDragPoint(origin, planeHit, verticalHit, vertical, candidates, toScreen, tolPx, free3d = true) {
1836
+ if (vertical) {
1837
+ if (!verticalHit) return null;
1838
+ const point = [origin[0], origin[1], verticalHit[2]];
1839
+ const levels = [...new Set(candidates.flatMap((c) => [c.p, c.a, c.b])
1840
+ .filter(finiteVec3).map((p) => p[2]))];
1841
+ const r = snapPoint(point, levels.map((z) => ({ type: 'level', p: [origin[0], origin[1], z] })), toScreen, tolPx);
1842
+ return { point: r.snapped, type: r.candidate?.type || null };
1843
+ }
1844
+ // An edge-on horizontal plane has no ray hit, but an existing endpoint is still pickable.
1845
+ const query = planeHit || verticalHit;
1846
+ if (!query) return null;
1847
+ const allowed = candidates.filter((c) => {
1848
+ // An axis or grid steers XY at the cursor's Z; without a plane hit that Z is not an elevation pick.
1849
+ if (!planeHit && (!finiteVec3(c.p) || c.type === 'vertical-axis' || c.type === 'grid-int')) return false;
1850
+ const point = candidatePoint(c, query);
1851
+ return finiteVec3(point) && (free3d || candidateOnPlane(c, query, origin, [0, 0, 1]));
1852
+ });
1853
+ const r = snapPoint(query, allowed, toScreen, tolPx);
1854
+ if (r.candidate) return { point: free3d ? r.snapped : [r.snapped[0], r.snapped[1], origin[2]], type: r.candidate.type };
1855
+ return planeHit ? { point: planeHit, type: null } : null;
1856
+ }
1857
+
1874
1858
  /**
1875
1859
  * ONE canonical "is this a vertical brace", matching the durable scene reader's normalisation
1876
1860
  * (`contract-to-scene.ts` `memberIsBrace`, which trims and lowercases). The repo had THREE spellings of