Skip to content

refactor(broker): move Rust crate under crates/broker#903

Merged
willwashburn merged 1 commit into
mainfrom
codex/issue-874-broker-crate
May 19, 2026
Merged

refactor(broker): move Rust crate under crates/broker#903
willwashburn merged 1 commit into
mainfrom
codex/issue-874-broker-crate

Conversation

@willwashburn
Copy link
Copy Markdown
Member

Summary

  • Move the Rust broker package from root src/*.rs into crates/broker/src.
  • Convert the root Cargo manifest into a workspace with crates/broker as the default member.
  • Update include paths, CI path filters, SDK source-checkout binary detection, and broker source path references.

Closes #874

Verification

  • cargo build --bin agent-relay-broker
  • cargo test
  • cargo fmt --all -- --check
  • cargo clippy -- -D warnings
  • npm run build:rust
  • cargo test --release
  • npm run typecheck
  • npm run -w @agent-relay/sdk check
  • npm exec -- vitest run --config vitest.config.ts src/__tests__/broker-path.test.ts from packages/sdk
  • npx prettier --check ... for touched TS/YAML files

@willwashburn willwashburn requested a review from khaliqgant as a code owner May 19, 2026 00:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

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: 1c63ebce-e020-42f6-9605-ebc67f396b15

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf8238 and 8929d13.

📒 Files selected for processing (56)
  • .github/workflows/build-broker-binary.yml
  • .github/workflows/publish.yml
  • .github/workflows/rust-fmt-fix.yml
  • .trajectories/completed/2026-05/traj_jmf9pyt3zikn.json
  • .trajectories/completed/2026-05/traj_jmf9pyt3zikn.md
  • .trajectories/index.json
  • Cargo.toml
  • crates/broker/Cargo.toml
  • crates/broker/src/auth.rs
  • crates/broker/src/broker.rs
  • crates/broker/src/broker_tests.rs
  • crates/broker/src/cli_mcp_args.rs
  • crates/broker/src/config.rs
  • crates/broker/src/control.rs
  • crates/broker/src/conversation_log.rs
  • crates/broker/src/crash_insights.rs
  • crates/broker/src/dedup.rs
  • crates/broker/src/events.rs
  • crates/broker/src/helpers.rs
  • crates/broker/src/inject.rs
  • crates/broker/src/lib.rs
  • crates/broker/src/listen_api.rs
  • crates/broker/src/main.rs
  • crates/broker/src/message_bridge.rs
  • crates/broker/src/metrics.rs
  • crates/broker/src/multi_workspace.rs
  • crates/broker/src/priorities.rs
  • crates/broker/src/protocol.rs
  • crates/broker/src/pty.rs
  • crates/broker/src/pty_worker.rs
  • crates/broker/src/queue.rs
  • crates/broker/src/readiness.rs
  • crates/broker/src/redact.rs
  • crates/broker/src/relaycast_ws.rs
  • crates/broker/src/replay_buffer.rs
  • crates/broker/src/routing.rs
  • crates/broker/src/scheduler.rs
  • crates/broker/src/snapshot.rs
  • crates/broker/src/snippets.rs
  • crates/broker/src/spawner.rs
  • crates/broker/src/supervisor.rs
  • crates/broker/src/swarm.rs
  • crates/broker/src/swarm_tui.rs
  • crates/broker/src/telemetry.rs
  • crates/broker/src/types.rs
  • crates/broker/src/wait.rs
  • crates/broker/src/worker.rs
  • crates/broker/src/worker_request.rs
  • crates/broker/src/worker_tests.rs
  • crates/broker/src/wrap.rs
  • crates/broker/tests/continuity.rs
  • packages/sdk/src/__tests__/broker-path.test.ts
  • packages/sdk/src/broker-path.ts
  • packages/sdk/src/cli-registry.ts
  • scripts/spawn-reviewers.ts
  • tests/integration/broker/bug-repro.sh

📝 Walkthrough

Walkthrough

This PR relocates the Rust broker crate from src/ into crates/broker/, converts the root Cargo.toml into a workspace manifest, updates test fixture loading paths, enhances SDK binary detection for the new layout, and adjusts all dependent workflows and scripts to reference the reorganized structure.

Changes

Broker Crate Reorganization

Layer / File(s) Summary
Root workspace and broker crate manifests
Cargo.toml, crates/broker/Cargo.toml
Root Cargo.toml transitions from single-crate package to workspace with crates/broker as the only member. New crates/broker/Cargo.toml defines the agent-relay-broker package with library and binary targets, and specifies runtime dependencies including axum, tokio, reqwest, serde, tracing, and Unix-specific packages for pty/nix support.
Broker source test fixture path adjustments
crates/broker/src/listen_api.rs, crates/broker/src/main.rs, crates/broker/src/message_bridge.rs, crates/broker/src/snapshot.rs, crates/broker/src/snippets.rs
Multiple test fixtures loaded via include_str! are updated to use new relative paths (e.g., ../../../packages/contracts/fixtures/ instead of ../packages/contracts/fixtures/) reflecting the crate's nested location under crates/broker/.
SDK binary path detection for new broker layout
packages/sdk/src/broker-path.ts
New findAncestorSourceCheckoutRoot() helper walks up to 8 parent directories to locate a workspace root. isSourceCheckoutRoot now requires crates/broker/src/main.rs instead of src/main.rs. Development binary search is seeded from the discovered ancestor root rather than from process.cwd() directly.
SDK tests for broker binary path detection
packages/sdk/src/__tests__/broker-path.test.ts
Import formatting consolidated, JSON string corrected, path normalization assertion added. New test constructs a simulated source-checkout directory structure (workspace + crate layout) in a temp directory, changes CWD into the SDK subdirectory, and verifies binary path resolves to the expected target/release/ location.
GitHub workflow path trigger updates
.github/workflows/build-broker-binary.yml, .github/workflows/rust-fmt-fix.yml, .github/workflows/publish.yml
build-broker-binary.yml changes push trigger from src/** to crates/broker/**, rust-fmt-fix.yml adds crates/broker/Cargo.toml and Cargo.lock to pull_request filters, and publish.yml comment references are corrected to crates/broker/src/telemetry.rs.
CLI registry and review/test scripts updated for new paths
packages/sdk/src/cli-registry.ts, scripts/spawn-reviewers.ts, tests/integration/broker/bug-repro.sh
cli-registry.ts comments and nonInteractiveArgs are reformatted; spawn-reviewers.ts review prompts updated to include crates/broker/src patterns; bug-repro.sh adds BROKER_SRC_DIR variable and updates Tests 8–11 to search crates/broker/src for source code patterns and function definitions.
Trajectory metadata records completed refactoring
.trajectories/completed/2026-05/traj_jmf9pyt3zikn.json, .trajectories/completed/2026-05/traj_jmf9pyt3zikn.md, .trajectories/index.json
New trajectory record documents issue 874 completion with task metadata, agent/chapter structure, decision notes describing the broker relocation and workspace setup, and path/reference updates. Index.json is updated with new timestamp and trajectory entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • khaliqgant

Poem

🐰 hops into crates/broker/
A cozy warren for the relay-broker to dwell,
No more mingled with TypeScript,
The workspace now rings its bell!
Fixtures follow their new paths with glee,
SDK detects, walks ancestors with ease—
Refactor complete, as organized as can be! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 'refactor(broker): move Rust crate under crates/broker' directly and clearly describes the primary change, which is moving the Rust broker crate from root src/ to crates/broker/.
Description check ✅ Passed The PR description includes a clear summary of changes and comprehensive verification steps, matching the template structure with summary and test/verification details.
Linked Issues check ✅ Passed The PR fully addresses issue #874: Rust broker moved to crates/broker, root Cargo.toml converted to workspace, build command still works, paths updated in SDK/tests, and no functional refactoring beyond path updates.
Out of Scope Changes check ✅ Passed All changes are scoped to relocating the broker crate and updating references; trajectory metadata files and script updates are all related to the refactoring objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-874-broker-crate

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

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@willwashburn willwashburn merged commit 040e6d9 into main May 19, 2026
49 checks passed
@willwashburn willwashburn deleted the codex/issue-874-broker-crate branch May 19, 2026 00:42
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.

refactor(broker): move Rust broker into crates/broker

1 participant