Skip to content

refactor(acp-nats): split global extensions into dedicated GLOBAL_EXT stream#71

Merged
yordis merged 1 commit into
mainfrom
refactor/split-global-ext-stream
Mar 31, 2026
Merged

refactor(acp-nats): split global extensions into dedicated GLOBAL_EXT stream#71
yordis merged 1 commit into
mainfrom
refactor/split-global-ext-stream

Conversation

@yordis
Copy link
Copy Markdown
Member

@yordis yordis commented Mar 31, 2026

Summary

  • Extract agent.ext.> from GLOBAL stream into its own GLOBAL_EXT stream with independent storage limits
  • GLOBAL stream now contains only the 3 lifecycle subjects: initialize, authenticate, session.new
  • Extensions are user-defined with unknown volume — isolating them prevents a noisy extension from evicting lifecycle audit events

… stream

Extensions are user-defined with unknown volume profiles. Isolating
them prevents a noisy extension from evicting lifecycle audit events.

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

cursor Bot commented Mar 31, 2026

PR Summary

Medium Risk
Moderate risk because it changes JetStream stream topology and subject-to-stream routing, which can affect message retention/consumers and requires coordinated deployment/migration.

Overview
Refactors JetStream provisioning to create six streams by introducing a new GLOBAL_EXT stream and moving acp.agent.ext.> subjects out of GLOBAL.

Adds global_ext_* helpers/config, updates all_configs() to include the new stream, and adjusts tests to validate the new subject split and updated stream counts/idempotency.

Written by Cursor Bugbot for commit a4f616e. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

Walkthrough

A new NATS JetStream stream configuration (*_GLOBAL_EXT) is introduced to handle extended agent subjects. The existing global_config is modified to exclude ext subjects, while two new public functions define the dedicated ext stream. The all_configs function now returns 6 configurations instead of 5, and related tests are updated accordingly.

Changes

Cohort / File(s) Summary
JetStream Stream Configuration
rsworkspace/crates/acp-nats/src/jetstream/streams.rs
Added global_ext_stream_name() and global_ext_config() functions to define a new *_GLOBAL_EXT stream for extended agent subjects ({prefix}.agent.ext.>). Modified global_config() to exclude ext subjects from its subject list. Updated all_configs() return type from 5-element array to 6-element array. Expanded test assertions to validate the new ext stream configuration.
Provisioning Test Updates
rsworkspace/crates/acp-nats/src/jetstream/provision.rs
Updated stream count expectations in provisioning tests: total streams from 5→6 and idempotency checks from 10→12. Extended assertions to verify the new ACP_GLOBAL_EXT stream is created.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A new stream hops into the fold,
GLOBAL_EXT, bold and sleek,
Ext subjects now have their own home,
Config splits clean, no overlap's spoke,
Six streams dance where five once stood! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: extracting extension subjects into a dedicated GLOBAL_EXT stream, which is reflected in both file summaries.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation and technical details of splitting the global extensions into a separate stream with independent storage limits.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/split-global-ext-stream

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

badge

Code Coverage Summary

Details
Filename                                                     Stmts    Miss  Cover    Missing
---------------------------------------------------------  -------  ------  -------  ---------------------------------------------------------------------------------------------
crates/acp-nats/src/jetstream/ext_policy.rs                     26       0  100.00%
crates/acp-nats/src/jetstream/streams.rs                       252       0  100.00%
crates/acp-nats/src/jetstream/provision.rs                      58       0  100.00%
crates/acp-nats/src/jetstream/consumers.rs                      76       0  100.00%
crates/acp-nats-stdio/src/config.rs                             72       0  100.00%
crates/acp-nats-stdio/src/main.rs                              113      11  90.27%   58, 106-113, 119-121, 138
crates/trogon-std/src/fs/mem.rs                                220      10  95.45%   61-63, 77-79, 133-135, 158
crates/trogon-std/src/fs/system.rs                              29      12  58.62%   17-19, 31-45
crates/acp-nats/src/nats/parsing.rs                            280       1  99.64%   151
crates/acp-nats/src/nats/extensions.rs                           3       0  100.00%
crates/acp-nats/src/nats/subjects.rs                           294       0  100.00%
crates/acp-nats/src/nats/token.rs                                8       0  100.00%
crates/trogon-std/src/dirs/system.rs                            98      11  88.78%   57, 65, 67, 75, 77, 85, 87, 96, 98, 109, 154
crates/trogon-std/src/dirs/fixed.rs                             84       0  100.00%
crates/acp-telemetry/src/lib.rs                                153      22  85.62%   39-46, 81, 86, 91, 105-120
crates/acp-telemetry/src/signal.rs                               3       3  0.00%    4-43
crates/acp-telemetry/src/metric.rs                              35       4  88.57%   30-31, 38-39
crates/acp-telemetry/src/service_name.rs                        16       0  100.00%
crates/acp-telemetry/src/trace.rs                               32       4  87.50%   23-24, 31-32
crates/acp-telemetry/src/log.rs                                 70       2  97.14%   39-40
crates/acp-nats/src/client/rpc_reply.rs                         71       0  100.00%
crates/acp-nats/src/client/fs_read_text_file.rs                384       0  100.00%
crates/acp-nats/src/client/terminal_wait_for_exit.rs           396       0  100.00%
crates/acp-nats/src/client/ext_session_prompt_response.rs      150       0  100.00%
crates/acp-nats/src/client/mod.rs                             2981       0  100.00%
crates/acp-nats/src/client/fs_write_text_file.rs               451       0  100.00%
crates/acp-nats/src/client/session_update.rs                    55       0  100.00%
crates/acp-nats/src/client/ext.rs                              365       8  97.81%   193-204, 229-240
crates/acp-nats/src/client/terminal_create.rs                  294       0  100.00%
crates/acp-nats/src/client/terminal_kill.rs                    309       0  100.00%
crates/acp-nats/src/client/terminal_output.rs                  223       0  100.00%
crates/acp-nats/src/client/terminal_release.rs                 357       0  100.00%
crates/acp-nats/src/client/request_permission.rs               338       0  100.00%
crates/trogon-std/src/args.rs                                   10       0  100.00%
crates/trogon-std/src/json.rs                                   30       0  100.00%
crates/acp-nats-agent/src/connection.rs                       1356       9  99.34%   472, 669-671, 678, 1826-1827, 1840-1841
crates/trogon-std/src/time/mock.rs                             123       0  100.00%
crates/trogon-std/src/time/system.rs                            24       0  100.00%
crates/acp-nats/src/telemetry/metrics.rs                        65       0  100.00%
crates/acp-nats-ws/src/main.rs                                 157       2  98.73%   84, 247
crates/acp-nats-ws/src/upgrade.rs                               57       2  96.49%   59, 90
crates/acp-nats-ws/src/config.rs                                83       0  100.00%
crates/acp-nats-ws/src/connection.rs                           162      35  78.40%   71-78, 83-94, 110, 112-113, 118, 129-131, 138, 142, 146, 149-157, 168, 172, 175, 178-182, 216
crates/acp-nats/src/pending_prompt_waiters.rs                  112       0  100.00%
crates/acp-nats/src/session_id.rs                               88       0  100.00%
crates/acp-nats/src/config.rs                                  201       0  100.00%
crates/acp-nats/src/acp_prefix.rs                               63       0  100.00%
crates/acp-nats/src/client_proxy.rs                            196       0  100.00%
crates/acp-nats/src/in_flight_slot_guard.rs                     32       0  100.00%
crates/acp-nats/src/lib.rs                                      73       0  100.00%
crates/acp-nats/src/error.rs                                    84       0  100.00%
crates/acp-nats/src/ext_method_name.rs                          85       0  100.00%
crates/acp-nats/src/jsonrpc.rs                                   6       0  100.00%
crates/trogon-nats/src/jetstream/mocks.rs                      435       0  100.00%
crates/trogon-nats/src/jetstream/traits.rs                      96       0  100.00%
crates/trogon-std/src/env/system.rs                             17       0  100.00%
crates/trogon-std/src/env/in_memory.rs                          81       0  100.00%
crates/acp-nats/src/agent/set_session_config_option.rs          76       0  100.00%
crates/acp-nats/src/agent/load_session.rs                      114       0  100.00%
crates/acp-nats/src/agent/ext_method.rs                         92       0  100.00%
crates/acp-nats/src/agent/fork_session.rs                      117       0  100.00%
crates/acp-nats/src/agent/set_session_mode.rs                   79       0  100.00%
crates/acp-nats/src/agent/cancel.rs                            104       0  100.00%
crates/acp-nats/src/agent/js_request.rs                        296       0  100.00%
crates/acp-nats/src/agent/authenticate.rs                       52       0  100.00%
crates/acp-nats/src/agent/resume_session.rs                    113       0  100.00%
crates/acp-nats/src/agent/ext_notification.rs                   88       0  100.00%
crates/acp-nats/src/agent/mod.rs                                61       0  100.00%
crates/acp-nats/src/agent/prompt.rs                           1085       2  99.82%   144, 301
crates/acp-nats/src/agent/test_support.rs                      267       0  100.00%
crates/acp-nats/src/agent/list_sessions.rs                      50       0  100.00%
crates/acp-nats/src/agent/set_session_model.rs                  76       0  100.00%
crates/acp-nats/src/agent/initialize.rs                         82       0  100.00%
crates/acp-nats/src/agent/close_session.rs                      72       0  100.00%
crates/acp-nats/src/agent/new_session.rs                        91       0  100.00%
crates/acp-nats/src/agent/bridge.rs                            142      13  90.85%   171-183
crates/trogon-nats/src/connect.rs                               96      16  83.33%   22-24, 37, 49, 68-151
crates/trogon-nats/src/client.rs                                25      25  0.00%    50-89
crates/trogon-nats/src/mocks.rs                                304       0  100.00%
crates/trogon-nats/src/messaging.rs                            533       4  99.25%   141-146, 156-157
crates/trogon-nats/src/auth.rs                                 114       3  97.37%   45-47
TOTAL                                                        16061     199  98.76%

Diff against main

Filename                                      Stmts    Miss  Cover
------------------------------------------  -------  ------  --------
crates/acp-nats/src/jetstream/streams.rs        +25       0  +100.00%
crates/acp-nats/src/jetstream/provision.rs       +1       0  +100.00%
TOTAL                                           +26       0  +0.00%

Results for commit: a4f616e

Minimum allowed coverage is 95%

♻️ This comment has been updated with latest results

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.

🧹 Nitpick comments (1)
rsworkspace/crates/acp-nats/src/jetstream/streams.rs (1)

92-106: Consider documenting the migration impact for existing deployments.

The global_config now excludes {prefix}.agent.ext.> subjects. Existing consumers that were receiving extension messages from the GLOBAL stream will need to subscribe to the new GLOBAL_EXT stream after this change.

If this is deployed to existing environments, consider:

  1. Adding migration notes to the PR description or changelog
  2. Ensuring consumers are updated to subscribe to the new stream before or alongside this deployment
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rsworkspace/crates/acp-nats/src/jetstream/streams.rs` around lines 92 - 106,
Update the PR/changelog and add migration guidance noting that global_config
(the function building the GLOBAL stream via stream_name(prefix, "GLOBAL")) no
longer includes the "{prefix}.agent.ext.>" subjects and that those messages now
belong to the new GLOBAL_EXT stream; explicitly instruct operators to update
consumers to subscribe to the new GLOBAL_EXT stream (or add the subjects back
temporarily) and recommend a rollout order (create GLOBAL_EXT and update
consumers before removing ext subjects from GLOBAL) so no messages are lost.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@rsworkspace/crates/acp-nats/src/jetstream/streams.rs`:
- Around line 92-106: Update the PR/changelog and add migration guidance noting
that global_config (the function building the GLOBAL stream via
stream_name(prefix, "GLOBAL")) no longer includes the "{prefix}.agent.ext.>"
subjects and that those messages now belong to the new GLOBAL_EXT stream;
explicitly instruct operators to update consumers to subscribe to the new
GLOBAL_EXT stream (or add the subjects back temporarily) and recommend a rollout
order (create GLOBAL_EXT and update consumers before removing ext subjects from
GLOBAL) so no messages are lost.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95c0c912-3131-4f55-8315-cf9988eb7e09

📥 Commits

Reviewing files that changed from the base of the PR and between 9962576 and a4f616e.

📒 Files selected for processing (2)
  • rsworkspace/crates/acp-nats/src/jetstream/provision.rs
  • rsworkspace/crates/acp-nats/src/jetstream/streams.rs

@yordis yordis merged commit 1d8a489 into main Mar 31, 2026
7 checks passed
@yordis yordis deleted the refactor/split-global-ext-stream branch March 31, 2026 17:21
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