fix(mcp): restore >0 validation and reject ambiguous numbers in measurement()

Adversarial-review follow-ups to the lingo measurement() field:
- Add a `positive` option (strict > 0) and use it for the non-zero dimension
  params. Swapping z.number().positive() → measurement(..,{min:0}) had started
  admitting 0 (the core node schemas have no positivity backstop), so a zero-size
  wall/opening/roof could be created. Inclusive-0 fields (overhang, sill height,
  knee-wall height, opening offset, roof pitch) keep min:0.
- Escalate AMBIGUOUS_NUMBER to error so "1,234" fails instead of silently reading
  as 1234 — a 1000x hazard for European decimals. Matches lingo's own /ai fields.
- roofLevelElevation reverted to z.number() (it's a level ordinal, not meters);
  radians fields now advertise radian-appropriate examples.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aymeric Rabot
2026-07-08 13:09:59 +02:00
co-authored by Claude Opus 4.8
parent f66dcd438b
commit 3273aac551
7 changed files with 108 additions and 48 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ export const cutOpeningInput = {
wallId: NodeIdSchema,
type: z.enum(['door', 'window']),
position: z.number().min(0).max(1),
width: measurement('length', 'm', { min: 0, description: 'Opening width.' }),
height: measurement('length', 'm', { min: 0, description: 'Opening height.' }),
width: measurement('length', 'm', { positive: true, description: 'Opening width.' }),
height: measurement('length', 'm', { positive: true, description: 'Opening height.' }),
}
export const cutOpeningOutput = {