fix(coding-agent): trust supervisor-approved session renames in worker mode - #1702
Closed
snimu wants to merge 6 commits into
Closed
fix(coding-agent): trust supervisor-approved session renames in worker mode#1702snimu wants to merge 6 commits into
snimu wants to merge 6 commits into
Conversation
…d-rename-authority
…d-rename-authority
Contributor
Author
This was referenced Aug 27, 2026
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.
What was wrong
Renaming a session could fail even though the rename was valid. In worker mode the supervisor already reserves and validates the new name, but the worker then validated it a second time against its own copy of the peer roster — which can be stale (sync failures are suppressed). So a name the supervisor had correctly approved could be rejected by the worker holding outdated data.
The fix
rename, activerename_saved_session,set_session_name) now go through a mutation-only path: the supervisor's reservation is trusted, the worker just applies the name and appends the RLM ledger rename.18 production lines, deletion-first (the second validation layer is gone, not worked around).
How it's verified
tsgo clean, biome clean, focused rename suites pass (daemon + supervisor), full-suite failures reproduce identically on main (pre-existing, unrelated). Implemented and independently reviewed by two different models; the reviewer traced all worker command paths and the authenticated-socket gate.
Follow-up candidates noted in review (not in this PR, same bug class, pre-existing): the non-active
rename_saved_sessionbranch and worker-modecreate-with-name paths still double-validate.Note: intentionally no Linear ticket for this cleanup stack, so that check stays red.
Note
Low Risk
Narrows worker rename behavior to trust supervisor authority; standalone validation is unchanged and scope is limited to session naming.
Overview
Worker-mode daemon renames no longer re-check name availability after the supervisor has already reserved the name. Commands
rename, active-sessionrename_saved_session, andset_session_namenow callsetStateSessionNameForCommand, which in worker mode applies the name viaapplyStateSessionName(set name + RLM ledger) and skipssetStateSessionName's reservation andassertStateSessionNameAvailablepass.Standalone daemons (no
workeroption) still use the fullsetStateSessionNamepath. That path now delegates the actual mutation to sharedapplyStateSessionNameafter validation.A regression test confirms a supervisor
set_session_namesucceeds when worker-side availability checks would fail, and that those checks are not invoked.Reviewed by Cursor Bugbot for commit 1cb0f22. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Trust supervisor-approved session renames in worker mode and remove blanket RPC timeouts
AgentDaemon.handleCommandnow delegatesrename,rename_saved_session, andset_session_nameto a newsetStateSessionNameForCommandhelper that applies the supervisor-approved name directly viaapplyStateSessionName, bypassing availability validation. Outside worker mode, the previous validated path viasetStateSessionNameremains.rpc.RpcClient(send,refine,waitForIdle,collectEvents). A newfailPendingOperationshelper centralizes rejection of in-flight requests and event waiters when the transport fails or the client stops.startnow fails fast with stderr if the child cannot spawn, andstopproactively rejects pending operations before waiting for child close.rpc.RpcClientcommands and agent completion waits no longer time out by default. A hung child process that keeps stdout open will leave pending operations waiting indefinitely untilstopis called or the transport errors.Macroscope summarized 1cb0f22.
Linear: ENG-5648