fix: validate DI provider graphs before startup - #1041
Conversation
|
Warning Review limit reached
More reviews will be available in 40 minutes and 16 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthrough
ChangesDI/모듈 그래프 매니페스트 및 croco di check CLI
Sequence Diagram(s)sequenceDiagram
participant User as 사용자/CI
participant croco_di_check as croco di check (runDiCheck)
participant Container as Container.createDependencyGraphManifest
participant ModuleRegistry as createModuleGraphManifest
participant DiCheckReport as createDiCheckReport
rect rgba(70, 130, 180, 0.5)
note over User, ModuleRegistry: 매니페스트 생성 단계 (앱 빌드/스크립트)
User->>Container: createDependencyGraphManifest(options?)
Container->>Container: root 토큰별 trace 생성 및 captureSourceLocation
Container-->>User: DependencyGraphManifest (JSON 파일로 저장)
User->>ModuleRegistry: createModuleGraphManifest(rootModules?)
ModuleRegistry->>ModuleRegistry: provider visibility 검사 및 순환 의존성 포착
ModuleRegistry-->>User: ModuleGraphManifest (JSON 파일로 저장)
end
rect rgba(60, 179, 113, 0.5)
note over User, DiCheckReport: CI 검증 단계 (croco di check)
User->>croco_di_check: --manifest di-graph.json [--json] [--out report.json]
croco_di_check->>croco_di_check: JSON 파일 읽기 및 파싱
croco_di_check->>DiCheckReport: normalizeDiagnostic 및 status 계산
DiCheckReport-->>croco_di_check: DiCheckReport (passed/failed)
alt failed
croco_di_check-->>User: 포맷된 진단 출력 + exit code 1
else passed
croco_di_check-->>User: 성공 메시지 + exit code 0
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 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 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 |
📊 Benchmark Results❌ Some benchmarks failed Gate failures
Updated: 2026-06-20T14:52:40.174Z · Commit: 968b31b |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@packages/cli/src/commands/diCheck.ts`:
- Around line 195-213: The function normalizeDiagnostic contains duplicate calls
to readOptionalString for the "token" and "moduleName" keys. In both cases,
readOptionalString is called once in the ternary condition and again when
constructing the object value. Extract the results of readOptionalString(record,
"token") and readOptionalString(record, "moduleName") into separate variables
before the return statement, then use these variables in the conditional checks
and object spread operations to eliminate the redundant function calls.
In `@packages/framework-context/src/libs/Container.ts`:
- Around line 293-337: The createGraphProviders method uses the token label
string as the Map key for providers aggregation and dependency lookups, which
can cause collisions when different tokens share the same label (e.g.,
same-named classes). Replace the use of step.token as the Map key with a unique
tokenId identifier instead, ensuring both the providers Map operations and the
dependencyOf lookups use this tokenId consistently. This prevents provider
information and source locations from being incorrectly merged or associated
with the wrong tokens.
- Around line 438-444: The regular expression pattern used in the match
statement on line 438 only accepts Unix-style absolute paths starting with
forward slashes or file:// URIs, and fails to match Windows-style paths with
drive letters like C:\. Update the regex pattern to also capture Windows
absolute paths that start with a drive letter followed by a colon, in addition
to the existing Unix path patterns. This will ensure that sourceLocation parsing
works correctly on both Windows and Unix environments.
In `@packages/framework-module/src/ModuleRegistry.ts`:
- Around line 236-238: The diagnostic code string in the diagnostics.push call
at the ModuleRegistry.ts location does not match the code defined in the
ModuleCircularDependencyProblem in problems.ts. Update the code value from
"framework-module/module-circular-dependency" to
"framework-module/circular-dependency" to ensure consistency between the
diagnostic record and the Problem definition, which is required for proper
downstream diagnostic aggregation and filtering.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 151e8c65-440f-4891-b636-514f97d905da
📒 Files selected for processing (23)
.changeset/di-graph-manifest-check.mdpackages/cli/src/commands/di.tspackages/cli/src/commands/diCheck.tspackages/cli/src/commands/root.tspackages/cli/src/index.tspackages/cli/src/tests/diCheck.spec.tspackages/docs/src/content/docs/api/framework-context/src/classes/Container.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencyGraphDiagnostic.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencyGraphDiagnosticCode.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencyGraphManifest.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencyGraphManifestStatus.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencyGraphManifestVersion.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencyGraphProvider.mdpackages/docs/src/content/docs/api/framework-context/src/type-aliases/DependencySourceLocation.mdpackages/framework-context/src/index.tspackages/framework-context/src/libs/Container.tspackages/framework-context/src/libs/types.tspackages/framework-context/src/tests/DependencyGraphManifest.spec.tspackages/framework-module/src/ModuleRegistry.tspackages/framework-module/src/index.tspackages/framework-module/src/tests/ModuleGraphManifest.spec.tspackages/framework-module/src/types.tspublic-api-surface.snapshot.json
Closes #977.
Summary
@croco/framework-context, including missing provider, circular dependency, scope mismatch, and TypeDI fallback diagnostics.@croco/framework-module, including pre-start module cycle and provider visibility diagnostics.croco di checkso CI can validate DI/module manifest JSON without importing or running app code.Validation
pnpm --filter @croco/framework-context exec vitest run src/tests/DependencyGraphManifest.spec.tspnpm --filter @croco/framework-module exec vitest run src/tests/ModuleGraphManifest.spec.tspnpm --filter @croco/cli exec vitest run src/tests/diCheck.spec.tspnpm test --filter=@croco/framework-contextpnpm test --filter=@croco/framework-modulepnpm --filter @croco/cli testpnpm --filter @croco/framework-context typecheckpnpm --filter @croco/framework-module typecheckpnpm --filter @croco/cli typecheckpnpm --filter @croco/framework-context lintpnpm --filter @croco/framework-module lintpnpm --filter @croco/cli lintpnpm public-api:checkpnpm package-manifests:checkpnpm changeset-required:check -- --base origin/trunk --head HEADpnpm checkpnpm typecheckpnpm create-croco-app:smokepnpm testpnpm typecheckReview notes
croco di checkreads an explicit manifest file and reports its diagnostics; it does not load controllers, providers, modules, or user application code.framework-context/di-unknown-providererrors so static verification does not hide unverifiable runtime state.Summary by CodeRabbit
릴리스 노트
New Features
di check명령 추가로 의존성 주입 및 모듈 그래프 검증 가능Documentation
Tests