Draft — 2026

Keeping slot state and fee logic from drifting apart

An early version of the parking system stored slot availability as a simple boolean flag on each slot — occupied or free — separate from the actual entry/exit records. It worked, until it didn't: an edge case where a session update failed partway through left a slot marked occupied with no matching active record, and no easy way to tell which was correct.

The fix was to stop treating availability as its own piece of state entirely. Instead, a slot's status is derived on read from whether an active (unclosed) entry record exists for it. There's no flag to fall out of sync, because there's no second source of truth to disagree with the first.

The same principle applies to fee calculation. Rather than starting a client-side timer when a vehicle enters, the fee is computed from the stored entry timestamp whenever the session is closed — even if that happens much later than expected, or after a page refresh, the charge is still correct because it's derived from data, not from an in-progress process in the browser.

It's a small architectural choice, but it removed an entire category of bugs: anything that could theoretically get 'out of sync' between two representations of the same fact simply doesn't have a second representation to sync with.