Repository navigation
cli: prevent duplicate GitHub environment supervisors - #348010
Merged
roblourens merged 2 commits intoNov 16, 2026
Merged
Conversation
Keep one sharing supervisor per server data directory so concurrent starts cannot publish competing encryption keys for the same environment. Preserve private data-directory permissions and reject duplicate starts before authentication. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review findings remain for the supervisor identity-locking change.
No open issues 🎉
What changed in this PR
This follow-up to #347703 prevents duplicate GitHub environment supervisors from sharing a persisted identity while advertising conflicting encryption keys. Ownership is scoped to the backend server data directory; ordinary local agent-host startup remains unchanged.
Changes:
- Reject duplicate starts before credential prompts, then recheck and hold the cross-process lock throughout the supervisor’s lifetime.
- Add tests for duplicate rejection, lock release, directory isolation, and Unix directory permissions.
- Document the single-supervisor restriction and how to start independent environments.
No actionable findings remain. Windows live validation was not run, as noted in the PR description.
| File | Description |
|---|---|
cli/src/commands/agent_host.rs |
Adds supervisor locking, early duplicate detection, and regression tests. |
cli/CONTRIBUTING.md |
Documents ownership scope, restart guidance, and independent environment configuration. |
Review effort: Balanced
Use taskkill /f /t for background process trees and surface termination failures before removing discovery metadata. Cover no-console termination and failed taskkill on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
marked this pull request as ready for review
November 16, 2026 05:18
roblourens
enabled auto-merge
November 16, 2026 05:18
Bryan Chen (bryanchen-d)
approved these changes
Nov 16, 2026
roblourens
deleted the
roblou/agents/debug-windows-mc-authentication-issue
branch
November 16, 2026 05:46
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.
Follow-up to #347703.
Repeated
code agent host --github-environmentcommands start independent background supervisors that share one persisted environment identity but advertise different encryption keys. Clients can then reject authentication because the host answering the relay does not match the keys published by the latest heartbeat.Hold the existing cross-process file lock for the GitHub environment supervisor's lifetime, scoped to the backend server data directory. Reject duplicate starts before prompting for credentials and recheck in the supervisor to cover concurrent first starts. Separate server data directories remain independent; ordinary local agent-host startup is unchanged.
Also force Windows process-tree termination with
taskkill /f /tand check its exit status. A failed Windows termination command must not remove discovery metadata and report that the host was killed. Add Windows regression cases for a background process without a console window and failed termination.Live validation on macOS with the rebuilt CLI: concurrent initial starts admitted one supervisor; repeated starts, foreground mode, and alternate CLI/registry directories were rejected. The remaining host answered initialize once, completed encrypted authentication, and retained matching keys across a heartbeat. Three sharing/kill cycles stopped the full observed process tree. All test hosts and environments were removed. The maintainer independently confirmed on Windows that adding
/fstops the shared host; the new Windows unit tests have not been run locally.Checks passed:
cd cli && cargo build --locked --bin code;cd cli && cargo test --locked --lib commands:: --no-fail-fast(61 tests);cd cli && cargo test --locked --lib util::command::tests(1 test);cd cli && cargo clippy --locked --lib --quiet;cd cli && rustfmt --check --edition 2021 src/commands/agent_host.rs.cd cli && rustfmt --check --edition 2021 src/util/command.rsreports an existing formatting difference in the unchanged Unix process-tree test.(Written by Copilot)