orchestrator: emit snapshot_load before _write_meta to keep t_mono ~0
On slower disks (Pi5 SD cards, mu's hardware) the json.dump → write → os.replace path inside _write_meta takes more than 1 ms, so when the snapshot_load event fired afterwards its t_mono_ns drifted past the "<1 ms after origin" assertion in test_driver_events_persist_to_events_jsonl. Fix: emit snapshot_load immediately after setting _t_mono_origin_ns, before any file I/O. Matches the semantic intent (snapshot_load marks episode clock = 0) and removes the disk-speed dependency from the event timeline. Diagnosis + suggested patch from spectral/CIS490#7 (filed by mu). Closes spectral/CIS490#7. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
637fb064df
commit
7311802822
1 changed files with 5 additions and 3 deletions
|
|
@ -124,13 +124,15 @@ class EpisodeRunner:
|
|||
|
||||
def run(self) -> EpisodeResult:
|
||||
self._t_mono_origin_ns = time.monotonic_ns()
|
||||
started_at_wall = datetime.now(timezone.utc).isoformat()
|
||||
# snapshot_load is the marker for "episode clock = 0". Emit
|
||||
# BEFORE any file I/O — _write_meta() takes >1 ms on slow disks
|
||||
# (Refs spectral/CIS490#7).
|
||||
self.emit_event("snapshot_load", snapshot=self.cfg.snapshot_name)
|
||||
|
||||
started_at_wall = datetime.now(timezone.utc).isoformat()
|
||||
meta = self._initial_meta(started_at_wall)
|
||||
self._write_meta(meta)
|
||||
|
||||
self.emit_event("snapshot_load", snapshot=self.cfg.snapshot_name)
|
||||
|
||||
# Snapshot revert at start: pause+restore the guest to a known
|
||||
# baseline before phase 0. Requires QMP and a savevm having
|
||||
# already taken place (the launcher is responsible for that).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue