Skip to content

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

Merged
khaliqgant merged 3 commits into
mainfrom
feat/broker-node-kind
Oct 27, 2026
Merged

khaliqgant merged 3 commits 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
  • claude session ad12d71a · contributor · ran gh pr commands · last active 2026-10-27

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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f540b73-411a-4e0f-be76-51389226153a
Commits

Reviewing files that changed from the base of the PR and between 7a5f8a9 and 35a4d07.

Files selected for processing: 1
  • CHANGELOG.md
Files skipped from review as they are similar to previous changes: 1
  • CHANGELOG.md

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

Merge Risk: Minimal · up to 35a4d

Broker spawn capabilities retain their declared node kind across registration and heartbeats. No issue identified here prevents merging after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description check Passed The description includes the required Summary, Test Plan, RelayFlow Proof, and Screenshots sections. It explains the implementation, test results, mutation checks, lint status, and RelayFlow evidence.…
Title check Passed The title clearly and concisely describes the main change: broker spawn capabilities now declare node_kind as broker.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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 includes the required Summary, Test Plan, RelayFlow Proof, and Screenshots sections. It explains the implementation, test results, mutation checks, lint status, and RelayFlow evidence. The test checklist remains unchecked, but the detailed test results make the description mostly complete.

Finishing Touches
🧪 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

I’m a rabbit, pleased to see
Spawn kinds set to broker, neatly.
Old configured facts remain,
Tests observe the register train.
I hop through fields, then rest.
Clear metadata is the best.

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

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

The broker now adds metadata.configured.node_kind: "broker" to spawn:* capabilities that have no declared kind.

  • Spawn capabilities identify broker nodes for Cloud placement.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@khaliqgant
khaliqgant merged commit 6c84773 into main Oct 27, 2026
118 of 120 checks passed
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