You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vector0 magnitudes go negative through unary minus and scalar * and /: -Temperature.FromKelvin(300) is −300 K #285
The quantities generator deliberately withholds binary - for V0 forms so that magnitudes stay non-negative (QuantitiesGenerator.cs:843-847, if (!isV0)). But for every scalar form, V0 included, it still emits:
Create intentionally does not guard (CLAUDE.md ~l.84), and #50 added Vector0Guards only to the factories. So a V0 quantity becomes negative through a single operator.
This contradicts docs/architecture.md:400 and CLAUDE.md rule 4 ("Physical constraints are enforced structurally via the V0 form"). docs/complete-library-guide.md:137 claims Speed.Create(-1) throws, but it returns −1. Downstream code that relies on the type guaranteeing non-negativity (square roots, logs, dividing by magnitudes) gets NaN or wrong signs.
Suggested fix / acceptance criteria
For V0 forms, don't emit unary negation (as is already done for binary -).
For V0 forms, guard scalar * and / with Vector0Guards.EnsureNonNegative, or restrict them to non-negative scalars.
Fix the complete-library-guide.md line (or make Create behave as it says).
Tests: unary negation of a V0 is unavailable, or throws. Scaling a V0 by a negative number throws.
Priority: Medium. This breaks the library's core structural invariant: V0 magnitudes should never be negative. A single operator gets a V0 quantity past the guards added in Vector0 quantities do not enforce the non-negativity invariant #50, and downstream sqrt, log, or division then produces NaN or the wrong sign. It takes an explicit negation or a negative scalar to trigger, which is why this isn't rated higher.
Area / suggested owner: Source generator, QuantitiesGenerator.cs (the operator emission around l.843–857). Also a docs fix in docs/complete-library-guide.md:137.
Next step: Skip unary - for V0, the same way binary - is already skipped. Guard scalar * and / with Vector0Guards.EnsureNonNegative. Correct the guide's claim about Create. Add tests that V0 negation is unavailable and that scaling a V0 by a negative number throws.
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
QuantitiesGenerator.cs(the operator emission around l.843–857). Also a docs fix indocs/complete-library-guide.md:137.-for V0, the same way binary-is already skipped. Guard scalar*and/withVector0Guards.EnsureNonNegative. Correct the guide's claim aboutCreate. Add tests that V0 negation is unavailable and that scaling a V0 by a negative number throws.Generated by Claude Code