Ask: Refund carried resources and release their build reservation when the ambient break event clears a worker's task.
Expected files: scripts/colony_sim.gd
Problem:
The ambient break branch in ColonySim.maybe_fire_event (event_roll == 1) unconditionally sets worker.task = {} and grants break_ticks = 6. It only releases the gather reservation (release_resource) when the cleared task was a gather / gather_food with a resource. Two leak paths are not covered:
- A worker mid-haul who has already picked up from the stockpile (i.e.
worker.carrying[resource] >= 1) loses those carried units when the task is wiped — worker.carrying is never refunded and the worker eventually resets to a new task without delivering.
- The reservation that was incremented in
_pick_up_for_build is never decremented, because _deliver_carried is what decrements it. gather_haul_tasks subtracts build.reserved from its need calculation, so a leaked reservation starves the build of future hauls — the build silently stalls even though the global stockpile looks fine.
This was masked by the zero-worker guard (#346) but the carry/refund path was never addressed.
Evidence:
scripts/colony_sim.gd — maybe_fire_event rolls event_roll == 1, clears worker.task, and only releases the reservation for gather-kind tasks.
scripts/colony_sim.gd — _pick_up_for_build increments build.reserved[resource]; _deliver_carried is the only call site that decrements it.
scripts/colony_sim.gd — gather_haul_tasks computes need = cost - delivered - reserved, so a leaked reservation under-counts need.
Acceptance:
- A break that fires while a worker is mid-haul with carried resources refunds the carried units to the stockpile and decrements the matching
build.reserved[resource] before clearing the task.
- Behavior for idle workers and for gather-kind tasks (which already release reservations) is preserved.
- A new test in
tests/test_reservations.gd (or an existing suite that covers break behavior) exercises a mid-haul break and asserts both the carry refund and the reservation balance.
Ask: Refund carried resources and release their build reservation when the ambient break event clears a worker's task.
Expected files: scripts/colony_sim.gd
Problem:
The ambient break branch in
ColonySim.maybe_fire_event(event_roll == 1) unconditionally setsworker.task = {}and grantsbreak_ticks = 6. It only releases the gather reservation (release_resource) when the cleared task was agather/gather_foodwith aresource. Two leak paths are not covered:worker.carrying[resource] >= 1) loses those carried units when the task is wiped —worker.carryingis never refunded and the worker eventually resets to a new task without delivering._pick_up_for_buildis never decremented, because_deliver_carriedis what decrements it.gather_haul_taskssubtractsbuild.reservedfrom itsneedcalculation, so a leaked reservation starves the build of future hauls — the build silently stalls even though the global stockpile looks fine.This was masked by the zero-worker guard (#346) but the carry/refund path was never addressed.
Evidence:
scripts/colony_sim.gd—maybe_fire_eventrolls event_roll == 1, clearsworker.task, and only releases the reservation for gather-kind tasks.scripts/colony_sim.gd—_pick_up_for_buildincrementsbuild.reserved[resource];_deliver_carriedis the only call site that decrements it.scripts/colony_sim.gd—gather_haul_taskscomputesneed = cost - delivered - reserved, so a leaked reservation under-counts need.Acceptance:
build.reserved[resource]before clearing the task.tests/test_reservations.gd(or an existing suite that covers break behavior) exercises a mid-haul break and asserts both the carry refund and the reservation balance.