Skip to content

engine: integer leak into an arrested conveyor inflates its stock #947

Open

Description

@bpowers

A leak flow marked <leak_integers/> whose destination conveyor is arrested can still move whole units.
The units leave the upstream belt and are added to the arrested belt's stock value, but never placed on its slats.
From then on that belt's stock value is larger than the sum of its slats, for the rest of the run.
While the destination is arrested, the leak should move nothing.

Example

Not reproduced in a model; this is read from the code.
The ordinary leak calculation skips a flow whose destination is arrested, so its continuous amount is 0.
The whole-unit step that follows (quantize_integer_leaks) does not check arrest.
It adds that 0 to the flow's carried remainder and removes floor(carry) units.
The carry can hold 1 or more, because whole units a slat could not supply on an earlier step are returned to it.
The arrested belt's insertion step returns early and inserts nothing, but the stock integration still adds the leak's rate to the belt's stock.

A regression test should check both symptoms: the upstream belt sheds nothing while the destination is arrested, and the destination's stock equals the sum of its slats afterwards.
Total conservation across all stocks still holds, so a conservation check alone misses it.

Why it matters

Silent wrong numbers that outlast the arrest.
It needs integer leaks into a belt that can be arrested; no real model with that combination has been seen.

Fix

Pass the arrested flags into quantize_integer_leaks and skip a flow whose destination is arrested, leaving its carry untouched.
The wasm belt pass copies this behaviour on purpose to stay identical to the VM, so change conveyor.rs and wasmgen/belt.rs in the same commit and remove the note about it from emit_leak's doc comment.

Pointers

  • src/simlin-engine/src/conveyor.rs: leak_step, quantize_integer_leaks
  • src/simlin-engine/src/wasmgen/belt.rs: emit_leak
  • leak_to_arrested_destination_is_skipped in src/simlin-engine/src/conveyor_tests.rs covers only the continuous case

Activity

  1. changed the title [-]conveyor-engine: an integer leak flow into an ARRESTED destination belt can still deliver whole units[/-] [+]engine: integer leak into an arrested conveyor inflates its stock[/+] on Oct 12, 2026
  2. added
    engine
    bug
    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