Saved states
A saved state is the complete state of a vehicle-by-vehicle traffic run at one moment, stored as bytes with a digest. A new run can have a saved state as its start, and several runs from one saved state have exactly the same beginning.
Inputs
- A completed traffic run of your account.
- A moment of that run: its end, or a checkpoint from the run's setup.
- A name for the saved state.
A saved state contains every vehicle with its route and its position, the queues on every road link, the signal plans, the hazard zones, the road network, the tick, the clock, and the state of the random-number generator. The bytes have a marker for the format, a SHA-256 digest of the body, and an envelope with the workspace, the scenario and a hash of the specification.
Outputs
- A reference to the saved state, with the digest of its bytes, the tick, the clock and the number of vehicles.
- A list of your saved states.
- A new run. In a proposal, a saved state is named as the start of the traffic model. After your approval, the first tick of the run is the saved tick.
- A continuation: the same run for a further number of ticks from its end or from a checkpoint.
Guarantees and their checks
| Guarantee | Mechanism | Check |
|---|---|---|
| The bytes of a saved state are intact. | At a restore, the SHA-256 digest of the body is compared with the digest in the header. | In a test of the core, a state with one changed bit has a refusal as its result. |
| A saved state belongs to one person in one workspace. | A restore is open to the creator of the state. The workspace is also inside the bytes. For another account, the answer is the same as for a missing state. | In tests, a restore by another workspace has the answer "not found", a restore by another person of the same workspace is refused before any disclosure, and bytes under another workspace are refused in the core. |
| The selected state is the stored state. | The digest in the request is compared with the digest of the stored record. Then the tick, the clock and the vehicle count of the record are compared with the restored bytes. | In a test, a request with an older digest has a refusal as its answer. |
| A save is a verified copy. | The first step of a save is a replay of the source run from its setup. The state is stored when the replay has the tick count and the final digest of the source. | In a test, a save from an unfinished run and a save with a differing receipt each have a refusal as their result. |
| A continued run is equal to the uninterrupted run. | The state is complete for the next tick, down to the state of the random-number generator. | In a test through an AI assistant's operations, a run with a continuation and one run of the same total length have the same final digest and the same saved frames. In tests of the core, a restored run and the uninterrupted run have equal bytes after every tick. |
| Two runs from one saved state have the same start. | Each run's provenance has the digest of its source state. | In a test, two approved runs from one saved state, one of them with a road closure, have the same source digest, and the trip in the run with the closure is longer. |
Place in the path of a question
A saved state is data for the traffic model, like the streets of a place. A comparison of a change from a busy moment has two runs from one saved state: one as it was, and one with the change. In run control, a continuation of a run has the state at the run's end, or at a checkpoint, as its start. In the engine, the first step of each save and of each continuation is a replay of the source run.