Skip to content

engine: integer leakage is ignored on an exponential-leak conveyor #942

Open

Description

@bpowers

On a conveyor with exponential_leak="true", a leak flow marked <leak_integers/> still leaks fractional amounts.
The exponential branch of ConveyorState::leak_step returns before the whole-unit rounding that the linear branch applies, so the flag is silently ignored.
The wasm backend copies this behavior on purpose, to match the VM.

Example

An exponential-leak conveyor carrying people, with a leak flow marked <leak_integers/> and fraction 0.1/time unit, reports a leak rate like 0.37 people per DT instead of whole people.
No error or warning is produced.

Why it matters

Integer leakage exists for belts of discrete entities, where a fractional leak is simply wrong.
Constructed: no model we have combines the two (none of the test/conveyors/ files uses <leak_integers/>).
The XMILE spec (section 3.7.2) does not restrict integer leakage to the linear model; what Stella does is unverified.

Fix

Reject the combination with a clear compile error in conveyor_compile::expand_conveyors, and scope docs/design/conveyors.md §5.4 to linear leakage.
Then update the comments in wasmgen/belt.rs and src/simlin-engine/CLAUDE.md that describe the wasm side as mirroring the VM's silent drop.

Alternative: define and implement integer rounding for exponential leaks in both backends, plus a parity test.
That needs answers the spec does not give (round before or after the overdrain scale-down; how whole-unit removal fits the rule that overlapping exponential rates add), so it is only worth doing if a real model needs it.

Pointers

  • src/simlin-engine/src/conveyor.rs: ConveyorState::leak_step
  • src/simlin-engine/src/wasmgen/belt.rs
  • docs/design/conveyors.md §5.2, §5.4 (§5.4 already notes this issue)

Activity

  1. added
    engine
    bug
    on Oct 12, 2026
  2. changed the title [-]engine: <leak_integers/> is silently ignored on an exponential-leak conveyor[/-] [+]engine: integer leakage is ignored on an exponential-leak conveyor[/+] on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugengine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions