feat(broker): align reported version with product release line#911
Conversation
The broker previously reported its Cargo crate version (3.0.0) in health/session/telemetry payloads even when shipped inside agent-relay 6.x, making install debugging and telemetry confusing. - Add util::version::broker_version() that reads AGENT_RELAY_VERSION at compile time and falls back to CARGO_PKG_VERSION for dev builds. - Route all listen_api, telemetry, and swarm version reporting through the helper and expose --version on the CLI. - Pass AGENT_RELAY_VERSION through publish, build-broker-binary, and package-validation workflows (plus Cross.toml for aarch64 musl), and fail validation if the binary does not report the release version. Closes #904 https://claude.ai/code/session_01Cs6t4GfxUHbnptziCekJAR
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a compile-time AGENT_RELAY_VERSION injected by CI/cross builds; introduces util::version BROKER_VERSION and broker_version(); updates CLI, /health, swarm handshake, and telemetry to use broker_version(); package-validation ensures the built binary reports the expected product version. ChangesBroker version alignment with product releases
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
- Drop dead `needs.build.outputs.new_version` reference in package-validation.yml; standalone-macos-smoke only `needs: changes`, so the expression was always empty. Read package.json directly. - Treat an empty `AGENT_RELAY_VERSION` env var as unset so a stray unresolved CI expression cannot surface as an empty broker version string; fall back to CARGO_PKG_VERSION instead. https://claude.ai/code/session_01Cs6t4GfxUHbnptziCekJAR
barryollama
left a comment
There was a problem hiding this comment.
Code Review: Approved ✅
This PR effectively solves the version alignment issue described in #904.
Summary
The broker crate now correctly reports the product release-line version (e.g., 6.2.x) instead of the internal Cargo crate version (3.0.0) in health, session, telemetry payloads, and the --version output.
What’s Reviewed
Correctness
- The
version.rshelper usesoption_env!with an empty-string guard — this correctly handles CI edge cases where the env var might be set but unresolved. - All direct
env!("CARGO_PKG_VERSION")calls have been replaced with the centralized helper.
Security
- No hardcoded secrets or credentials introduced.
- No new attack surface — all changes are compile-time constant resolution.
Code Quality
- Clear documentation in
version.rsexplaining the fallback strategy. - Unit tests verify non-empty output and compile-time env matching.
- Consistent naming (
broker_version,BROKER_VERSION).
CI/CD Integration
Cross.tomlproperly forwardsAGENT_RELAY_VERSIONto aarch64 cross-compile containers.package-validation.ymlincludes a verification step that fails the build if versions don’t match — excellent guardrail.- The
needs: builddependency inpublish.ymlworkflow ensures the broker build gets the correctnew_versionoutput.
Testing
- Local manual verification steps noted in PR description.
- CI verification via
package-validation.ymlcovers the acceptance criteria.
Minor Suggestions
(none blocking)
- Consider documenting the version override behavior in
crates/broker/README.mdor top-levelBROKING.mdfor developers building from source. - In
build-broker-binary.yml, the fallback tonpm pkg get versionon branch pushes ensures the version is always meaningful — good defensive pattern.
Verdict
Clean implementation with good test coverage and CI guardrails. Ready to merge.
Closes #904.
Summary
The Rust broker crate previously reported its Cargo package version (
3.0.0) in health, session, and telemetry payloads — even when shipped inside anagent-relay/@agent-relay/sdk6.x release. That made install/support debugging and telemetry filtering confusing.This PR embeds the product release-line version into the broker at compile time, keeping the Cargo crate version as a developer-build fallback rather than the source of truth.
Changes
crates/broker/src/util/version.rsexposing aBROKER_VERSIONconst andbroker_version()accessor, backed byoption_env!("AGENT_RELAY_VERSION")withCARGO_PKG_VERSIONas the fallback.env!("CARGO_PKG_VERSION")call inlisten_api.rs(health +/api/config),telemetry.rs, andswarm.rswith the helper.--versiononagent-relay-brokerso packagers / smoke tests can verify the shipped version.AGENT_RELAY_VERSIONthroughpublish.yml(thebuild-brokerjob nowneeds: buildso it can readneeds.build.outputs.new_version),build-broker-binary.yml(uses the dispatch tag orpackage.jsonversion), andpackage-validation.yml(now fails ifbroker --versiondoes not matchpackage.json).Cross.tomlpassthrough updated so the env var reaches the aarch64-musl cross container.Acceptance criteria from #904
agent-relay/@agent-relay/sdkrelease that shipped them (workflow setsAGENT_RELAY_VERSIONfromneeds.build.outputs.new_version).cargo build --bin agent-relay-brokerstill reports a reasonable fallback (CARGO_PKG_VERSION)./api/config, health/session, and telemetry use one helper instead of directenv!calls.package-validation.ymlverifiesbroker --versionmatches the release version.Test plan
cargo test -p agent-relay-broker --lib— 625 existing + 2 new tests pass.cargo clippy -p agent-relay-broker --bin agent-relay-broker -- -D warningsclean.AGENT_RELAY_VERSION=6.2.99 cargo build→agent-relay-broker --versionreports6.2.99; plaincargo buildreports3.0.0(the crate fallback).https://claude.ai/code/session_01Cs6t4GfxUHbnptziCekJAR
Generated by Claude Code