Skip to content

fix(harness-driver): resolve installed broker under mise launchers - #1426

Merged
khaliqgant merged 4 commits into
mainfrom
fix/node-broker-resolution-and-fleet-spawn
Aug 4, 2026
Merged

fix(harness-driver): resolve installed broker under mise launchers#1426
khaliqgant merged 4 commits into
mainfrom
fix/node-broker-resolution-and-fleet-spawn

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • canonicalize package-manager entry points before resolving the platform broker optional dependency
  • fall back to broker binaries beside installed launchers and in standard Relay user install directories
  • add regression coverage and a patch changelog entry

Bug A evidence

Before, a clean globally installed CLI with its optional broker packages unavailable and a minimal PATH failed with:

Failed to start broker: @agent-relay/harness-driver could not find an agent-relay-broker binary for darwin-arm64

After deploying this harness-driver build into the same install, agent-relay node up --no-spawn --background started PID 95430, node status reported RUNNING and Node delivery CONNECTED, and fleet nodes --name no-optional-after reported the node online/live. The temporary node was stopped afterward.

Bug B investigation

No Bug B code is included. The original failing target was a different remote mini in a separate workspace; that node and exact invocation are unavailable. Targeted fleet spawn succeeded end to end against the currently available relay node from standalone 11.4.0, clean npm 11.4.0, and mise npm 11.2.0 clients; all three workers appeared in node agent list and were released.

The trace found two important diagnostics for a future reproduction:

  • workspace queries resolve explicit flag, environment, project session, then global active workspace, while targeted spawn requires and prefers an agent token that is already bound to one workspace
  • targeted spawn returns the immediate asynchronous invocation acknowledgement; a downstream broker failure is only visible by reading that invocation result
  • current broker caches node tokens by node id, workspace id, and engine URL, and clears/remints a rejected cache after a node-control 401

Validation

  • npx vitest run packages/harness-driver/src/broker-path.test.ts packages/cli/src/cli/commands/fleet.test.ts (25 passed)
  • npm run typecheck
  • npx prettier --check packages/harness-driver/src/broker-path.ts packages/harness-driver/src/broker-path.test.ts CHANGELOG.md
  • npm pack --dry-run in packages/harness-driver
  • git diff origin/main...HEAD --check

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 675eecf8-5e57-4ebc-8bf6-ae5048af1211

📥 Commits

Reviewing files that changed from the base of the PR and between 40a7100 and 33e0d0b.

📒 Files selected for processing (2)
  • packages/harness-driver/src/broker-path.test.ts
  • packages/harness-driver/src/broker-path.ts

📝 Walkthrough

Walkthrough

The broker resolver now canonicalizes launcher references and searches installer-managed locations after PATH lookup. Tests cover symlinked launchers, fallback binaries, PATH precedence, legacy installation paths, and process.execPath isolation. The changelog documents the patch.

Changes

Broker resolution

Layer / File(s) Summary
Canonical launcher resolution
packages/harness-driver/src/broker-path.ts, packages/harness-driver/src/broker-path.test.ts
Canonical paths support optional broker package lookup from symlinked launchers. Tests restore process.execPath and cover canonicalization.
Installer location fallback
packages/harness-driver/src/broker-path.ts, packages/harness-driver/src/broker-path.test.ts, CHANGELOG.md
Lookup checks PATH before installer-managed locations and retains legacy standalone fallback behavior. Tests cover launcher-adjacent, canonical-target, user-install, PATH-precedence, and legacy fallback cases. The changelog records the fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NodeUp as agent-relay node up
  participant Resolver as broker-path resolver
  participant Path as PATH
  participant Installer as Relay installer locations
  NodeUp->>Resolver: resolve broker binary
  Resolver->>Path: check broker executable
  Path-->>Resolver: path or not found
  Resolver->>Installer: check canonical launcher and user locations
  Installer-->>Resolver: path or not found
  Resolver-->>NodeUp: return broker binary path
Loading

Possibly related PRs

Suggested labels: size:L

Suggested reviewers: willwashburn

Poem

I hop through links where brokers hide,
Canonical paths become my guide.
By launcher, Node, or user bin,
I find the binary tucked within.
Tests guard each trail with care.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the harness-driver fix for broker resolution under mise launchers.
Description check ✅ Passed The description explains the change, evidence, investigation, and validation; the missing template checklist is non-critical.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/node-broker-resolution-and-fleet-spawn

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaliqgant
khaliqgant marked this pull request as ready for review August 4, 2026 06:49
@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Line 8: Update the unreleased changelog heading from “## [Unreleased - Patch]”
to “## [Unreleased]”, leaving release-level labeling for the released version
heading.

In `@packages/harness-driver/src/broker-path.ts`:
- Around line 120-127: Update getInstalledBinaryPaths to also add broker sibling
candidates derived from realpathSync(process.argv[1]) and
realpathSync(process.execPath), while retaining the existing symlink-path
candidates and uniqueness handling. Add a regression test covering a symlinked
launcher with an unavailable optional package, verifying the canonical-target
sibling broker is found.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f005fdb4-44d2-42b3-b651-f7ff3feca8cc

📥 Commits

Reviewing files that changed from the base of the PR and between f0179c8 and 40a7100.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/harness-driver/src/broker-path.test.ts
  • packages/harness-driver/src/broker-path.ts

Comment thread CHANGELOG.md
Comment thread packages/harness-driver/src/broker-path.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40a7100f0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/harness-driver/src/broker-path.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/harness-driver/src/broker-path.ts
Comment thread packages/harness-driver/src/broker-path.ts Outdated
@khaliqgant
khaliqgant merged commit b0151ff into main Aug 4, 2026
36 checks passed
@khaliqgant
khaliqgant deleted the fix/node-broker-resolution-and-fleet-spawn branch August 4, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant