fix: publish ContractGraph v1 snapshot - #1118
Conversation
|
Warning Review limit reached
Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. 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, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthrough
ChangesContractGraph v1 스냅샷과 CLI 검증
Sequence Diagram(s)sequenceDiagram
participant User as CLI 사용자
participant runCli as runCli
participant buildContractGraph as buildContractGraph
participant getContractGraphErrors as getContractGraphErrors
participant emitOpenAPIFromContractGraph as emitOpenAPIFromContractGraph
User->>runCli: --check 또는 --out 실행
runCli->>buildContractGraph: controllers, strictProblemResponses
buildContractGraph-->>runCli: graph
runCli->>getContractGraphErrors: graph
getContractGraphErrors-->>runCli: errors
alt --check
runCli->>User: 진단 출력 및 종료 코드 반환
else errors 존재
runCli->>User: 오류 요약 출력
else 정상
runCli->>emitOpenAPIFromContractGraph: graph
emitOpenAPIFromContractGraph-->>runCli: OpenAPI JSON
runCli->>User: 파일 출력
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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-30T10:09:17.971Z · Commit: 976beb7 |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
31b6724 to
a15bca4
Compare
|
@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 @.changeset/contract-graph-v1-snapshot.md:
- Around line 2-3: The changeset release levels for `@croco/protocols-core` and
`@croco/openapi-spec` should be bumped from patch to minor because the diff
introduces new public-facing functionality. Update the version annotations in
the changeset entry so the packages that expose the new API and CLI behavior are
marked as minor instead of patch.
In `@packages/openapi-spec/src/libs/cli.ts`:
- Around line 65-84: The CLI path in `main` only calls
`reportContractDiagnostics(graph, io)` when `getContractGraphErrors(graph)` has
errors, so diagnostics added by `buildContractGraph(..., {
strictProblemResponses: true })` can be skipped on the `--out` path. Update the
`cli.ts` flow to emit `graph.diagnostics` through `reportContractDiagnostics`
before the `errors.length` check, or otherwise ensure both `--check` and `--out`
paths print diagnostics consistently before continuing to
`emitOpenAPIFromContractGraph` and `writeFile`.
- Around line 1-6: The CLI import block in cli.ts should separate ContractGraph
into its own import type statement instead of mixing it with value imports from
`@croco/protocols-core`. Also update the emit/openapi generation path in cli.ts
(around the main CLI execution logic) so diagnostics produced by
--strict-problems include warning-level entries in the output, ensuring those
warnings are surfaced even when running with --out; use the existing
formatContractDiagnostic and getContractGraphErrors flow to locate where to
collect and print them.
In `@packages/protocols-core/src/libs/ContractGraphSnapshot.ts`:
- Around line 226-235: `isContractGraphV1` only checks top-level fields, so
invalid snapshots like `routes: [null]` can still pass the type guard. Update
this guard in `ContractGraphSnapshot.ts` to validate each element of `routes`
and `diagnostics` as a record, and verify the required core fields and their
types before returning true. Use the existing `isRecord` helper and the
`isContractGraphV1` function as the main entry point for the fix.
🪄 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: 51e2cf50-b5a9-4d91-a999-1fa60d1b0fbc
📒 Files selected for processing (8)
.changeset/contract-graph-v1-snapshot.mdpackages/openapi-spec/src/libs/cli.tspackages/openapi-spec/src/tests/Cli.spec.tspackages/protocols-core/README.mdpackages/protocols-core/src/index.tspackages/protocols-core/src/libs/ContractGraphSnapshot.tspackages/protocols-core/src/tests/ContractGraph.spec.tspublic-api-surface.snapshot.json
a15bca4 to
765b0aa
Compare
Fixes #1084.
Summary
ContractGraphV1JSON-safe REST snapshot schema with deterministiccreateContractGraphV1andstringifyContractGraphV1helpers.@croco/protocols-coreand publishes the new public exports in the API snapshot.--checkand--strict-problemsmatching the existing RPC graph-validation path.Verification
CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/protocols-core exec vitest run src/tests/ContractGraph.spec.ts- passed, 41 tests.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/openapi-spec exec vitest run src/tests/Cli.spec.ts src/tests/OpenApiCliGeneration.spec.ts- passed, 7 tests.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/protocols-core test- passed, 61 tests.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/openapi-spec test- passed, 35 tests.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/protocols-core typecheck- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/openapi-spec typecheck- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/protocols-core lint- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/openapi-spec lint- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/protocols-core build- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/openapi-spec build- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm public-api:check- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm package-manifests:check- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm changeset-required:check -- --base origin/trunk --head HEAD- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm strict-contract-typecheck- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm docs:catalog:check- passed.CI=true COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm check- passed.git diff --checkandgit diff --cached --check- passed.Self-review gates
ContractGraphV1schema, the deterministic reversed-controller snapshot test, source-location assertions, direct weak-schema diagnostic assertions, and OpenAPI CLI graph-validation tests. RPC generation already consumedloadContractGraph; this PR aligns OpenAPI CLI behavior with that graph source before emission.public-api-surface.snapshot.json; patch changesets cover@croco/protocols-coreand@croco/openapi-spec; no package manifest, lockfile, dependency, secret, credential, or runtime environment changes are introduced.createContractGraphSnapshot, schema descriptors, diagnostics, and sorted route data; the OpenAPI CLI reuses existing graph diagnostics instead of adding a parallel route validator; tests are scoped to the new public surface and CLI behavior.Notes
--no-verifyafter the repository hook path entered an interactive pnpm reinstall prompt. The equivalent targeted and repository validations above passed manually through Corepack pnpm 10.15.1.Risk
Low-medium. This adds a public snapshot helper and makes OpenAPI CLI refuse graph errors before writing output; the change is additive for library consumers and intentionally stricter for invalid OpenAPI generation inputs.
Summary by CodeRabbit
--check및--strict-problems옵션이 추가되어, 출력 전 진단을 확인할 수 있습니다(오류 시 OpenAPI 미생성).