Implement replay_session RPC and wire up the CLI replay command - #62
Merged
Conversation
The CLI `replay` command posted to /rpc/replay_session, but no such function existed, so it always failed. Add the function and make the command work end to end. - sql/replay_session.sql: replay_session(user_id, start_id) re-queues the user's original commands (replay_of_command_id IS NULL) with id >= start_id, in order, via submit_command so each is tagged with replay_of_command_id and a shared replay_run_id and the executor is notified. Validates the user (SQLSTATE 22023) and returns the run id. Replaying a range that already contains prior replays cannot snowball. - sql/install.sql and tests/conftest.py install the new function. - cli/shell_cli.py: replay now takes --user/--start and posts p_user_id/p_start_id, consistent with the other RPC clients. - SPEC.md documents the new RPC. - Tests cover the SQL behavior (requeue from start, originals-only, unknown user) and the CLI argument wiring. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BixPb34oe2Ae5cXuz9WxbP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The CLI
replaycommand POSTed to/rpc/replay_session, but no such functionexisted — so it always failed. This implements the function (a v0.3 roadmap
item) and makes the command work end to end.
Changes
sql/replay_session.sql—replay_session(user_id UUID, start_id INTEGER) RETURNS UUID. Re-queues the user's original commands(
replay_of_command_id IS NULL) withid >= start_id, in order, by callingsubmit_commandfor each — so every replayed row is tagged withreplay_of_command_id(the source) and a sharedreplay_run_id, and theexecutor is notified. Validates the user up front (SQLSTATE
22023) andreturns the run id. This mirrors
workers/replay_agent.py. Replaying onlyoriginals means a range that already contains prior replays can't snowball.
sql/install.sql/tests/conftest.py— install the new function.cli/shell_cli.py— thereplaysubcommand now takes--user/--startand posts
p_user_id/p_start_id, consistent with the other RPC clients.(The old
--sessionarg pointed at a non-existent endpoint.)SPEC.md— documents the new RPC under §2.Tests
repeat replay, and unknown-user error.
maindispatches--user/--startcorrectly.Verification
install.sqlapplies cleanly; manual end-to-end showsreplay_sessionreturnsa run id and queues the originals as new pending rows tagged to their sources.
🤖 Generated with Claude Code
Generated by Claude Code