Skip to content

fix(sim): stop non-finite produced numbers with one checked path - #137

Merged
e54-bot merged 1 commit into
mainfrom
fix/non-finite-guard
Oct 28, 2026
Merged

e54-bot merged 1 commit into
mainfrom
fix/non-finite-guard

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Val::Number now holds a Finite newtype (src/finite.rs) instead of a raw f64, so a non-finite f64 can no longer reach a store, a Change record, 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.
  • Every produced scalar goes through the one checked construction: Finite::produced (or produced_number for a Val), which stops the run not_modeled naming the producing construct. Finite::new covers test and boundary construction; From covers integer counts/ids.
  • Sealed every site athena#132 left open:
    • step.rs: For/For Player Variable End increments (old + step)
    • state_writes.rs: Set Max Health (max * percent / 100.0), Set Health, Set Ultimate Charge
    • actions.rs: Damage/Heal applied amounts bound into Event Damage/Event Healing, Set Ability Cooldown, Set Status Effect expiry
    • player.rs: Speed Of magnitude
    • clock.rs/sched.rs: advance (elapsed, countdown match_time), Total Time Elapsed (now), timeline time
    • state.rs: hero-settings pool scaling (max * health%), cooldown seconds * scale, ultimateCost, plus pool writes inside damage/heal
  • All numeric-bearing world/clock/timeline/event fields are Finite; now, cooldowns, pools, and status expiries thread the type through.
  • Docs: removed the feat(sim): model Number Of Players over the scenario roster #132 known-gap note in docs/findings.md (replaced with the sealed statement), documented the finite number contract in docs/trace-format.md and docs/simulator-interface.md.
  • Finite moved produced_number out of vector.rs into finite.rs; size-guard required lib.rs to shed the type to finite.rs and a few over-limit files to tighten.

Tests added

  • Per-site not_modeled tests with the construct named: For End (global and player variable), Set Max Health, Damage, Heal, Speed Of, non-finite clock arguments, elapsed overflow via Set Slow Motion, timeline time overflow, 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, timeline time) and asserts {"type":"number","value":null} never appears.
  • Two pre-existing tests that drove inf downstream through For End were updated to assert the earlier For/producing-operation stop, matching the new semantics.

Verification

  • cargo fmt --check — clean
  • cargo clippy -p athena-sim --all-targets — no warnings
  • cargo test -p athena-sim — all suites pass, including probe_hashes
  • cargo check --locked --target wasm32-unknown-unknown -p athena-sim — clean

Unverified

  • Finite::produced also wraps pure-extraction sites (Set Slow Motion/Set Match Time/Set Ability Cooldown/Set Ult Charge arguments and For start values) where an evaluated Val is already finite by construction; the calls keep the "every produced f64 entering a Finite field takes the checked path" rule uniform and cannot fire today.
  • Val::Vector components remain raw f64, guarded by vector::produced (athena#74) — unchanged, out of this issue's number-value scope.

Fixes #133

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
@e54-bot
e54-bot merged commit 933f7af into main Oct 28, 2026
3 checks passed
@e54-bot
e54-bot deleted the fix/non-finite-guard branch October 28, 2026 18:22
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.

Stop every non-finite produced number as not_modeled with one checked path

2 participants