Fix ThreatCostCalculator: per-unit division, scrap fallback, fixpoint, staggered-recipe max

This commit is contained in:
2026-07-08 20:28:31 +02:00
parent c6db4bf24a
commit 5b86b15c71
6 changed files with 333 additions and 98 deletions

View File

@@ -373,31 +373,3 @@ in `requirements.md` and the git history). Still open:
one matching deposit tile). Touches REQ-BLD-MINER ("every asteroid
tile is equivalent" no longer holds), REQ-GW-ASTEROID-EXPAND /
REQ-EXP-*, `world.toml`, and `visuals.toml`.
6. **Scrap-consuming recipes as threat fallback only.** Amend
REQ-THREAT-ITEM: recipes that take scrap as an input participate in
an item's threat computation only if no scrap-free recipe (miner,
smelter, or assembler) produces that item — mirroring the existing
rule for the reprocessing path. Otherwise the scrap→ingot smelter
recipe would inflate the basic materials' threat via the
max-across-recipes rule, poisoning every downstream value.
7. **Per-unit item threat.** Amend REQ-THREAT-ITEM and
`ThreatCostCalculator`: a recipe's threat is divided by its output
amount, so item threat is production-seconds *per unit*. Currently a
recipe producing 2 copper_wire per run assigns each wire the full
run's threat, double-pricing multi-output items and everything
downstream of them.
8. **Fixpoint resolution in ThreatCostCalculator.** Items downstream of
reprocessing-only items (e.g. capital parts built from the scrap-only
input) never resolve, because resolution stops after the reprocessing
pass instead of iterating; their consumers silently drop the missing
materials, so capital hull threat is currently underestimated (found
by `tools/threat_report.py`, which implements the correct fixpoint).
9. **Max rule across staggered recipes in ThreatCostCalculator.** An
item is committed at the first iteration where *any* of its recipes
resolves, taking the max only over the recipes resolvable at that
point. A shallow shortcut recipe (e.g. steel plate from raw ore)
resolves one iteration earlier than the base path and wins, silently
underpricing the item and everything downstream — violating the
"shortcuts are pure rewards" rule. Fix: commit an item's threat only
once every eligible recipe for it is computable (as
`tools/threat_report.py` does), with a fallback for recipe cycles.