fix(session): report the frame a pause began at

Frames go on counting while paused, since Pump still runs, but status
gave no pause frame and `wait --paused` replied with the current one.
A wait that came minutes after `pause --on-check` caught a failure at
frame 237 said "paused at frame 5475", which an agent takes for when
the check failed.

The session records the frame in PauseNow, and status and the paused
wait report it as pausedAt. The client prints "PAUSED since frame N",
and "paused at frame N (now M)" when the two differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-01 03:21:41 +01:00
commit 2c77cdcfab
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 29 additions and 5 deletions

View file

@ -92,7 +92,17 @@ int main() {
const Value pausedReply = ResultOf(*waitPaused);
const Value* reason = pausedReply.Find("reason");
Check(reason != nullptr && reason->AsString().find("counter >= 3") != std::string::npos, "wait --paused replies with the reason");
// Frames go on while paused: a wait that comes later must still say
// when the pause began, not the frame it looked at.
const std::uint64_t pausedAt = pausedReply.Find("pausedAt")->AsInteger();
for (std::int32_t frame = 0; frame < 5; ++frame) Pump();
const Value later = ResultOf(*Send("debug.wait", R"({"paused": true})"));
const Value statusWhilePaused = ResultOf(*Send("debug.status"));
Check(later.Find("pausedAt")->AsInteger() == static_cast<std::int64_t>(pausedAt) && later.Find("frame")->AsInteger() >= static_cast<std::int64_t>(pausedAt) + 5
&& statusWhilePaused.Find("pausedAt")->AsInteger() == static_cast<std::int64_t>(pausedAt),
std::format("a later wait and status say when the pause began (frame {}), not the frame now", pausedAt));
Send("debug.resume");
Check(ResultOf(*Send("debug.status")).Find("pausedAt") == nullptr, "status has no pausedAt once resumed");
Check(ResultOf(*Send("debug.pause", R"({"onCheck": true})")).Find("armed")->AsString() == "onCheck", "pause --on-check arms");
Check(Advance(), "running before the check fails");