Skip to content

fix(constraint): read decimal literals in constraint expressions - #10

Merged
superWorldSavior merged 3 commits into
mainfrom
fix/constraint-decimal-literals
Oct 25, 2026
Merged

superWorldSavior merged 3 commits into
mainfrom
fix/constraint-decimal-literals

Conversation

@superWorldSavior

Copy link
Copy Markdown
Owner

Summary

  • Any decimal in a constraint failed to extract. totalMass <= 2.5 or thrust / (totalMass * 9.81) >= 2 gave Cannot parse literal value from 'LiteralRational'.
  • Root cause, checked on a live SysON: its expression results have no real-number type. self.value on a LiteralRational therefore fails in GraphQL ("non null type … objValue/id"). The error was swallowed, and the parser fell back to the element's label.
  • The fix reads the value with self.value.toString(), as the attribute value resolver already does. It parses with Number (not parseFloat: "1/3" is not 1). A blank or non-finite text is reported as an error, never read as 0.
  • Every caller of syson_constraint_extract benefits: validation, solving, requirement limits and the requirements trace's authored constraints.

Test plan

  • New test against a mock that fails self.value the way SysON does. It failed before the fix with the production error. It now covers 2.5 and Java's 5.5E7.
  • "", " ", "NaN" and "Infinity" are reported, never read as 0. This test fails without the guard.
  • deno task fmt, lint, check, test
  • Live, on the local audit project: thrust / (totalMass * 9.81) >= 2, totalMass <= 2.5 and totalMass >= -0.5 all evaluate. Before the fix all three were error.
  • Independent review (Sonnet): nothing significant. Its hardening point (a blank text would have read as 0) is applied.

Seen, not fixed here

The validation viewer shows the expression thrust / (totalMass * 9.81) as thrust / totalMass * 9.81; the computed value is right. The cause is in @casys/constraint-solver (format.ts, maybeParen), which never parenthesises a right operand of the same precedence under / or -.

🤖 Generated with Claude Code

superWorldSavior and others added 2 commits October 25, 2026 10:53
Any decimal in a constraint (`totalMass <= 2.5`) failed with "Cannot
parse literal value from 'LiteralRational'". SysON's expression results
have no real-number type, so `self.value` on a LiteralRational fails in
GraphQL; the failure was swallowed and the parser fell back to the
element's label. The value is now read with `self.value.toString()`,
as the value resolver already does for attributes.

Verified on a live SysON: `thrust / (totalMass * 9.81) >= 2`,
`totalMass <= 2.5` and `totalMass >= -0.5` now evaluate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Number('') is 0: a blank or non-finite text for a LiteralRational is now
reported by the parser instead. Tests cover Java's exponent form and the
unreadable texts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@superWorldSavior
superWorldSavior merged commit 31b85c2 into main Oct 25, 2026
2 checks passed
@superWorldSavior superWorldSavior mentioned this pull request Oct 25, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant