Repository navigation
Merge upstream #1746: Use lazy stream accessors for provider runtime events - #51
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Warning Rate limit exceeded
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 17 minutes and 34 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request refactors event streaming patterns across the orchestration system by converting eager stream property initialization to lazy getter-based evaluation, introduces a dedicated test implementation for the RuntimeReceiptBus with a renamed API, and restructures event processing in ProviderService from a queue-based worker to direct stream pipeline handling. State management in EventNdjsonLogger is also refactored to use synchronized references. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/server/integration/providerService.integration.test.ts (1)
89-90: Prefer an explicit collector-ready signal over the fixed 50ms delay.Line 89 adds a wall-clock dependency that can still race on slower CI and adds latency to every turn capture. A ready handshake, or a single long-lived collector owned by the fixture, would make these tests deterministic without hard-coded timing.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/server/integration/providerService.integration.test.ts` around lines 89 - 90, The test currently uses a fixed wall-clock delay (yield* Effect.sleep("50 millis")) before running yield* action, which causes flaky CI and added latency; replace this with an explicit collector-ready handshake or a long-lived collector owned by the test fixture: modify the test setup to start the collector in the fixture (or expose a promise/event like collector.ready or waitForCollectorReady()) and await that signal instead of using Effect.sleep, or refactor the fixture to keep a single long-lived collector for all turns and remove the sleep before calling action.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/server/src/provider/Layers/EventNdjsonLogger.ts`:
- Around line 269-283: The current shutdown sequence in
SynchronizedRef.modifyEffect (operating on stateRef) clears threadWriters and
failedSegments but does not mark the logger as closed, so subsequent write calls
can recreate ThreadWriter instances and reopen files; modify the shared state
shape to include a terminal flag (e.g., closed or isShutdown) and in the close
path (where you call ThreadWriter.close on each writer) set that flag true; then
update the write/create path that accesses stateRef and threadWriters to check
the closed flag first and refuse or noop writes when closed, ensuring no new
ThreadWriter is created after shutdown and existing resources remain final.
---
Nitpick comments:
In `@apps/server/integration/providerService.integration.test.ts`:
- Around line 89-90: The test currently uses a fixed wall-clock delay (yield*
Effect.sleep("50 millis")) before running yield* action, which causes flaky CI
and added latency; replace this with an explicit collector-ready handshake or a
long-lived collector owned by the test fixture: modify the test setup to start
the collector in the fixture (or expose a promise/event like collector.ready or
waitForCollectorReady()) and await that signal instead of using Effect.sleep, or
refactor the fixture to keep a single long-lived collector for all turns and
remove the sleep before calling action.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: d0f67fe2-eed7-4f08-8f02-fbe2d3b77eb9
📒 Files selected for processing (14)
apps/server/integration/OrchestrationEngineHarness.integration.tsapps/server/integration/providerService.integration.test.tsapps/server/src/orchestration/Layers/CheckpointReactor.test.tsapps/server/src/orchestration/Layers/ProviderCommandReactor.test.tsapps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tsapps/server/src/orchestration/Layers/RuntimeReceiptBus.tsapps/server/src/orchestration/Services/RuntimeReceiptBus.tsapps/server/src/provider/Layers/ClaudeAdapter.tsapps/server/src/provider/Layers/CodexAdapter.tsapps/server/src/provider/Layers/EventNdjsonLogger.test.tsapps/server/src/provider/Layers/EventNdjsonLogger.tsapps/server/src/provider/Layers/ProviderRegistry.test.tsapps/server/src/provider/Layers/ProviderService.test.tsapps/server/src/provider/Layers/ProviderService.ts
…replace sleep with yieldNow Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Summary
Cherry-picks upstream commit
740d7a32— "Use lazy stream accessors for provider runtime events (pingdotgg#1746)".Changes
streamEventsfrom eagerStream.fromQueue()to a lazy getter on provider adapters (Codex + Claude), so the queue is only consumed when readRuntimeReceiptBusintoRuntimeReceiptBusLive(no-op) andRuntimeReceiptBusTest(PubSub-backed) for cleaner test isolationSynchronizedRefconcurrency safety toEventNdjsonLoggerit.liveand lazy stream accessorsConflict Resolution
1 conflict in
ClaudeAdapter.ts— fork had restructured function positions in a prior refactor. Resolved by keeping fork structure and applying only the upstream lazy getter change.Verification
bun typecheck✅bun fmt✅bun lint✅Fork Preservation
All fork-specific multi-provider logic, guards, and imports verified intact.
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests
Refactor