A public charger’s connector
One step from the seed lot: a public charging station’s connector, whose charges are sessions with their own numbers, as the lot’s tests are runs. Events arrive from the cable, the driver’s app, the charger and an operator, and the charger’s messages can arrive late. Each level starts from the previous level’s finished code, so you can begin at any of them.
Drivers can stop charging and start again without unplugging, and the charger’s readings travel over a mobile link, so a reading can arrive seconds late. The station starts a new billing session at every start. The charger now stamps each reading with the session it measured.
A reading from the session that just stopped lands in the next one, and a driver is billed for energy the previous charge took. If session numbers start again after a fault or an unplug, a late reading can carry a number that matches the new session by accident.
Reproduce plug, start, stop, start, then a late meter(session 1, 500 Wh): it is added to the new charge, which shows 500Wh before it has drawn anything.
Acceptance criteria Every start begins a new session, numbered one more than the last; a session number is never used twice on the connector, whatever happens between (stop, unplug, fault, reset). A reading counts only if it carries the session that is charging now; otherwise it is refused as stale-session and changes nothing. The phase is still checked first: a reading while not charging is not-allowed, whatever session it carries. Everything STATE-MACHINE-101 asked still holds. Notes Sessions are numbered from 1; 0 means no session, as the charger’s protocol sends it. Each case starts from a new connector and prints the log line, the reason (accepted, not-allowed or stale-session) and the effect after every event. Keep newConnector, transition and describe, with their parameters; the checker calls them.