fix: detect generated contract drift without rewriting outputs - #1434
Conversation
|
Warning Review limit reached
Next review available in: 18 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 Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (30)
📝 WalkthroughWalkthroughOpenAPI와 RPC 코드 생성 CLI에 출력 드리프트 검사 기능이 추가되었습니다. 생성 앱 템플릿은 생성과 읽기 전용 검증을 분리하고, 스모크 테스트와 검증 정책은 새로운 계약 검사 흐름을 반영합니다. Changes읽기 전용 코드 생성 드리프트
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant CodegenCLI
participant GeneratedOutput
participant ContractVerify
Developer->>CodegenCLI: pnpm codegen
CodegenCLI->>GeneratedOutput: write OpenAPI and RPC outputs
Developer->>ContractVerify: pnpm contract:verify
ContractVerify->>CodegenCLI: run --output-check
CodegenCLI->>GeneratedOutput: compare without writing
GeneratedOutput-->>ContractVerify: drift status
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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✅ All benchmarks passed
Updated: 2026-07-23T01:58:23.853Z · Commit: 286564d |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/create-croco-app/templates/spa-be-split/package.json.hbs`:
- Around line 16-27: Remove the redundant provider-rpc typecheck invocation from
the contract:verify script. Keep contract:client:check unchanged, since it
already runs pnpm --filter {{scope}}/provider-rpc typecheck.
In `@packages/rpc-codegen/src/libs/generate.ts`:
- Around line 3469-3541: normalizeGeneratedContent와 openapi-spec의 중복된 개행 정규화 로직을
하나의 공유 유틸리티로 추출하세요. generate.ts의 normalizeGeneratedContent 구현을 제거하고
compareClientFiles가 공유 유틸리티를 사용하도록 변경하며, openapi-spec 측도 동일한 유틸리티를 재사용하게 하세요.
기존의 CRLF 및 CR을 LF로 변환하는 동작은 유지하세요.
🪄 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: 89a08ec1-c173-4830-9489-ab7df3e5929f
⛔ Files ignored due to path filters (1)
packages/problems-core/src/generated/problem-code-registry.tsis excluded by!**/generated/**
📒 Files selected for processing (27)
.changeset/read-only-codegen-drift.mddocs/problem-code-registry.jsonpackages/create-croco-app/src/tests/e2e-generation.spec.tspackages/create-croco-app/src/tests/templates-build.spec.tspackages/create-croco-app/templates/admin-console/README.md.hbspackages/create-croco-app/templates/admin-console/package.json.hbspackages/create-croco-app/templates/ai-saas/README.md.hbspackages/create-croco-app/templates/ai-saas/package.json.hbspackages/create-croco-app/templates/saas/README.md.hbspackages/create-croco-app/templates/saas/package.json.hbspackages/create-croco-app/templates/spa-be-split/README.md.hbspackages/create-croco-app/templates/spa-be-split/package.json.hbspackages/docs/src/content/docs/en/reference/problem-recovery-cookbook.mdpackages/openapi-spec/src/libs/cli.tspackages/openapi-spec/src/libs/output.tspackages/openapi-spec/src/tests/Cli.spec.tspackages/openapi-spec/src/tests/Output.spec.tspackages/rpc-codegen/src/libs/cli.tspackages/rpc-codegen/src/libs/generate.tspackages/rpc-codegen/src/tests/Cli.spec.tspackages/rpc-codegen/src/tests/codegen.spec.tsscripts/create-croco-app-generated-smoke.mtsscripts/static-misuse-raw-error-allowlist.jsonscripts/tests/create-croco-app-generated-smoke.spec.tsscripts/tests/verification-policy.spec.tsscripts/verification-policy.mtstsconfig/contract-strict.baseline.json
|
Pre-merge evidence: all issue-scoped checks pass, CodeRabbit approved the latest commit, and both review threads are resolved. The remaining validate failure is the same dependency-audit-policy failure present on current trunk, with no manifest or lockfile changes in this PR. The companion report has 0 generated-app gate failures and fails only in the unrelated graphql-vite-spa-astryx SSR case because the packaged ui-astryx build references a missing React global; every issue-scoped generated-app case passes. Local pre-push repository tests are 226/226 and typecheck is 225/225. |
ba0eb1c to
c518f67
Compare
|
Updated onto current trunk at ba1c12d. The trunk lockfile and dependency overrides resolve the prior blocking brace-expansion, js-yaml, and axios audit findings; dependency-audit-policy now passes locally. Fresh validation on head c518f67: repository profile passed 21/22 with one non-applicable check, package suites passed OpenAPI 59/59, RPC 112/112, create-croco-app 108/108, all four issue-scoped generated-app smoke cases passed, pre-push tests passed 226/226, and typecheck passed 225/225. |
|
Post-fix verification for head
The remaining required-check failure is external to #1322: The optional companion check also has only the pre-existing |
9f2d3cd to
780e0be
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/create-croco-app-generated-smoke.mts (1)
2373-2396: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win검증 실패를
Problem하위 타입으로 표준화하세요.새 런타임 계약 검증이 일반
Error를 던집니다. 코드와 category를 가진 전용Problem하위 타입을 사용해야 합니다. As per coding guidelines, “Throw only Problem subclasses, never generic Error instances”.🤖 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 `@scripts/create-croco-app-generated-smoke.mts` around lines 2373 - 2396, Update the runtime contract validation checks in the smoke-test flow to throw the established Problem subclass instead of generic Error instances. Ensure each validation failure preserves its descriptive message and uses the required code and category fields, including the checks for engines.node, .nvmrc, README guidance, and deployment-runtime wording.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 `@packages/rpc-codegen/src/libs/generate.ts`:
- Line 3524: Update the diagnostic sorting in the return path associated with
compareClientFiles() to use deterministic code-unit string comparison instead of
localeCompare(). Preserve sorting by each drift’s filePath so diagnostics and
regeneration commands have stable ordering across locales.
---
Outside diff comments:
In `@scripts/create-croco-app-generated-smoke.mts`:
- Around line 2373-2396: Update the runtime contract validation checks in the
smoke-test flow to throw the established Problem subclass instead of generic
Error instances. Ensure each validation failure preserves its descriptive
message and uses the required code and category fields, including the checks for
engines.node, .nvmrc, README guidance, and deployment-runtime wording.
🪄 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: 319b503e-6c92-4bed-9943-15e0e7092126
⛔ Files ignored due to path filters (1)
packages/problems-core/src/generated/problem-code-registry.tsis excluded by!**/generated/**
📒 Files selected for processing (34)
.changeset/read-only-codegen-drift.mddocs/problem-code-registry.jsonpackages/create-croco-app/src/tests/e2e-generation.spec.tspackages/create-croco-app/src/tests/templates-build.spec.tspackages/create-croco-app/templates/addons/graphql-nextjs/apps/web/package.json.hbspackages/create-croco-app/templates/addons/trpc-nextjs/apps/web/package.json.hbspackages/create-croco-app/templates/addons/web-graphql/apps/web/package.json.hbspackages/create-croco-app/templates/addons/web-trpc/apps/web/package.json.hbspackages/create-croco-app/templates/admin-console/README.md.hbspackages/create-croco-app/templates/admin-console/package.json.hbspackages/create-croco-app/templates/ai-saas/README.md.hbspackages/create-croco-app/templates/ai-saas/package.json.hbspackages/create-croco-app/templates/saas/README.md.hbspackages/create-croco-app/templates/saas/package.json.hbspackages/create-croco-app/templates/spa-be-split/README.md.hbspackages/create-croco-app/templates/spa-be-split/package.json.hbspackages/docs/src/content/docs/api/problems-core/src/variables/CROCO_PROBLEM_CODE_REGISTRY.mdpackages/docs/src/content/docs/en/reference/problem-recovery-cookbook.mdpackages/openapi-spec/src/libs/cli.tspackages/openapi-spec/src/libs/output.tspackages/openapi-spec/src/tests/Cli.spec.tspackages/openapi-spec/src/tests/Output.spec.tspackages/rpc-codegen/src/libs/cli.tspackages/rpc-codegen/src/libs/generate.tspackages/rpc-codegen/src/tests/Cli.spec.tspackages/rpc-codegen/src/tests/codegen.spec.tsscripts/alpha-release-smoke.mtsscripts/create-croco-app-generated-smoke.mtsscripts/static-misuse-raw-error-allowlist.jsonscripts/tests/alpha-release-smoke.spec.tsscripts/tests/create-croco-app-generated-smoke.spec.tsscripts/tests/verification-policy.spec.tsscripts/verification-policy.mtstsconfig/contract-strict.baseline.json
769cb34 to
1f02444
Compare
Outcome
OpenAPI and RPC code generation now provide an explicit read-only
--output-checkmode that compares committed artifacts with the production emitters without changing files. Drift reports stable missing, changed, or unexpected-file diagnostics and an exact recovery command, while the existing graph-diagnostic--checkcontract remains unchanged.Generated admin-console, SaaS, AI-SaaS, and split-app projects now separate intentional
codegenwrites from read-onlycontract:verifychecks. Generated-app smoke coverage guards tracked files so CI proves contracts were already synchronized.Verification
@croco/openapi-specsuite — 59/59 tests@croco/rpc-codegensuite — 112/112 testscreate-croco-appsuite — 108/108 testsReview gates
--checkis unchanged; the new mode is additive; package manifests, dependencies, lockfile, and public exports are unchanged; patch changesets cover all affected packages.Validation note
The complete generated-app smoke run passed every issue-scoped case; the unrelated
graphql-vite-spa-astryxcase on trunk still fails during SSR because its packaged UI references a missing React global. This change does not touch that package or path.Fixes #1322
Summary by CodeRabbit
--output-check로 OpenAPI 문서 및 RPC 클라이언트 생성 결과의 드리프트를 덮어쓰기 없이 검사할 수 있습니다.