fix(cost): an unpriced rollup reports no total rather than zero #272

Merged
coilysiren merged 1 commit from coilyco-ops/unpriced-is-not-free into main 2026-08-13 22:53:24 +00:00 AGit
Member

closes #285 - ingredientCost 0 meant no leaf resolved, so the least-known recipe ranked cheapest by 7x

Slice of #266, which stays open: the 25-tool audit and its generic invariant test are not this.

closes #285 - ingredientCost 0 meant no leaf resolved, so the least-known recipe ranked cheapest by 7x Slice of #266, which stays open: the 25-tool audit and its generic invariant test are not this.
price_recipe(product=IronBarItem) ranked the recipe where nothing priced
as the cheapest, by 7x:

  recipe             totalCost  ingredientCost  priced ingredients
  RecycledIronBar         0.22               0  0 of 2
  IronBar                 1.46            1.28  1 of 2
  SmeltIron               3.18            2.56  1 of 2

ingredientCost: 0 meant "no leaf resolved", not "the ingredients are
free", and it was the only comparable-looking number in the row.

perUnitCost already goes None when complete is false. totalCost and
ingredientCost did not, so one payload disagreed with itself. They now
follow it: a partial sum is not a cost.

The priced part is not lost. ingredients[] carries every resolved leaf
and unpricedInputs names what did not, so a caller can still see how far
the rollup got.

The frontend already had the pattern for this. Its recipe sort reads
perUnitCost ?? Number.POSITIVE_INFINITY, so an unknown cost sorts last
rather than winning, which is the behaviour this defect wanted. The two
types widen to number | null and the ingredient-cost cell takes the same
null guard the per-unit cell already had.

Mutation: reporting the partial sum again fails the incomplete-rollup
test and nothing else.

Slice of #266, which stays open: its acceptance is an audit of all 25
tools plus a generic invariant test, and get_economy.govt_funds and
get_currency are untouched here.

Refs #266

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Kai Siren <coilysiren@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-gaming/eco-app!272
No description provided.