Skip to content

Fix Command Router HTTP API count-only queries and parameter sync#1188

Merged
marcocapozzoli merged 4 commits into
masterfrom
masc/fix-http-api
Jul 22, 2026
Merged

Fix Command Router HTTP API count-only queries and parameter sync#1188
marcocapozzoli merged 4 commits into
masterfrom
masc/fix-http-api

Conversation

@marcocapozzoli

Copy link
Copy Markdown
Collaborator

No description provided.

@marcocapozzoli
marcocapozzoli requested a review from ccgsnet July 21, 2026 23:55
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@marcocapozzoli, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c45dda0-4320-4b0a-b5c9-c6580bee6858

📥 Commits

Reviewing files that changed from the base of the PR and between fe052eb and da4e2ee.

📒 Files selected for processing (1)
  • src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.cc

Walkthrough

HTTP command routing now synchronizes per-peer parameters and returns structured polling results. COUNT responses support count-only execution totals, while HTTP handlers and tests consume the richer result contract across streaming, get/set, error, and parameter synchronization paths.

Changes

HTTP router result flow

Layer / File(s) Summary
Count response handling
src/agents/command_router/BusCommandRouterProxy.*
Router proxies handle COUNT responses, validate and store totals, and track count receipt state.
Structured stream polling
src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.*
poll_stream returns PollStreamResult for success, failure, streamed answers, and count-only totals.
HTTP execution integration and validation
src/agents/command_router/BusCommandRouterProcessor.cc, src/agents/command_router/http_api/CommandRouterHttpAPI.*, src/tests/cpp/command_router_http_api_test.cc
HTTP execution consumes structured results, count-only completions use returned totals, dispatches synchronize parameters, and tests cover the updated flows.

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

Sequence Diagram(s)

sequenceDiagram
  participant CommandRouterHttpAPI
  participant BusCommandRouterProxyStreamPoller
  participant BusCommandRouterProxy
  participant RemotePeer
  CommandRouterHttpAPI->>BusCommandRouterProxyStreamPoller: execute command and poll stream
  BusCommandRouterProxyStreamPoller->>RemotePeer: dispatch router command
  RemotePeer-->>BusCommandRouterProxy: answers or COUNT response
  BusCommandRouterProxyStreamPoller-->>CommandRouterHttpAPI: PollStreamResult
Loading

Possibly related PRs

  • singnet/das#1165: Updates the same HTTP execution pipeline used by the structured polling result flow.
  • singnet/das#1168: Modifies in-process HTTP routing and caller-proxy setup extended here with parameter synchronization.
  • singnet/das#1175: Changes the CommandRouterHttpAPI execution flow around router command handling.

Suggested reviewers: andre-senna, ccgsnet

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so there is nothing to assess against the changeset. Add a short description of the HTTP API and stream-polling changes so reviewers can confirm the intent.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: count-only query handling and HTTP parameter synchronization.
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.
Tests For Behavior Changes ✅ Passed PASS — behavior changes in BusCommandRouterProxyStreamPoller.cc are covered by new/updated C++ tests in src/tests/cpp/command_router_http_api_test.cc, including count-only and sync cases.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch masc/fix-http-api

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.

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/agents/command_router/BusCommandRouterProcessor.cc (1)

39-48: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Copy peer parameters while holding the mutex

parameters_for_peer() returns a Properties& after releasing router_parameters_mutex, but both dispatch_http_command() and run_command() copy from that reference later. handle_set() writes back to the same router_parameters_by_peer entry under the same mutex, so overlapping requests for one peer can race on the Properties copy. Return Properties by value from the locked section (or add a locked copy helper) and add a concurrent set/query test.

🤖 Prompt for 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.

In `@src/agents/command_router/BusCommandRouterProcessor.cc` around lines 39 - 48,
Change BusCommandRouterProcessor::parameters_for_peer() to copy the peer
parameters while router_parameters_mutex is held and return Properties by value,
then update dispatch_http_command() and run_command() callers to use the value.
Add a concurrent test covering overlapping handle_set() and query/dispatch
operations for the same peer.

Source: Path instructions

🤖 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 `@src/agents/command_router/BusCommandRouterProxy.cc`:
- Around line 65-74: Update BusCommandRouterProxy::count_answer to parse and
validate the COUNT argument before calling set_count: reject negative or
otherwise invalid values through the existing error mechanism, then convert only
validated non-negative input to the unsigned count type. Add coverage for
negative and invalid COUNT arguments.

---

Outside diff comments:
In `@src/agents/command_router/BusCommandRouterProcessor.cc`:
- Around line 39-48: Change BusCommandRouterProcessor::parameters_for_peer() to
copy the peer parameters while router_parameters_mutex is held and return
Properties by value, then update dispatch_http_command() and run_command()
callers to use the value. Add a concurrent test covering overlapping
handle_set() and query/dispatch operations for the same peer.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dd2dca6e-0945-4c2e-a8d5-b98f0f7908fb

📥 Commits

Reviewing files that changed from the base of the PR and between b89bc77 and 47643c9.

📒 Files selected for processing (8)
  • src/agents/command_router/BusCommandRouterProcessor.cc
  • src/agents/command_router/BusCommandRouterProxy.cc
  • src/agents/command_router/BusCommandRouterProxy.h
  • src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.cc
  • src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.h
  • src/agents/command_router/http_api/CommandRouterHttpAPI.cc
  • src/agents/command_router/http_api/CommandRouterHttpAPI.h
  • src/tests/cpp/command_router_http_api_test.cc

Comment thread src/agents/command_router/BusCommandRouterProxy.cc

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

🧹 Nitpick comments (1)
src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.cc (1)

12-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover both metta-output branches with focused tests.

The supplied regression test covers only populate_metta_mapping == false with an empty mapping. Add cases for populate_metta_mapping == true and for populate_metta_mapping == false with a populated metta_expression map, asserting that the serialized answer contains the MeTTa value.

As per coding guidelines, test updates are required when production code changes. As per path instructions, behavior changes should have matching *_test.cc coverage.

🤖 Prompt for 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.

In `@src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.cc`
around lines 12 - 14, Add focused tests for should_use_metta_output covering
both remaining branches: populate_metta_mapping == true and
populate_metta_mapping == false with a populated answer.metta_expression map. In
each case, assert that the serialized answer includes the expected MeTTa value,
using the existing regression test setup and corresponding *_test.cc
conventions.

Sources: Coding guidelines, Path instructions

🤖 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.

Nitpick comments:
In `@src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.cc`:
- Around line 12-14: Add focused tests for should_use_metta_output covering both
remaining branches: populate_metta_mapping == true and populate_metta_mapping ==
false with a populated answer.metta_expression map. In each case, assert that
the serialized answer includes the expected MeTTa value, using the existing
regression test setup and corresponding *_test.cc conventions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4dd3923-ee4e-4ecb-ba69-9f13c19c0249

📥 Commits

Reviewing files that changed from the base of the PR and between 8fcf11a and fe052eb.

📒 Files selected for processing (2)
  • src/agents/command_router/http_api/BusCommandRouterProxyStreamPoller.cc
  • src/tests/cpp/command_router_http_api_test.cc
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/cpp/command_router_http_api_test.cc

@marcocapozzoli
marcocapozzoli merged commit 2d8f7bf into master Jul 22, 2026
4 of 5 checks passed
@marcocapozzoli
marcocapozzoli deleted the masc/fix-http-api branch July 22, 2026 21:28
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.

2 participants