Repository navigation
diagram: three-valued unit-error kind; plain-language inference text - #838
Conversation
The diagram's UnitError collapsed the engine's three-valued unit-error
kind (Definition | Consistency | Inference) into a boolean
isConsistencyError, so a unit inference error was handled exactly like
a definition error: its equation-relative offsets were applied to the
units string, underlining an arbitrary wrong span of the units box.
Core's UnitError now carries kind: 'definition' | 'consistency' |
'inference', and inference errors underline nothing in either field --
they describe a contradiction spanning several variables, so any
single-field span would be arbitrary (and their offsets may point into
a different variable's equation). Their text renders in the details
panel and errors panel instead.
For that text to be usable by modelers, the engine now synthesizes a
plain-language reason for inference errors: unit_inference_reason
names the involved variables ("the units of 'a' and 'b' are
inconsistent with each other; check the equations and declared units
of these variables") instead of the raw `1 == unit-expression`
constraint dump, which stays in the terminal-formatted message for
CLI consumers. A single-line reason (e.g. the clarified macro
conflict) passes through untouched. The model-level inference umbrella
diagnostic in db/units.rs uses the same helper, format_diagnostic's
Model arm now carries Error.details through to FormattedError.details,
and the diagram's modelErrors prefer details over the
terminal-formatted message. Source names are deduped order-preserving
because upstream dedup is by (var, loc), which permits repeated names.
The per-variable inference path is currently latent (the salsa
pipeline surfaces inference conflicts only through the model-level
umbrella), so this pins the placement rule before it can go live;
per-source attribution is tracked in #837.
|
Reviewed the diff — I did not find any bugs that meet the flagging bar. The change is coherent end-to-end (engine emits three-valued kind + user-facing details, diagram maps them correctly, tests pin the new placement rule), and I checked the areas where I expected friction:
Minor observation, not a defect: for 4 names Overall verdict: correct. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #838 +/- ##
========================================
Coverage 90.86% 90.86%
========================================
Files 224 224
Lines 143185 143302 +117
========================================
+ Hits 130101 130218 +117
Misses 13084 13084 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #836
Why
The diagram's
UnitErrorcollapsed the engine's three-valued unit-error kind (Definition | Consistency | Inference) into a booleanisConsistencyError, so a unit inference error was handled exactly like a definition error: its equation-relative offsets were applied to the units string, red-underlining an arbitrary wrong span of the units box.What
UnitError.isConsistencyErroris replaced bykind: 'definition' | 'consistency' | 'inference', mirroring the engine'sSimlinUnitErrorKind. (unitErrorsare attached at runtime and never serialized, so no proto/compat concern.)sources.first(), which may point into a different variable's equation. Their text renders in the details panel and errors panel instead. The whole-declaration units underline now fires only when a consistency error is actually present, instead of for any non-definition unit error.1 == unit-expressionconstraint dump with@Nmetavariables -- meaningful in terminal output, noise for modelers. The engine now synthesizes a plain-languagedetailsnaming the involved variables ("the units of 'births' and 'population' are inconsistent with each other; check the equations and declared units of these variables"); the terminal-formattedmessagekeeps the full dump for CLI/MCP consumers. A single-line reason (e.g. the clarified macro conflict from GH engine: macro unit polymorphism is contained, not resolved #619) passes through untouched. The model-level umbrella diagnostic uses the same helper, and the diagram's model-error list prefers the baredetailsover the terminal-formattedmessage.Notes
variable: None) -- so this pins the placement rule with tests before it can go live. Per-source attribution (the deferred "Option D") is tracked in engine: unit inference errors are not attached to any variable #837.details ?? messagepreference).🤖 Generated with Claude Code
https://claude.ai/code/session_01DyGQwfTBHuwGi7C7m5b3Th