Skip to content

fix(acp-nats-server): preserve ACP HTTP compatibility#135

Merged
yordis merged 4 commits into
mainfrom
yordis/acp-1064-audit
Apr 23, 2026
Merged

fix(acp-nats-server): preserve ACP HTTP compatibility#135
yordis merged 4 commits into
mainfrom
yordis/acp-1064-audit

Conversation

@yordis
Copy link
Copy Markdown
Member

@yordis yordis commented Apr 23, 2026

  • Align the ACP HTTP transport with the current upstream protocol semantics so remote clients do not rely on superseded request and streaming behavior.
  • Preserve interoperability between this server and ACP clients that now expect JSON initialize responses, immediate follow-up POST acknowledgements, and a connection-scoped event stream.
  • Keep the crate documentation and coverage pointed at the protocol shape the repo is intended to support.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 23, 2026

PR Summary

Medium Risk
Changes ACP Streamable HTTP wire semantics (response codes/content-types, SSE routing, and header requirements), which can break clients and affects core transport behavior. Logic now injects IDs into JSON-RPC results and drops/filters undeliverable responses based on GET listener availability.

Overview
Updates ACP Streamable HTTP to match newer protocol expectations: POST /acp now returns JSON 200 OK only for initialize (augmenting the JSON-RPC result with connectionId), while all follow-up POSTs return 202 Accepted immediately and deliver their JSON-RPC responses over a connection-scoped GET /acp SSE stream.

Refactors SSE fanout from session-scoped listeners to a single per-connection listener set, removes the priming/empty SSE frame behavior, relaxes POST Accept validation, and adds session/connection ID injection into successful responses (with logging when a response can’t be delivered due to missing/stalled GET listeners). Tests and README are updated to reflect the new handshake and streaming flow.

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@yordis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 19 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 19 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b6fd6d40-49c5-44f7-9708-598c65f8c7fd

📥 Commits

Reviewing files that changed from the base of the PR and between 8375101 and cbcd881.

📒 Files selected for processing (1)
  • rsworkspace/crates/acp-nats-server/src/transport.rs

Walkthrough

The PR refactors the ACP NATS server's HTTP transport architecture from SSE-based response streaming to JSON-only POST responses combined with asynchronous delivery via a separate, connection-scoped GET stream. POST /acp returns 202 Accepted for most operations (delivering results asynchronously) and 200 OK with JSON for initialization, while session-scoped listeners are replaced with a flat, connection-level listener list.

Changes

Cohort / File(s) Summary
Documentation
rsworkspace/crates/acp-nats-server/README.md
Updated HTTP behavior: POST now returns JSON-only (200 OK for initialize, 202 Accepted for others), with asynchronous JSON-RPC responses delivered via connection-scoped GET /acp stream instead of direct SSE bodies. Removed session-scoped listener semantics and SSE priming event documentation.
Test Refactoring
rsworkspace/crates/acp-nats-server/src/main.rs
Updated test infrastructure to parse JSON directly from POST responses and consume JSON-over-SSE events from GET streams using next_json_sse_event. Renamed tests to reflect new semantics (initialize returns JSON; session/new and session/load return 202). Session broadcast test refactored to open independent GET streams before issuing POST requests.
Transport Implementation
rsworkspace/crates/acp-nats-server/src/transport.rs
Refactored HTTP flow: HttpPostOutcome now contains only a Json variant; POST returns JSON instead of SSE streams. Removed session-ID routing from HttpGet and ManagerRequest::HttpGet; replaced per-session listener maps with flat listener list. Added PendingResponseContext to inject connectionId and sessionId into JSON-RPC results. Simplified dispatch_to_get_listeners broadcast logic. Removed SSE priming/empty-frame state machines and Accept header validation.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Server as HTTP Server
    participant NATS as NATS Backend

    rect rgba(100, 150, 200, 0.5)
    Note over Client,NATS: New Flow: JSON POST + Async GET Stream
    end

    Client->>Server: POST /acp (initialize request)<br/>with Acp-Connection-Id
    Server->>NATS: Forward initialize request
    NATS-->>Server: Initialize response
    Server->>Server: Inject connectionId into result
    Server-->>Client: 200 OK + JSON response

    Client->>Server: GET /acp (opens stream)<br/>with Acp-Connection-Id
    activate Server
    Client->>Server: POST /acp (session/new request)
    Server->>NATS: Forward session request
    NATS-->>Server: Session response
    Server->>Server: Inject sessionId into result
    Server-->>Client: 202 Accepted (empty body)
    Server-->>Client: JSON-RPC result on GET stream
    deactivate Server
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

rust:coverage-baseline-reset

Poem

🐰 Hops with glee through JSON streams so clean,
No SSE mess in responses seen!
Async delivery, connection-scoped delight,
POST now quick, GET streams the sight!

🚥 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 'preserve ACP HTTP compatibility' directly reflects the main objective stated in the PR description: aligning with upstream protocol semantics and preserving interoperability between server and ACP clients.
Description check ✅ Passed The description clearly explains the changeset's purpose: aligning HTTP transport with upstream protocol semantics, preserving client interoperability, and updating documentation—all directly related to the file changes.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/acp-1064-audit

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

badge

Code Coverage Summary

Details
Filename                                                                      Stmts    Miss  Cover    Missing
--------------------------------------------------------------------------  -------  ------  -------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
crates/acp-nats/src/agent/mod.rs                                                 65       0  100.00%
crates/acp-nats/src/agent/ext_notification.rs                                    82       0  100.00%
crates/acp-nats/src/agent/logout.rs                                              49       0  100.00%
crates/acp-nats/src/agent/cancel.rs                                             101       0  100.00%
crates/acp-nats/src/agent/initialize.rs                                          79       0  100.00%
crates/acp-nats/src/agent/list_sessions.rs                                       47       0  100.00%
crates/acp-nats/src/agent/ext_method.rs                                          82       0  100.00%
crates/acp-nats/src/agent/set_session_config_option.rs                           67       0  100.00%
crates/acp-nats/src/agent/authenticate.rs                                        49       0  100.00%
crates/acp-nats/src/agent/fork_session.rs                                        94       0  100.00%
crates/acp-nats/src/agent/test_support.rs                                       267       0  100.00%
crates/acp-nats/src/agent/set_session_model.rs                                   67       0  100.00%
crates/acp-nats/src/agent/close_session.rs                                       63       0  100.00%
crates/acp-nats/src/agent/js_request.rs                                         283       0  100.00%
crates/acp-nats/src/agent/resume_session.rs                                      90       0  100.00%
crates/acp-nats/src/agent/set_session_mode.rs                                    67       0  100.00%
crates/acp-nats/src/agent/load_session.rs                                        89       0  100.00%
crates/acp-nats/src/agent/bridge.rs                                             123       4  96.75%   108-111
crates/acp-nats/src/agent/prompt.rs                                             471       0  100.00%
crates/acp-nats/src/agent/new_session.rs                                         82       0  100.00%
crates/acp-nats/src/lib.rs                                                       69       0  100.00%
crates/acp-nats/src/client_proxy.rs                                             186       0  100.00%
crates/acp-nats/src/in_flight_slot_guard.rs                                      32       0  100.00%
crates/acp-nats/src/acp_prefix.rs                                                50       0  100.00%
crates/acp-nats/src/error.rs                                                     82       0  100.00%
crates/acp-nats/src/pending_prompt_waiters.rs                                   134       0  100.00%
crates/acp-nats/src/req_id.rs                                                    39       0  100.00%
crates/acp-nats/src/session_id.rs                                                71       0  100.00%
crates/acp-nats/src/ext_method_name.rs                                           68       0  100.00%
crates/acp-nats/src/config.rs                                                   203       0  100.00%
crates/acp-nats/src/jsonrpc.rs                                                    6       0  100.00%
crates/acp-telemetry/src/trace.rs                                                30       3  90.00%   21-22, 30
crates/acp-telemetry/src/log.rs                                                  67       1  98.51%   41
crates/acp-telemetry/src/metric.rs                                               33       3  90.91%   28-29, 37
crates/acp-telemetry/src/service_name.rs                                         38       0  100.00%
crates/acp-telemetry/src/lib.rs                                                 165      28  83.03%   28-34, 56-59, 94, 99, 104, 118-133, 170, 173, 176, 182
crates/acp-telemetry/src/signal.rs                                                7       1  85.71%   43
crates/acp-nats/src/nats/subjects/subscriptions/all_agent_ext.rs                  9       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/global_all.rs                     9       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/one_agent.rs                     15       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/all_client.rs                     9       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/prompt_wildcard.rs                9       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/all_session.rs                    9       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/one_session.rs                   12       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/all_agent.rs                      9       0  100.00%
crates/acp-nats/src/nats/subjects/subscriptions/one_client.rs                    15       0  100.00%
crates/acp-nats-agent/src/connection.rs                                        1270       1  99.92%   607
crates/trogon-source-slack/src/server.rs                                        863       0  100.00%
crates/trogon-source-slack/src/config.rs                                         17       0  100.00%
crates/trogon-source-slack/src/signature.rs                                      77       0  100.00%
crates/acp-nats/src/nats/subjects/responses/cancelled.rs                         15       0  100.00%
crates/acp-nats/src/nats/subjects/responses/response.rs                          20       0  100.00%
crates/acp-nats/src/nats/subjects/responses/ext_ready.rs                         12       0  100.00%
crates/acp-nats/src/nats/subjects/responses/prompt_response.rs                   27       0  100.00%
crates/acp-nats/src/nats/subjects/responses/update.rs                            27       0  100.00%
crates/trogon-source-incidentio/src/incidentio_event_type.rs                     62       0  100.00%
crates/trogon-source-incidentio/src/incidentio_signing_secret.rs                 67       0  100.00%
crates/trogon-source-incidentio/src/config.rs                                    16       0  100.00%
crates/trogon-source-incidentio/src/server.rs                                   343       0  100.00%
crates/trogon-source-incidentio/src/signature.rs                                369       0  100.00%
crates/acp-nats-stdio/src/config.rs                                              66       0  100.00%
crates/acp-nats-stdio/src/main.rs                                               135      25  81.48%   56, 104-111, 117-119, 136, 165-184
crates/acp-nats/src/nats/subjects/commands/set_mode.rs                           15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/resume.rs                             15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/load.rs                               15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/cancel.rs                             15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/prompt.rs                             15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/set_model.rs                          15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/set_config_option.rs                  15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/fork.rs                               15       0  100.00%
crates/acp-nats/src/nats/subjects/commands/close.rs                              15       0  100.00%
crates/trogon-std/src/telemetry/http.rs                                         217       0  100.00%
crates/trogon-service-config/src/lib.rs                                          92       0  100.00%
crates/trogon-std/src/secret_string.rs                                           35       0  100.00%
crates/trogon-std/src/json.rs                                                    30       0  100.00%
crates/trogon-std/src/duration.rs                                                45       0  100.00%
crates/trogon-std/src/uuid.rs                                                     7       0  100.00%
crates/trogon-std/src/args.rs                                                    10       0  100.00%
crates/trogon-std/src/http.rs                                                    19       0  100.00%
crates/trogon-nats/src/nats_token.rs                                            157       0  100.00%
crates/trogon-nats/src/connect.rs                                                94       9  90.43%   22-23, 33, 60-65
crates/trogon-nats/src/messaging.rs                                             561       2  99.64%   144, 154
crates/trogon-nats/src/auth.rs                                                  114       0  100.00%
crates/trogon-nats/src/client.rs                                                 22      22  0.00%    50-86
crates/trogon-nats/src/subject_token_violation.rs                                17       0  100.00%
crates/trogon-nats/src/token.rs                                                   6       0  100.00%
crates/trogon-nats/src/mocks.rs                                                 284       0  100.00%
crates/trogon-source-github/src/signature.rs                                     61       0  100.00%
crates/trogon-source-github/src/config.rs                                        17       0  100.00%
crates/trogon-source-github/src/server.rs                                       328       0  100.00%
crates/trogon-source-gitlab/src/server.rs                                       397       0  100.00%
crates/trogon-source-gitlab/src/config.rs                                        17       0  100.00%
crates/trogon-source-gitlab/src/signature.rs                                     28       0  100.00%
crates/trogon-source-sentry/src/server.rs                                       311       0  100.00%
crates/trogon-source-sentry/src/signature.rs                                     54       0  100.00%
crates/trogon-source-sentry/src/sentry_client_secret.rs                          17       0  100.00%
crates/trogon-source-twitter/src/server.rs                                      525       0  100.00%
crates/trogon-source-twitter/src/config.rs                                       17       0  100.00%
crates/trogon-source-twitter/src/signature.rs                                    69       0  100.00%
crates/trogon-std/src/env/in_memory.rs                                           73       0  100.00%
crates/trogon-std/src/env/system.rs                                              17       0  100.00%
crates/trogon-std/src/fs/mem.rs                                                 216      10  95.37%   61-63, 77-79, 132-134, 157
crates/trogon-std/src/fs/system.rs                                               92       0  100.00%
crates/acp-nats-server/src/acp_connection_id.rs                                  45       0  100.00%
crates/acp-nats-server/src/main.rs                                              896      10  98.88%   96, 227-234, 433
crates/acp-nats-server/src/connection.rs                                        171      32  81.29%   76-83, 88-99, 115, 117-118, 123, 132-133, 138, 142, 146, 149, 157, 161, 164, 167-171, 207
crates/acp-nats-server/src/config.rs                                            137       9  93.43%   41, 50-61
crates/acp-nats-server/src/transport.rs                                        1833     113  93.84%   277, 444, 528, 546, 573, 627, 632, 651, 663, 782, 805-807, 859, 876-879, 974-977, 1051, 1054, 1057, 1066, 1070, 1073, 1076-1079, 1098, 1130-1133, 1141-1146, 1158-1162, 1166-1175, 1187-1188, 1206-1207, 1217, 1233-1237, 1265-1271, 1282, 1285-1292, 1297-1301, 1304-1309, 1319-1321, 1330, 1332-1333, 1415-1416, 1428-1429, 1449-1450, 1502-1518, 2214, 2257, 2309, 2364, 2376
crates/acp-nats/src/nats/subjects/client_ops/fs_read_text_file.rs                12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/session_update.rs                   12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/terminal_output.rs                  12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/fs_write_text_file.rs               12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/terminal_release.rs                 12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/terminal_kill.rs                    12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/session_request_permission.rs       12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/terminal_wait_for_exit.rs           12       0  100.00%
crates/acp-nats/src/nats/subjects/client_ops/terminal_create.rs                  12       0  100.00%
crates/acp-nats/src/nats/subjects/stream.rs                                      56       0  100.00%
crates/acp-nats/src/nats/subjects/mod.rs                                        362       0  100.00%
crates/acp-nats/src/jetstream/consumers.rs                                       91       0  100.00%
crates/acp-nats/src/jetstream/ext_policy.rs                                      26       0  100.00%
crates/acp-nats/src/jetstream/provision.rs                                       53       0  100.00%
crates/acp-nats/src/jetstream/streams.rs                                        163       4  97.55%   206-208, 218
crates/trogon-gateway/src/http.rs                                               110       0  100.00%
crates/trogon-gateway/src/streams.rs                                            138       0  100.00%
crates/trogon-gateway/src/config.rs                                            1639       0  100.00%
crates/trogon-gateway/src/main.rs                                                 4       0  100.00%
crates/trogon-gateway/src/source_status.rs                                       28       0  100.00%
crates/acp-nats/src/nats/subjects/global/initialize.rs                            6       0  100.00%
crates/acp-nats/src/nats/subjects/global/ext_notify.rs                            9       0  100.00%
crates/acp-nats/src/nats/subjects/global/logout.rs                                6       0  100.00%
crates/acp-nats/src/nats/subjects/global/session_list.rs                          6       0  100.00%
crates/acp-nats/src/nats/subjects/global/session_new.rs                           6       0  100.00%
crates/acp-nats/src/nats/subjects/global/authenticate.rs                          6       0  100.00%
crates/acp-nats/src/nats/subjects/global/ext.rs                                   9       0  100.00%
crates/acp-nats/src/telemetry/metrics.rs                                         53       0  100.00%
crates/trogon-source-telegram/src/config.rs                                      17       0  100.00%
crates/trogon-source-telegram/src/server.rs                                     338       0  100.00%
crates/trogon-source-telegram/src/signature.rs                                   32       0  100.00%
crates/trogon-std/src/time/system.rs                                             31       0  100.00%
crates/trogon-std/src/time/mock.rs                                              125       0  100.00%
crates/trogon-nats/src/jetstream/create_conflicts.rs                             24       0  100.00%
crates/trogon-nats/src/jetstream/claim_check.rs                                 346       0  100.00%
crates/trogon-nats/src/jetstream/publish.rs                                      64       0  100.00%
crates/trogon-nats/src/jetstream/stream_max_age.rs                               18       0  100.00%
crates/trogon-nats/src/jetstream/mocks.rs                                       670      32  95.22%   364-378, 384-392, 407-413, 427-430, 494-496
crates/trogon-nats/src/telemetry/messaging.rs                                    82       0  100.00%
crates/trogon-source-discord/src/gateway.rs                                     426       1  99.77%   137
crates/trogon-source-discord/src/config.rs                                      108       0  100.00%
crates/trogon-source-notion/src/notion_event_type.rs                             46       3  93.48%   47-49
crates/trogon-source-notion/src/notion_verification_token.rs                     17       0  100.00%
crates/trogon-source-notion/src/signature.rs                                     56       1  98.21%   32
crates/trogon-source-notion/src/server.rs                                       318       8  97.48%   92-96, 129-130, 149-150
crates/trogon-nats/src/lease/release.rs                                           5       5  0.00%    8-12
crates/trogon-nats/src/lease/renew_interval.rs                                   61       0  100.00%
crates/trogon-nats/src/lease/ttl.rs                                              73       0  100.00%
crates/trogon-nats/src/lease/nats_kv_lease_config.rs                             26       0  100.00%
crates/trogon-nats/src/lease/provision.rs                                       177       0  100.00%
crates/trogon-nats/src/lease/renew.rs                                           234       7  97.01%   24-30
crates/trogon-nats/src/lease/mod.rs                                             561      13  97.68%   180-193
crates/trogon-nats/src/lease/lease_key.rs                                        19       0  100.00%
crates/trogon-nats/src/lease/lease_bucket.rs                                     19       0  100.00%
crates/trogon-nats/src/lease/acquire.rs                                           5       5  0.00%    9-14
crates/trogon-nats/src/lease/lease_config_error.rs                               11       0  100.00%
crates/trogon-nats/src/lease/lease_timing.rs                                     15       0  100.00%
crates/acp-nats/src/nats/parsing.rs                                             278       1  99.64%   151
crates/acp-nats/src/nats/mod.rs                                                  23       0  100.00%
crates/acp-nats/src/nats/extensions.rs                                            3       0  100.00%
crates/acp-nats/src/client/mod.rs                                              2851       0  100.00%
crates/acp-nats/src/client/terminal_create.rs                                   274       0  100.00%
crates/acp-nats/src/client/session_update.rs                                     55       0  100.00%
crates/acp-nats/src/client/fs_write_text_file.rs                                418       0  100.00%
crates/acp-nats/src/client/terminal_kill.rs                                     290       0  100.00%
crates/acp-nats/src/client/terminal_release.rs                                  347       0  100.00%
crates/acp-nats/src/client/terminal_wait_for_exit.rs                            378       0  100.00%
crates/acp-nats/src/client/fs_read_text_file.rs                                 356       0  100.00%
crates/acp-nats/src/client/request_permission.rs                                308       0  100.00%
crates/acp-nats/src/client/ext.rs                                               308       8  97.40%   163-172, 189-198
crates/acp-nats/src/client/ext_session_prompt_response.rs                       135       0  100.00%
crates/acp-nats/src/client/terminal_output.rs                                   206       0  100.00%
crates/acp-nats/src/client/rpc_reply.rs                                          64       0  100.00%
crates/trogon-source-linear/src/config.rs                                        17       0  100.00%
crates/trogon-source-linear/src/server.rs                                       386       0  100.00%
crates/trogon-source-linear/src/signature.rs                                     54       1  98.15%   16
crates/trogon-std/src/dirs/fixed.rs                                              80       0  100.00%
crates/trogon-std/src/dirs/system.rs                                             71       0  100.00%
TOTAL                                                                         27950     362  98.70%

Diff against main

Filename                                   Stmts    Miss  Cover
---------------------------------------  -------  ------  -------
crates/acp-nats-server/src/main.rs           -35       0  -0.04%
crates/acp-nats-server/src/transport.rs     -175      -9  -0.09%
TOTAL                                       -210      -9  +0.02%

Results for commit: cbcd881

Minimum allowed coverage is 95%

♻️ This comment has been updated with latest results

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8375101. Configure here.

Comment thread rsworkspace/crates/acp-nats-server/src/transport.rs Outdated
Comment thread rsworkspace/crates/acp-nats-server/src/transport.rs Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
rsworkspace/crates/acp-nats-server/README.md (1)

50-60: Document the required ordering: open GET /acp before sending follow-up POSTs.

With the new async delivery model, any response to a follow-up POST is fanned out to the currently-attached GET listeners on the connection (dispatch_to_get_listeners in transport.rs). If the client hasn't yet opened the long-lived GET /acp stream when the backend produces the response, the frame is dropped and the client will wait indefinitely for a reply it can never receive. The README should make this sequencing explicit so integrators don't get bitten by a race between POST and the subsequent GET.

📝 Proposed wording tweak
-Then open the long-lived SSE stream for the connection:
+After `initialize`, open the long-lived SSE stream for the connection **before** sending any follow-up `POST` requests — responses to those requests are delivered exclusively on this stream and are dropped if no listener is attached when they arrive:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rsworkspace/crates/acp-nats-server/README.md` around lines 50 - 60, Update
the README to explicitly require opening the long-lived GET /acp SSE stream
before sending any follow-up POSTs: explain that responses to follow-up POSTs
are delivered asynchronously and fanned out to currently-attached GET listeners
(see dispatch_to_get_listeners in transport.rs), so if the client hasn't
attached a GET listener yet the response may be dropped and the client will
hang; add a short example/one-line note near the curl examples that instructs
users to open the GET /acp stream first and only then send subsequent POST
requests, and mention that initialize (POST /acp) is the only POST that returns
immediate JSON while others return 202 and deliver JSON on the GET stream.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@rsworkspace/crates/acp-nats-server/src/transport.rs`:
- Around line 292-297: PendingResponseContext currently has inject_session_id
always true; change the construction site that sets inject_session_id (the code
around where PendingResponseContext is instantiated) so inject_session_id is
only true when the request method satisfies attaches_session() (i.e., only for
backend methods that may legitimately omit sessionId like session/load or
session/resume), and leave inject_session_id false otherwise; update any
comments and keep the single field usage (reading inject_session_id) untouched
so the injection behavior is gated to attaches_session() only.
- Around line 1241-1248: The code currently discards the Result from
dispatch_to_get_listeners; change it to inspect the returned enum
(Missing/Dropped/Delivered) and, when the parsed OutgoingHttpMessage (from
OutgoingHttpMessage::parse(&outbound)) represents a response (i.e., has a
correlating id and is not a pure notification—use
OutgoingHttpMessage::result_session_id or the message id accessor to detect
this), emit a warn! (or increment a dropped-response counter) if the outcome is
Missing or Dropped so operators can detect lost responses; keep notifications
best-effort and only log for messages identified as responses. Ensure you
reference SseFrame::json, parsed/outbound, dispatch_to_get_listeners, and
get_listeners in the change so the new logic replaces the discarded let _ = ...
line.

---

Nitpick comments:
In `@rsworkspace/crates/acp-nats-server/README.md`:
- Around line 50-60: Update the README to explicitly require opening the
long-lived GET /acp SSE stream before sending any follow-up POSTs: explain that
responses to follow-up POSTs are delivered asynchronously and fanned out to
currently-attached GET listeners (see dispatch_to_get_listeners in
transport.rs), so if the client hasn't attached a GET listener yet the response
may be dropped and the client will hang; add a short example/one-line note near
the curl examples that instructs users to open the GET /acp stream first and
only then send subsequent POST requests, and mention that initialize (POST /acp)
is the only POST that returns immediate JSON while others return 202 and deliver
JSON on the GET stream.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f306e74c-0998-4293-ad9b-618ffb70a41d

📥 Commits

Reviewing files that changed from the base of the PR and between aaf7273 and 8375101.

📒 Files selected for processing (3)
  • rsworkspace/crates/acp-nats-server/README.md
  • rsworkspace/crates/acp-nats-server/src/main.rs
  • rsworkspace/crates/acp-nats-server/src/transport.rs

Comment thread rsworkspace/crates/acp-nats-server/src/transport.rs
Comment thread rsworkspace/crates/acp-nats-server/src/transport.rs Outdated
yordis added 3 commits April 23, 2026 17:47
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis merged commit 970b54b into main Apr 23, 2026
7 checks passed
@yordis yordis deleted the yordis/acp-1064-audit branch April 23, 2026 22:46
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