fix(broker): confirm fleet spawn success - #1431
Draft
khaliqgant wants to merge 5 commits into
Draft
Conversation
`agent-relay up` / `node up` hand-rolled a narrower workspace chain than the SDK: flag -> env -> repository pin -> give up, with a `RELAY_NODE_TOKEN` short-circuit at the top. Two failures fell out of it. A Cloud enrollment set `RELAY_NODE_TOKEN` and no workspace key, so the pin was skipped and the broker, left with no key candidates, minted a fresh workspace — re-homing an enrolled node out of its repository's workspace. And a fresh directory never consulted the machine-global store, so a first start minted a new workspace even when the machine already had an active one selected. Both now resolve through one ladder, documented in `resolveWorkspaceSelection` and in the CLI README: 1. --workspace-key / --wk 2. RELAY_WORKSPACE_KEY > AGENT_RELAY_WORKSPACE_KEY > RELAY_API_KEY 3. <project>/.agentworkforce/relay/workspace-key.json 4. the active entry in ~/.agentworkforce/relay/workspaces.json 5. create a workspace — only when nothing above resolves The repository pin always outranks the machine-global entry, and a node token selects node identity only, so it no longer suppresses steps 1-4. Startup prints the winning source (flag name, variable, or path — never key material) and says explicitly when it created a workspace rather than joined one. Each start now records the resolved workspace id on the pin, so a later start can detect a stored enrollment pointing at a different workspace and stop with both source paths named instead of silently choosing one. Fixes #1406 Fixes #1378 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5FD3oEnWbMbAhjsdtmmiP
agent-relay node agent spawn could report success while the spawned worker process had already exited (e.g. a wrapper that fails to launch its harness) — Command::spawn only proves the wrapper was created, not that it survived. Add a brief stability window after spawn that non-blockingly checks the child is still alive before reporting success; if it already exited, remove the stale registry entry and return the real error (exit status + log path) instead of letting node agent list briefly advertise a dead process. Verified: - cargo test --package agent-relay-broker worker:: (62/62, 4 consecutive clean runs, plus 5 isolated runs of the specific new tests) - Real integration test: RELAY_INTEGRATION_REAL_CLI=1 node --test tests/integration/broker/dist/cli-spawn.test.js (missing-CLI rejection path, 21.5s, real broker)
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
WorkerRegistry::spawnresult out ofspawn_worker_from_requestspawn:<harness>invocations from that result instead of bare registry-key presencespawn_failed: <detail>with the startup exit status and worker log path from fix(broker): verify worker process before spawn success #1429's confirmation pathDependency
Depends on #1429 and must not merge before #1429. This branch is stacked directly on #1429's head commit because it reuses the process-stability confirmation introduced there.
Fixes #1430.
Validation
env -u AGENT_RELAY_MCP_COMMAND cargo test --package agent-relay-broker— 855 passed, 0 failed, 4 ignored; integration targets also passedenv -u AGENT_RELAY_MCP_COMMAND cargo clippy --package agent-relay-broker --lib -- -D warningscargo fmt --all -- --checkgit diff --checkNote: the inherited worker environment sets
AGENT_RELAY_MCP_COMMAND; leaving it set makes 12 existing tests expectnpxbut observe the injected local Node command. Unsetting that development override gives the repository's neutral test environment and the full green result above.