Skip to content

feat(broker): declare node_kind broker in spawn capability metadata - #1981

Open
khaliqgant wants to merge 1 commit into
mainfrom
feat/broker-node-kind
Open

khaliqgant wants to merge 1 commit into
mainfrom
feat/broker-node-kind

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Summary

AgentWorkforce/cloud#5310 makes Cloud spawn placement refuse an unclaimed node unless one of its spawn:<harness> capabilities declares metadata.configured.node_kind ("desktop" or "broker"). The CLI broker sent metadata: None on its spawn capacity, so every unclaimed CLI broker became non-spawnable until someone ran agent-relay node claim.

  • build_node_register (crates/broker/src/node_control.rs) now runs every capability through a new helper, spawn_capability_metadata. On spawn:* capabilities it sets metadata.configured.node_kind = "broker" only when no kind is already declared, and it leaves the rest of configured (and live) untouched. Non-spawn capabilities pass through unchanged.
  • Every register and re-register path goes through build_node_register, and the heartbeat descriptor reuses the registered capabilities, so the declaration is on both frames.
  • Relay Desktop builds its own node frames in the relay-desktop repo (probe/src/relay/spawn/wire.rs, which declares node_kind: "desktop"). It does not use this code path. If a manifest that reaches the broker already declares desktop, that value is preserved (covered by a test).

Tests

  • New: build_node_register_declares_broker_node_kind_on_every_spawn_capability checks the wire JSON and the heartbeat. build_node_register_preserves_declared_node_kind_and_configured_facts checks that a desktop kind and existing configured/live facts are preserved. Updated: build_node_register_prefers_manifest_identity.
  • cargo test -p agent-relay-broker --lib -- node_control::tests runtime::init: 121 passed, 0 failed.
  • Mutation 1 (helper returns metadata unchanged): 3 tests fail (declares_broker_node_kind…, preserves_declared…, prefers_manifest_identity).
  • Mutation 2 (always overwrite node_kind): only preserves_declared_node_kind… fails, with left: {"node_kind":"broker",…} right: {"node_kind":"desktop",…}. The other tests surviving is expected, because they never declare a kind.
  • cargo fmt --check: OK. cargo clippy --lib --bins -D warnings: OK. --all-targets reports 2 existing test-code lints (node_control.rs:8057, :8677) from older commits. This diff does not touch them.

RelayFlow proof

  • Change type: feature
  • RelayFlow case: 5310-broker-node-kind

The case runs the broker artifact against a fake Relaycast, accepts the first node.register, and records each capability's metadata.configured.node_kind. I verified it locally with the fix mutated out (base) and with it in place (head). Both runs exited 0:

  • base: absent spawn_capabilities_state_no_node_kind. All six spawn:* have node_kind: null.
  • head: fixed spawn_capabilities_declare_broker_node_kind. All six spawn:* declare "broker". release, native-delivery and delivery-cursor capabilities stay null.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff


Note

Low Risk
Narrow registration-metadata change with tests and a relayflow proof; only affects spawn capability wire shape for brokers missing node_kind.

Overview
Fixes Cloud spawn placement for unclaimed CLI brokers after cloud#5310 started requiring metadata.configured.node_kind on spawn:<harness> capabilities.

build_node_register now runs capabilities through spawn_capability_metadata, which sets configured.node_kind to "broker" only on spawn:* entries when no kind is already present; existing values (e.g. "desktop") and other configured/live metadata are unchanged. Non-spawn capabilities are untouched. Because registration and heartbeats reuse this path, the declaration appears on node.register and heartbeat capability snapshots.

Adds unit tests for default injection, preservation of declared kinds/facts, and an updated identity test; adds RelayFlow case 5310-broker-node-kind that observes the first node.register from a broker binary. CHANGELOG documents the patch under Unreleased.

Reviewed by Cursor Bugbot for commit 57cd580. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • claude session 942cd2fb · opened via gh pr create · last active 2026-10-18

Cloud placement (cloud#5310) refuses an unclaimed node whose spawn
capabilities state no metadata.configured.node_kind. build_node_register
now defaults configured.node_kind to "broker" on every spawn:<harness>
capability, preserving any kind the manifest already declares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@greptile-apps greptile-apps 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.

khaliqgant has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T05:36:08.137854Z 57cd580 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aef84a42-40ee-41d5-8142-8054c2071503
📥 Commits

Reviewing files that changed from the base of the PR and between c1ffabb and 57cd580.

📒 Files selected for processing: 4
  • CHANGELOG.md
  • crates/broker/src/node_control.rs
  • tests/relayflows/cases/5310-broker-node-kind/case.json
  • tests/relayflows/cases/5310-broker-node-kind/run.mjs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The broker now adds configured.node_kind: "broker" to spawn: capability metadata when no kind is present. It preserves existing kinds and other metadata. Unit tests and a relayflow case cover the registration behavior.

Changes: Broker spawn capability metadata

Layer / File(s) Summary
Default and preserve spawn metadata
crates/broker/src/node_control.rs, CHANGELOG.md
build_node_register adds the broker default to spawn: capability metadata when node_kind is absent. Tests cover preservation of existing kinds and other metadata, as well as non-spawn capabilities.
Relayflow registration validation
tests/relayflows/cases/5310-broker-node-kind/*
The relayflow runner checks the broker’s first registration against local HTTP and WebSocket stand-ins. The case expects missing spawn kinds on the base and broker kinds on the fixed revision.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 57cd5

The broker node-kind declaration is mergeable after normal checks; no actionable risk is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: broker spawn capabilities now declare node_kind as broker.
Description check Passed The description explains the change, test coverage, RelayFlow proof, and validation results. It includes the required Summary and RelayFlow Proof content. The Test Plan uses a Tests heading and does n…
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.
Full details: Description check

Explanation

The description explains the change, test coverage, RelayFlow proof, and validation results. It includes the required Summary and RelayFlow Proof content. The Test Plan uses a Tests heading and does not include the template checklist, but the required testing information is present. Screenshots are not applicable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the broker’s list,
And finds each spawn kind not missed.
Old metadata stays in place,
New broker kinds join the race.
The relayflow records the trace,
Then hops away at an easy pace.

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

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

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

Devin Review

@capy-ai capy-ai 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.

Capy found no issues.

Open in Capy

This branch has not been deployed

No deployments
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