Repository navigation
fix(sim): stop non-finite produced numbers with one checked path - #137
Merged
Merged
Conversation
Val::Number now holds a Finite newtype, so a non-finite f64 cannot
reach a store, a Change record, or the serialized trace, where it
used to serialize as {"type":"number","value":null}. Every computed
scalar goes through Finite::produced, or produced_number for a Val,
and stops not_modeled naming the producing construct. That seals the
remaining producers athena#132 left open: For and For Player
Variable End increments, Set Max Health scaling, Damage and Heal
applied amounts, Speed Of magnitude, match-clock advance and the
timeline time, and the hero-settings conversions and setters.
Fixes #133
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Val::Numbernow holds aFinitenewtype (src/finite.rs) instead of a rawf64, so a non-finitef64can no longer reach a store, aChangerecord, event values, timeline fields, or the serialized trace — where it used to serialize as{"type":"number","value":null}. The unchecked construction path is impossible by type.Finite::produced(orproduced_numberfor aVal), which stops the runnot_modelednaming the producing construct.Finite::newcovers test and boundary construction;Fromcovers integer counts/ids.step.rs:For/For Player VariableEndincrements (old + step)state_writes.rs:Set Max Health(max * percent / 100.0),Set Health,Set Ultimate Chargeactions.rs:Damage/Healapplied amounts bound intoEvent Damage/Event Healing,Set Ability Cooldown,Set Status Effectexpiryplayer.rs:Speed Ofmagnitudeclock.rs/sched.rs:advance(elapsed, countdownmatch_time),Total Time Elapsed(now), timelinetimestate.rs: hero-settings pool scaling (max * health%), cooldownseconds * scale,ultimateCost, plus pool writes insidedamage/healFinite;now, cooldowns, pools, and status expiries thread the type through.docs/findings.md(replaced with the sealed statement), documented the finitenumbercontract indocs/trace-format.mdanddocs/simulator-interface.md.Finitemovedproduced_numberout ofvector.rsintofinite.rs;size-guardrequiredlib.rsto shed the type tofinite.rsand a few over-limit files to tighten.Tests added
not_modeledtests with the construct named:ForEnd(global and player variable),Set Max Health,Damage,Heal,Speed Of, non-finite clock arguments,elapsedoverflow viaSet Slow Motion, timelinetimeoverflow,health%/abilityCooldown%hero-settings literals.a_serialized_trace_never_carries_a_null_number: serializes a globals trace and a scenario trace (pools, clock changes, event values, timelinetime) and asserts{"type":"number","value":null}never appears.infdownstream throughFor Endwere updated to assert the earlierFor/producing-operation stop, matching the new semantics.Verification
cargo fmt --check— cleancargo clippy -p athena-sim --all-targets— no warningscargo test -p athena-sim— all suites pass, includingprobe_hashescargo check --locked --target wasm32-unknown-unknown -p athena-sim— cleanUnverified
Finite::producedalso wraps pure-extraction sites (Set Slow Motion/Set Match Time/Set Ability Cooldown/Set Ult Chargearguments andForstart values) where an evaluatedValis already finite by construction; the calls keep the "every producedf64entering aFinitefield takes the checked path" rule uniform and cannot fire today.Val::Vectorcomponents remain rawf64, guarded byvector::produced(athena#74) — unchanged, out of this issue'snumber-value scope.Fixes #133