InterruptionPolicyIfc

What happens when a vehicle stops and cannot carry on by itself.

A process, not a duration, and that is the whole of the design. The real procedure around a breakdown is: somebody is told, somebody who is free walks to the vehicle, looks at it, decides, perhaps pushes it out of the aisle, repairs it, and puts it back to work. Every step of that is a wait or a branch, and a duration can express none of them.

suspend is what makes them expressible, exactly as it is for ksl.modeling.fleet.policies.AssignmentPolicyIfc: a policy that returns immediately is the simple case, and one that first waits for a scarce technician is the general one. They differ only in whether responding takes simulated time.

Declared as a member extension on the process builder for the same reason assign is: KSLProcessBuilder is @RestrictsSuspension, so a plain suspend fun on this interface would not compile at the call site. Being an extension also means an implementation receives the real process builder and may seize, delay, hold and tow -- rather than being confined to whatever a context object thought to offer.

The policy runs inside the vehicle's own agent, so while it is running the vehicle is doing nothing else, is not available to the dispatcher, and keeps its assignment and its load. A failure interrupts the tour; it does not revoke it.

What the framework does around it

  • Books the failure before the call and clears it after, so a policy cannot forget to end a repair and FracTimeFailed spans the whole procedure rather than the repair alone.

  • Asks whether the vehicle is fit to continue when the policy returns. If it is, the vehicle re-routes from wherever it now stands and finishes its tour. If it is not, it goes out of service for the rest of the replication, holding its zones.

  • Requires the same reproducibility as any other policy: randomness comes from a model-controlled stream, never a global generator.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun KSLProcessBuilder.handle(interruption: Interruption)