-
Notifications
You must be signed in to change notification settings - Fork 53
Add explicit broker workspace join options #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6419d59
Add explicit broker workspace join options
365302b
style: auto-format with Prettier
github-actions[bot] d5f7fee
chore: apply pr-reviewer fixes for #1055
agent-relay-code[bot] 95b1eb8
chore: apply pr-reviewer fixes for #1055
agent-relay-code[bot] e2c5c68
style: auto-format with Prettier
github-actions[bot] b374792
Fix workspace join option resolution
01449d0
Isolate harness spawn config coverage
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
.agentworkforce/trajectories/completed/2026-06/traj_1llfpjvd9m7k/summary.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Trajectory: Review and fix PR 1055 | ||
|
|
||
| > **Status:** ✅ Completed | ||
| > **Confidence:** 86% | ||
| > **Started:** June 6, 2026 at 01:49 PM | ||
| > **Completed:** June 6, 2026 at 02:05 PM | ||
|
|
||
| --- | ||
|
|
||
| ## Summary | ||
|
|
||
| Reviewed PR 1055, removed accidental rust_out artifact, restored emptied trajectory data, and fixed CLI env-var test cleanup. Verified harness-driver typecheck/build and focused broker CLI/auth tests. | ||
|
|
||
| **Approach:** Standard approach | ||
|
|
||
| --- | ||
|
|
||
| ## Key Decisions | ||
|
|
||
| ### Removed accidental binary artifact and restored emptied trajectory | ||
|
|
||
| - **Chose:** Removed accidental binary artifact and restored emptied trajectory | ||
| - **Reasoning:** PR diff added rust_out and emptied an active tracked trajectory; AGENTS.md requires trajectories to remain tracked, and generated binaries do not belong in the PR. | ||
|
|
||
| ### Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop | ||
|
|
||
| - **Chose:** Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop | ||
| - **Reasoning:** The new tests cleared the shared env var before each test but leaked it after the final test, which can affect later tests in the same process. | ||
|
|
||
| --- | ||
|
|
||
| ## Chapters | ||
|
|
||
| ### 1. Work | ||
|
|
||
| _Agent: default_ | ||
|
|
||
| - Removed accidental binary artifact and restored emptied trajectory: Removed accidental binary artifact and restored emptied trajectory | ||
| - Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop: Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop |
65 changes: 65 additions & 0 deletions
65
.agentworkforce/trajectories/completed/2026-06/traj_1llfpjvd9m7k/trajectory.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| "id": "traj_1llfpjvd9m7k", | ||
| "version": 1, | ||
| "task": { | ||
| "title": "Review and fix PR 1055" | ||
| }, | ||
| "status": "completed", | ||
| "startedAt": "2026-06-06T13:49:15.971Z", | ||
| "completedAt": "2026-06-06T14:05:43.957Z", | ||
| "agents": [ | ||
| { | ||
| "name": "default", | ||
| "role": "lead", | ||
| "joinedAt": "2026-06-06T14:05:29.768Z" | ||
| } | ||
| ], | ||
| "chapters": [ | ||
| { | ||
| "id": "chap_4iax8jv8u74r", | ||
| "title": "Work", | ||
| "agentName": "default", | ||
| "startedAt": "2026-06-06T14:05:29.768Z", | ||
| "endedAt": "2026-06-06T14:05:43.957Z", | ||
| "events": [ | ||
| { | ||
| "ts": 1780754729769, | ||
| "type": "decision", | ||
| "content": "Removed accidental binary artifact and restored emptied trajectory: Removed accidental binary artifact and restored emptied trajectory", | ||
| "raw": { | ||
| "question": "Removed accidental binary artifact and restored emptied trajectory", | ||
| "chosen": "Removed accidental binary artifact and restored emptied trajectory", | ||
| "alternatives": [], | ||
| "reasoning": "PR diff added rust_out and emptied an active tracked trajectory; AGENTS.md requires trajectories to remain tracked, and generated binaries do not belong in the PR." | ||
| }, | ||
| "significance": "high" | ||
| }, | ||
| { | ||
| "ts": 1780754730821, | ||
| "type": "decision", | ||
| "content": "Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop: Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop", | ||
| "raw": { | ||
| "question": "Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop", | ||
| "chosen": "Made CLI env-var test guard clear AGENT_RELAY_BROKER_NAME on drop", | ||
| "alternatives": [], | ||
| "reasoning": "The new tests cleared the shared env var before each test but leaked it after the final test, which can affect later tests in the same process." | ||
| }, | ||
| "significance": "high" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "retrospective": { | ||
| "summary": "Reviewed PR 1055, removed accidental rust_out artifact, restored emptied trajectory data, and fixed CLI env-var test cleanup. Verified harness-driver typecheck/build and focused broker CLI/auth tests.", | ||
| "approach": "Standard approach", | ||
| "confidence": 0.86 | ||
| }, | ||
| "commits": [], | ||
| "filesChanged": [], | ||
| "projectId": "AgentWorkforce/relay", | ||
| "tags": [], | ||
| "_trace": { | ||
| "startRef": "d5f7fee457c2d7a991bdb9167ad2c896aa0987e4", | ||
| "endRef": "d5f7fee457c2d7a991bdb9167ad2c896aa0987e4" | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,9 +72,9 @@ impl Commands { | |||||||||||||||||||||||||||||||||
| let pid = std::process::id(); | ||||||||||||||||||||||||||||||||||
| match self { | ||||||||||||||||||||||||||||||||||
| Commands::Init(cmd) => { | ||||||||||||||||||||||||||||||||||
| let name = cmd.name.trim(); | ||||||||||||||||||||||||||||||||||
| let name = cmd.resolved_instance_name(None); | ||||||||||||||||||||||||||||||||||
| if !name.is_empty() { | ||||||||||||||||||||||||||||||||||
| return name.to_string(); | ||||||||||||||||||||||||||||||||||
| return name; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| std::env::current_dir() | ||||||||||||||||||||||||||||||||||
| .ok() | ||||||||||||||||||||||||||||||||||
|
|
@@ -215,9 +215,18 @@ pub(crate) struct McpArgsCommand { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[derive(Debug, clap::Args)] | ||||||||||||||||||||||||||||||||||
| pub(crate) struct InitCommand { | ||||||||||||||||||||||||||||||||||
| #[arg(long, default_value = "")] | ||||||||||||||||||||||||||||||||||
| /// Legacy broker instance name flag. Prefer --instance-name. | ||||||||||||||||||||||||||||||||||
| #[arg(long, default_value = "", alias = "broker-name")] | ||||||||||||||||||||||||||||||||||
| pub(crate) name: String, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /// Stable broker instance name within the Relay workspace. | ||||||||||||||||||||||||||||||||||
| #[arg(long = "instance-name")] | ||||||||||||||||||||||||||||||||||
| pub(crate) instance_name: Option<String>, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /// Join an existing Relay workspace instead of creating a fresh one. | ||||||||||||||||||||||||||||||||||
| #[arg(long = "workspace-key")] | ||||||||||||||||||||||||||||||||||
| pub(crate) workspace_key: Option<String>, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[arg(long, default_value = "general")] | ||||||||||||||||||||||||||||||||||
| pub(crate) channels: String, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -248,6 +257,135 @@ pub(crate) struct InitCommand { | |||||||||||||||||||||||||||||||||
| pub(crate) state_dir: Option<String>, | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| impl InitCommand { | ||||||||||||||||||||||||||||||||||
| pub(crate) fn resolved_instance_name(&self, fallback: Option<&str>) -> String { | ||||||||||||||||||||||||||||||||||
| fn non_empty_trimmed(value: &str) -> Option<String> { | ||||||||||||||||||||||||||||||||||
| let trimmed = value.trim(); | ||||||||||||||||||||||||||||||||||
| if trimmed.is_empty() { | ||||||||||||||||||||||||||||||||||
| None | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| Some(trimmed.to_string()) | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| self.instance_name | ||||||||||||||||||||||||||||||||||
| .as_deref() | ||||||||||||||||||||||||||||||||||
| .and_then(non_empty_trimmed) | ||||||||||||||||||||||||||||||||||
| .or_else(|| non_empty_trimmed(&self.name)) | ||||||||||||||||||||||||||||||||||
| .or_else(|| { | ||||||||||||||||||||||||||||||||||
| std::env::var("AGENT_RELAY_BROKER_NAME") | ||||||||||||||||||||||||||||||||||
| .ok() | ||||||||||||||||||||||||||||||||||
| .and_then(|name| non_empty_trimmed(&name)) | ||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
| .or_else(|| fallback.and_then(non_empty_trimmed)) | ||||||||||||||||||||||||||||||||||
| .unwrap_or_default() | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| pub(crate) fn resolved_workspace_key(&self) -> Option<String> { | ||||||||||||||||||||||||||||||||||
| self.workspace_key | ||||||||||||||||||||||||||||||||||
| .clone() | ||||||||||||||||||||||||||||||||||
| .or_else(|| std::env::var("AGENT_RELAY_WORKSPACE_KEY").ok()) | ||||||||||||||||||||||||||||||||||
| .map(|key| key.trim().to_string()) | ||||||||||||||||||||||||||||||||||
| .filter(|key| !key.is_empty()) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+285
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Blank Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[cfg(test)] | ||||||||||||||||||||||||||||||||||
| mod tests { | ||||||||||||||||||||||||||||||||||
| use super::*; | ||||||||||||||||||||||||||||||||||
| use std::sync::Mutex; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| static BROKER_NAME_ENV_MUTEX: Mutex<()> = Mutex::new(()); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| struct BrokerNameEnvGuard { | ||||||||||||||||||||||||||||||||||
| _guard: std::sync::MutexGuard<'static, ()>, | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| impl Drop for BrokerNameEnvGuard { | ||||||||||||||||||||||||||||||||||
| fn drop(&mut self) { | ||||||||||||||||||||||||||||||||||
| std::env::remove_var("AGENT_RELAY_BROKER_NAME"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| fn broker_name_env_guard() -> BrokerNameEnvGuard { | ||||||||||||||||||||||||||||||||||
| let guard = BROKER_NAME_ENV_MUTEX.lock().unwrap(); | ||||||||||||||||||||||||||||||||||
| std::env::remove_var("AGENT_RELAY_BROKER_NAME"); | ||||||||||||||||||||||||||||||||||
| BrokerNameEnvGuard { _guard: guard } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| fn init_command(name: &str, instance_name: Option<&str>) -> InitCommand { | ||||||||||||||||||||||||||||||||||
| InitCommand { | ||||||||||||||||||||||||||||||||||
| name: name.to_string(), | ||||||||||||||||||||||||||||||||||
| instance_name: instance_name.map(ToOwned::to_owned), | ||||||||||||||||||||||||||||||||||
| workspace_key: None, | ||||||||||||||||||||||||||||||||||
| channels: "general".to_string(), | ||||||||||||||||||||||||||||||||||
| api_port: 0, | ||||||||||||||||||||||||||||||||||
| api_bind: "127.0.0.1".to_string(), | ||||||||||||||||||||||||||||||||||
| persist: false, | ||||||||||||||||||||||||||||||||||
| state_dir: None, | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||
| fn instance_name_flag_overrides_legacy_name_and_env() { | ||||||||||||||||||||||||||||||||||
| let _guard = broker_name_env_guard(); | ||||||||||||||||||||||||||||||||||
| std::env::set_var("AGENT_RELAY_BROKER_NAME", "env-name"); | ||||||||||||||||||||||||||||||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| let command = init_command("legacy-name", Some("instance-name")); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert_eq!( | ||||||||||||||||||||||||||||||||||
| command.resolved_instance_name(Some("fallback")), | ||||||||||||||||||||||||||||||||||
| "instance-name" | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||
| fn legacy_name_flag_overrides_env_default() { | ||||||||||||||||||||||||||||||||||
| let _guard = broker_name_env_guard(); | ||||||||||||||||||||||||||||||||||
| std::env::set_var("AGENT_RELAY_BROKER_NAME", "env-name"); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| let command = init_command("legacy-name", None); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert_eq!( | ||||||||||||||||||||||||||||||||||
| command.resolved_instance_name(Some("fallback")), | ||||||||||||||||||||||||||||||||||
| "legacy-name" | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||
| fn env_broker_name_overrides_fallback_only() { | ||||||||||||||||||||||||||||||||||
| let _guard = broker_name_env_guard(); | ||||||||||||||||||||||||||||||||||
| std::env::set_var("AGENT_RELAY_BROKER_NAME", "env-name"); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| let command = init_command("", None); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert_eq!(command.resolved_instance_name(Some("fallback")), "env-name"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||
| fn blank_instance_name_falls_through_to_legacy_name() { | ||||||||||||||||||||||||||||||||||
| let _guard = broker_name_env_guard(); | ||||||||||||||||||||||||||||||||||
| std::env::set_var("AGENT_RELAY_BROKER_NAME", "env-name"); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| let command = init_command("legacy-name", Some(" ")); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert_eq!( | ||||||||||||||||||||||||||||||||||
| command.resolved_instance_name(Some("fallback")), | ||||||||||||||||||||||||||||||||||
| "legacy-name" | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||
| fn empty_instance_name_and_blank_env_fall_through_to_fallback() { | ||||||||||||||||||||||||||||||||||
| let _guard = broker_name_env_guard(); | ||||||||||||||||||||||||||||||||||
| std::env::set_var("AGENT_RELAY_BROKER_NAME", " "); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| let command = init_command("", Some("")); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert_eq!(command.resolved_instance_name(Some("fallback")), "fallback"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #[derive(Debug, clap::Args, Clone)] | ||||||||||||||||||||||||||||||||||
| pub(crate) struct PtyCommand { | ||||||||||||||||||||||||||||||||||
| pub(crate) cli: String, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.