Skip to content

refactor(trogon-nats): use per-operation traits with ToSubject#6

Merged
yordis merged 1 commit into
mainfrom
fix-sub
Feb 18, 2026
Merged

refactor(trogon-nats): use per-operation traits with ToSubject#6
yordis merged 1 commit into
mainfrom
fix-sub

Conversation

@yordis

@yordis yordis commented Feb 18, 2026

Copy link
Copy Markdown
Member

No description provided.

@cursor

cursor Bot commented Feb 18, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Signature changes are source-breaking for downstream crates and could require widespread call-site updates, but behavior changes are limited to subject type handling and mocks.

Overview
Refactors the per-operation NATS client traits (SubscribeClient, RequestClient, PublishClient) to accept any async_nats::subject::ToSubject instead of requiring a String, aligning the abstraction with async_nats and reducing caller allocations.

Updates the NatsAsyncClient impls, mock clients, and unit tests to use the new generic subject parameter, and re-exports ToSubject from the crate root for easier downstream use.

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

@coderabbitai

coderabbitai Bot commented Feb 18, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

The NATS client traits (SubscribeClient, RequestClient, PublishClient) are generalized to accept subject parameters as any type implementing ToSubject + Send, rather than requiring String. The ToSubject trait is re-exported at the crate root, and mock implementations are updated to support the new generic signatures with subject conversion.

Changes

Cohort / File(s) Summary
Core Trait Abstractions
rsworkspace/crates/trogon-nats/src/client.rs
Updated trait method signatures (subscribe, request_with_headers, publish_with_headers) to use generic subject parameter S: ToSubject + Send instead of String. Adjusted implementations to pass generic subjects directly to underlying async_nats methods.
Public Re-exports
rsworkspace/crates/trogon-nats/src/lib.rs
Added public re-export of ToSubject trait from the async_nats crate to enable users to implement and pass custom subject types.
Mock Implementations
rsworkspace/crates/trogon-nats/src/mocks.rs
Updated MockNatsClient and AdvancedMockNatsClient to implement generic trait methods with subject conversion via to_subject().to_string(). Adjusted internal storage and message construction to work with stringified subjects.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through generic bounds,
Where subjects dance as flexible rounds,
No longer strings of static chain,
But traits that flow like autumn rain,
The code now bends yet holds its reins! 🌿

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-sub

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.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis marked this pull request as ready for review February 18, 2026 19:02
@yordis yordis merged commit 3107329 into main Feb 18, 2026
3 of 4 checks passed
@yordis yordis deleted the fix-sub branch February 18, 2026 19:03
jramirezhdez02 added a commit that referenced this pull request Mar 27, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
mariorha pushed a commit that referenced this pull request Apr 6, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
jramirezhdez02 added a commit that referenced this pull request Apr 6, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
mariorha pushed a commit that referenced this pull request Apr 9, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
mariorha pushed a commit that referenced this pull request Apr 9, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
mariorha pushed a commit that referenced this pull request Apr 13, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
jramirezhdez02 added a commit that referenced this pull request Apr 13, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
mariorha added a commit that referenced this pull request Apr 14, 2026
…eviewer dedup

#1 — Linear post_comment: embed now uses idempotency_marker()
The pre-check scan (tools/linear.rs:71) used super::idempotency_marker(key)
which replaces -- with __ in the key. The embed (line 117) used the raw key
directly, so the two paths produced different marker strings whenever the key
contained --. The check would search for abc__def but the stored body had
abc--def — a silent false negative that lets duplicates through. Now both
paths call idempotency_marker() so write and scan are byte-identical.

#2 — request_reviewers: filter already-added reviewers instead of all-or-nothing
The previous dedup skipped the POST only if ALL requested reviewers were
already in the pending list. A crash after GitHub partially applied the request
(some reviewers added, others not) caused recovery to re-execute with all
reviewers, sending duplicate notifications to those already added. Now we
filter the already-present reviewers from the request list and only POST the
missing ones; if no reviewers are missing the POST is skipped entirely.

Note: #6 (startup recovery rate limiting) turned out to be already implemented
correctly — recover_stale_promises processes promises sequentially, not
concurrently (intentional, see runner.rs comment at line 1092).
mariorha pushed a commit that referenced this pull request Apr 15, 2026
#5 — heartbeat KV timeout now reloads revision and retries the write,
matching the CAS-conflict arm. Under sustained NATS degradation the old
code left claimed_at frozen; the reload+retry keeps it fresh and avoids
false-positive stale detection by startup recovery.

#2 — recovering resets to false when checkpointing is permanently
disabled (payload exceeds all trim levels). Previously recovering stayed
true forever, causing same-input tool calls in genuinely-new turns to
return stale cached results (polling anti-pattern). New test
recovering_resets_when_checkpointing_permanently_disabled covers the
case.

#7 — summarize_dropped_messages is now wrapped in a 30 s timeout.
The call inherits a 5-minute LLM timeout which blocks the checkpoint
write and leaves claimed_at stale for that window. 30 s is generous for
a short summary; on timeout the empty Vec triggers the plain-trim
fallback that was already there.

#6 — list_running timeout raised from NATS_KV_TIMEOUT (10 s) to a
dedicated LIST_RUNNING_TIMEOUT (2 min). The operation does N+1 KV reads;
at 50+ stale promises under mild load the 10 s ceiling fires and silently
skips recovery. 2 min covers hundreds of promises without blocking the
consumer loop (recovery runs in a background task).
mariorha pushed a commit that referenced this pull request Apr 17, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
mariorha pushed a commit that referenced this pull request Apr 20, 2026
…ogging

- Drop impl for CodexProcess: kill subprocess on re-spawn/drop to avoid zombies
- resume_session: thread_resume errors are now non-fatal (warn + continue);
  Codex keeps threads alive regardless so failing here should not break prompts
- close_session: add comment explaining no thread/close exists in Codex protocol
- list_sessions: sort by session_id for deterministic output
- new_session: deduplicate to_string_lossy() call (issue #6)
- parse_event: trace-log when a message item has no output_text blocks
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