feat: implement ensureReady method for lazy bundle source initialization#500
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesBundleSyncService worker-safe lazy boot
Sequence Diagram(s)sequenceDiagram
participant Tool as Tool.execute
participant BSS as BundleSyncService
participant Source as StartableBundleSource
participant Registry as HiddenOpRegistry / SkillRegistry
Tool->>BSS: ensureReady()
alt source not yet started
BSS->>Source: start()
BSS->>Source: onChange(handler)
Source-->>BSS: emit first bundle
BSS->>BSS: apply(bundle) → resolve latch
end
BSS-->>Tool: void
Tool->>Registry: read skills / ops
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
Performance Test ResultsStatus: ✅ All tests passed Summary
Total: 101 tests across 21 projects 📊 View full report in workflow run Generated at: 2026-06-22T17:12:00.764Z |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
plugins/plugin-skilled-openapi/src/sync/bundle-sync.service.ts (1)
139-143: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winRemove the non-null assertion from the first-apply latch.
Line 139 violates the repo’s no-
!rule; use a checked local before the listener closes over the resolver.Proposed refactor
- let resolveFirst!: () => void; + let resolveFirst: (() => void) | undefined; let firstSettled = false; const firstApply = new Promise<void>((resolve) => { resolveFirst = resolve; }); + if (!resolveFirst) { + throw new Error('[bundle-sync] firstApply resolver was not initialized'); + } + const settleFirst = resolveFirst; @@ if (!firstSettled) { firstSettled = true; - void applied.then(() => resolveFirst()); + void applied.then(settleFirst); }As per coding guidelines, “Always avoid non-null assertions (
!); use proper error handling instead.”Also applies to: 159-162
🤖 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 `@plugins/plugin-skilled-openapi/src/sync/bundle-sync.service.ts` around lines 139 - 143, The variable `resolveFirst` is declared with a non-null assertion (`!`) on line 139, which violates the repository's no-`!` rule. Remove the non-null assertion and instead initialize `resolveFirst` with a safe default value (such as an empty arrow function) so that TypeScript can properly infer its type without requiring an assertion. Apply the same fix to any similar declarations around lines 159-162 where this pattern is also used.Source: Coding guidelines
🤖 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 `@plugins/plugin-skilled-openapi/src/__tests__/bundle-sync.service.spec.ts`:
- Around line 154-166: The test for "does not throw (swallows + logs) when the
source fails to start" verifies that ensureReady() resolves successfully when
the source fails, but it does not verify that the error was actually logged. Add
an assertion after the await expect statement that checks fakeLogger.error was
called with an appropriate message pattern (such as a pattern matching the error
message or describing a source startup failure). This ensures the test fully
covers the error-handling contract by confirming both that the error is
swallowed and that it is logged.
In `@plugins/plugin-skilled-openapi/src/__tests__/run-workflow.tool.spec.ts`:
- Around line 328-331: The ctx object literal has a duplicate `get` property
definition which is a syntax error. Locate the ctx object initialization and
identify where the `get` property is defined multiple times. Remove the
duplicate `get` property definition so that the ctx object only has a single
`get` property that returns an object with the ensureReady async method.
In `@plugins/plugin-skilled-openapi/src/sync/bundle-sync.service.ts`:
- Around line 147-163: The source.onChange callback in the bundle-sync service
immediately invokes this.apply(bundle) for each emission, which can cause
concurrent applies to interleave and corrupt shared state (registries, bundle
store, unregister handles). Implement a queue mechanism to serialize bundle
applies so that each apply completes before the next one begins. Modify the
onChange callback to enqueue each bundle apply operation rather than executing
it immediately, ensuring that mutations to shared state are serialized and the
active bundle/handles remain in the correct order.
- Around line 141-166: The SaasPullSource.start() method has an early return
when inFlight is already true that skips emission, causing
BundleSyncService.bootstrap() to hang indefinitely waiting for the onChange
callback to fire. Fix this by modifying the early return logic in
SaasPullSource.start() to ensure emission occurs before the method
resolves—either by awaiting the in-flight pull operation and emitting its
result, or by explicitly rejecting with a descriptive error that makes the race
condition visible, so that start() always triggers at least one onChange event
before completing.
---
Nitpick comments:
In `@plugins/plugin-skilled-openapi/src/sync/bundle-sync.service.ts`:
- Around line 139-143: The variable `resolveFirst` is declared with a non-null
assertion (`!`) on line 139, which violates the repository's no-`!` rule. Remove
the non-null assertion and instead initialize `resolveFirst` with a safe default
value (such as an empty arrow function) so that TypeScript can properly infer
its type without requiring an assertion. Apply the same fix to any similar
declarations around lines 159-162 where this pattern is also used.
🪄 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
Run ID: 322e6a16-4874-40ba-b96d-12a99973b528
📒 Files selected for processing (10)
plugins/plugin-skilled-openapi/src/__tests__/bundle-sync.service.spec.tsplugins/plugin-skilled-openapi/src/__tests__/meta-tools.spec.tsplugins/plugin-skilled-openapi/src/__tests__/plugin.spec.tsplugins/plugin-skilled-openapi/src/__tests__/run-workflow.tool.spec.tsplugins/plugin-skilled-openapi/src/__tests__/runtime-deps-injection.spec.tsplugins/plugin-skilled-openapi/src/skilled-openapi.plugin.tsplugins/plugin-skilled-openapi/src/sync/bundle-sync.service.tsplugins/plugin-skilled-openapi/src/tools/load-skill.tool.tsplugins/plugin-skilled-openapi/src/tools/run-workflow.tool.tsplugins/plugin-skilled-openapi/src/tools/search-skill.tool.ts
Cherry-pick CreatedA cherry-pick PR to Please review and merge if this change should also be in If the cherry-pick is not needed, close the PR. |
Summary by CodeRabbit
Bug Fixes
Tests