From c3b9938e9cb381bc7378fdca9073520ff1711ad6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 23:35:54 -0300 Subject: Play past sessions back, re-synced at their keyframes play session S [at SECONDS] restores the session's keyframe before that time (a binary search over its keyframes' times), replays its frames up to it and leaves it paused there; without a time it plays from the start. At each later keyframe the replay reaches, the State is compared with it over the leaves migration kept: a keyframe taken of what update made (periodic, mark, before a reload, exit) that differs is reported once, "diverged before frame F: N values, first ", and every keyframe is restored, so a replay across a jump the log does not hold (set, load, a sketch command) goes on from the State that followed it. A session built from another source or build says so. The console's status line names the session, frame and time, the mark, the clip and where it records. test-past records a session, replays it by the same build (the mark's State exactly, frame 120's two seconds in, no divergence), then by a build with an edited fixture (one divergence, before the mark). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index b642a09..f7a1aa9 100644 --- a/build.zig +++ b/build.zig @@ -355,6 +355,37 @@ pub fn build(b: *Build) void { test_step.dependOn(&killed.step); b.step("test-kill", "A session survives kill -9 up to its last commit").dependOn(&killed.step); + // A past session plays again: from its start to a mark, the same + // State leaf by leaf; two seconds in, from the keyframe before; and, + // built from edited code, it diverges before the mark, says so once, + // and goes on from the mark's State. + const edited = sb.app(.{ .name = "replay", .root_source_file = b.path("test/replay.zig"), .record = true }).addReloadCheck(.{ + .script = b.path("test/past_diverged.script"), + .edits = &.{.{ .file = "test/replay.zig", .old = "@splat(0.01)", .new = "@splat(0.02)" }}, + }); + const past = b.addSystemCommand(&.{ "sh", "-c", + \\set -e + \\db="${4%.state}.xitdb" + \\rm -f "$4" "$4.store" "$db" + \\"$0" --headless --script "$1" --state "$4" "$5" + \\"$0" --headless --script "$2" --state "$4" "$5" + \\"$0" --headless --script "$3" --state "$4" "$6" + \\test "$(stat -c %s "$db")" -lt 1048576 + \\rm -f "$4" "$4.store" "$db" + }); + past.setName("past sessions replay"); + past.addArtifactArg(host_exe); + past.addFileArg(b.path("test/past.script")); + past.addFileArg(b.path("test/past_replay.script")); + past.addFileArg(b.path("test/past_diverged.script")); + _ = past.addOutputFileArg("past.state"); + past.addArtifactArg(recorded); + past.addArtifactArg(edited.edited); + past.has_side_effects = true; + past.expectExitCode(0); + test_step.dependOn(&past.step); + b.step("test-past", "Replay past sessions, to a time and across a code change").dependOn(&past.step); + // Recorded input replays to the same state: played, seeked, stepped, // and after a live pointer move (core host behaviour, not an API). const replay = b.addRunArtifact(host_exe); -- cgit v1.3