Skip to content

fix: attribute unitless node totals to the node - #17

Merged
bwin merged 2 commits into
devfrom
fix/unitless-node-total
Nov 3, 2026
Merged

bwin merged 2 commits into
devfrom
fix/unitless-node-total

Conversation

@bwin

@bwin bwin commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes CONFIRMED-FINDINGS.md item 1: a node scalar total without graph.defaultUnit only produced the graph-level "unitless amounts cannot be mixed" message, which blamed links for missing units.

  • src/units.ts: tracks unitless links and unitless node totals separately. When named units are present, each scalar-total node gets its own invalid-unit issue with that nodeKey and guidance to set graph.defaultUnit or use totals with named units. The existing graph-level message is kept only for links with undefined input/output units.
  • Hardening follow-up: deduplicates repeated keys, skips the node-scoped guidance when total and totals are both present (leaving incompatible-totals as the actionable issue), and guards non-string keys so unit resolution does not add a TypeError path.
  • tests/units.test.ts: covers node-scoped attribution, retained link guidance, both issues together, validateGraph parity, fully unitless graphs, multiple/destination nodes, duplicate keys, total + totals, and malformed keys.
  • CHANGELOG.md: one [Unreleased] / Fixed entry.

Verification

  • npm run format — passed
  • npm run typecheck — passed
  • npm run lint — passed
  • npm test — 159 tests passed
  • npm run build — passed

Review

Adversarial review approved both commits. The reviewer independently checked a 35-combination matrix against dev and confirmed only the intended issue changes; malformed-key handling stays non-throwing through validateGraph.

Notes

Browser tests were not run to avoid the shared Playwright port. Validation-only change; no rendered-output change.

@bwin
bwin merged commit 36afc33 into dev Nov 3, 2026
2 checks passed
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