[FEATURE] PostRewind hook event — hooks that manage external state can't observe /rewind (re-files stale-closed #18858)
Summary
Add a hook event that fires on /rewind (checkpoint restore) — e.g. PostRewind — so hooks that manage state outside the transcript can observe conversation truncation.
Re-files @Glucksberg's #18858, which was closed by the stale bot as NOT_PLANNED with an invitation to reopen if still relevant. It is still relevant, and no hook event in the current set (31 events as of today's docs) covers it.
Use case: delivery cursors desync silently
We run a message bus for a fleet of agents. A UserPromptSubmit hook polls the bus, injects new messages as a context block, and advances a per-session delivery cursor ("these message ids were delivered").
On /rewind, the injected block is removed from the conversation, but the cursor lives outside the transcript and stays advanced. The next poll starts after the rewound messages, so they are never delivered again. The agent permanently loses whatever was in the rewound turns — supervisor instructions, job reports — with no error anywhere. Any hook that tracks "what the conversation has seen" (memory injectors, mail-style delivery, activity timelines as in #18858) has this failure mode.
Workaround today, and why it's not enough
The hook can stash a transcript anchor (the uuid of the entry it injected into) and scan transcript_path on each subsequent fire; if the anchor is gone, a rewind happened and the cursor rolls back. This works, but it is a per-hook reimplementation of state the harness knows authoritatively, it costs a transcript scan on every prompt, and every affected hook author has to discover the failure mode the hard way first.
Proposed event
PostRewind, firing after the transcript is truncated, with at least:
transcript_path- the uuid of the restore target (the entry the conversation was rewound to)
- the uuids (or id range) of the removed entries
No blocking/mutation semantics needed — observe-only would already solve the desync.
Related
- #18858 — the original request (stale-closed, not declined on the merits)
- #85455 — rewind already interacts badly with hook-produced context (SessionStart output replayed stale); a rewind event is the general-purpose fix for this class
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗