fix: enforce staged strict REST contract gates - #1051
Conversation
|
Warning Review limit reached
More reviews will be available in 31 minutes and 25 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 (9)
📝 WalkthroughWalkthrough
ChangesStaged Strict Contract Typecheck & REST Misuse Gate
Sequence Diagram(s)sequenceDiagram
rect rgba(70, 130, 180, 0.5)
Note over CICheck,baseline: pnpm check / smoke 실행
end
participant CICheck as pnpm check / smoke
participant runGeneratedAppContractGates
participant strictTypecheck as strict-contract-typecheck
participant staticMisuse as static-misuse:check
participant oxlint as oxlint (templates)
participant tsc as tsc (protocols-core)
participant baseline as contract-strict.baseline.json
CICheck->>runGeneratedAppContractGates: 게이트 순차 실행
runGeneratedAppContractGates->>strictTypecheck: pnpm strict-contract-typecheck
strictTypecheck->>tsc: spawnSync tsc --project tsconfig.contract-strict.json
tsc-->>strictTypecheck: 진단 출력
strictTypecheck->>baseline: readBaseline()
baseline-->>strictTypecheck: 기준 진단 목록
strictTypecheck-->>runGeneratedAppContractGates: passed / exit(1)
runGeneratedAppContractGates->>staticMisuse: pnpm static-misuse:check
staticMisuse-->>runGeneratedAppContractGates: passed / exit(1)
runGeneratedAppContractGates->>oxlint: pnpm exec oxlint packages/create-croco-app/templates
oxlint-->>runGeneratedAppContractGates: passed / exit(1)
runGeneratedAppContractGates-->>CICheck: 모든 게이트 통과
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 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-20T18:16:24.460Z · Commit: 676598b |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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/ai-saas/apps/api-server/src/controllers/aiSchemas.ts`:
- Line 3: The constant optionalTenantIdHeaderSchema uses camelCase naming
convention but the repository requires SCREAMING_SNAKE_CASE for all constant
declarations in TypeScript and JavaScript files. Rename
optionalTenantIdHeaderSchema to OPTIONAL_TENANT_ID_HEADER_SCHEMA in the
declaration within the aiSchemas.ts file, and update all import statements and
usages of this constant throughout the codebase to use the new
SCREAMING_SNAKE_CASE name.
In
`@packages/create-croco-app/templates/saas/apps/api-server/src/controllers/schemas.ts`:
- Around line 173-176: Rename the four exported schema constants in the
schemas.ts file from camelCase to SCREAMING_SNAKE_CASE: jobIdSchema should
become JOB_ID_SCHEMA, optionalJobStatusQuerySchema should become
OPTIONAL_JOB_STATUS_QUERY_SCHEMA, optionalJobTypeQuerySchema should become
OPTIONAL_JOB_TYPE_QUERY_SCHEMA, and optionalJobsIntegerQuerySchema should become
OPTIONAL_JOBS_INTEGER_QUERY_SCHEMA. After renaming these constants in their
declaration locations, also update all corresponding import statements and
usages of these constants in JobsController.ts to reference the new
SCREAMING_SNAKE_CASE names.
In `@packages/oxlint-rules/src/tests/rest-generated-contract-schema.spec.ts`:
- Around line 56-58: The test file is throwing a generic Error which violates
the repository exception policy that restricts generic Error throws. In the test
helper function around the importListener type check, replace the throw new
Error statement with a Vitest assertion instead. Use Vitest's expect API to
assert that importListener is a function type, which will fail the test
appropriately if the condition is not met, rather than throwing a generic Error
exception.
In `@scripts/static-misuse-check.mts`:
- Around line 106-121: The regex patterns in the match functions at lines 106,
112, and in the matchSchemaLessNamedParamDecorator function are matching
decorator patterns anywhere in the line, including within comments. To fix this,
modify the match functions to exclude commented portions of the line before
applying the regex. Either strip everything after // in each line before
matching, or add a check to skip lines that only contain decorator usage within
comments. This will prevent false positives when decorators are mentioned in
documentation comments or example comments.
In `@scripts/strict-contract-typecheck.mts`:
- Around line 166-213: The current implementation in the main function reads the
baseline and compares only the diagnostics, but does not validate that the
baseline metadata (version, strictOptions, packages) matches the current
configuration. After reading the baseline using readBaseline(rootDir) and before
calling compareStrictContractDiagnostics, add validation checks to ensure the
baseline version, strictOptions, and packages list align with the current
rollout configuration tracked by rolloutPackages. If any metadata mismatch is
detected, throw an error to prevent the gate from passing with stale or drifted
contract data.
🪄 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: 2867dbc1-325c-4e1c-8b8a-280c076a02fb
📒 Files selected for processing (24)
.changeset/strict-rest-contract-gate.md.oxlintrc.jsondocs/static-misuse-checks.mddocs/strict-contract-typecheck.mdpackage.jsonpackages/create-croco-app/templates/ai-saas/apps/api-server/src/controllers/AiController.tspackages/create-croco-app/templates/ai-saas/apps/api-server/src/controllers/aiSchemas.tspackages/create-croco-app/templates/saas/apps/api-server/src/controllers/JobsController.tspackages/create-croco-app/templates/saas/apps/api-server/src/controllers/schemas.tspackages/oxlint-rules/src/index.tspackages/oxlint-rules/src/rules/rest-generated-contract-schema.tspackages/oxlint-rules/src/tests/index.spec.tspackages/oxlint-rules/src/tests/rest-generated-contract-schema.spec.tspackages/protocols-core/src/libs/ContractGraph.tspackages/protocols-core/src/libs/ContractGraphSnapshot.tspackages/protocols-core/tsconfig.contract-strict.jsonscripts/create-croco-app-generated-smoke.mtsscripts/package-quality-report.mtsscripts/static-misuse-check.mtsscripts/strict-contract-typecheck.mtsscripts/tests/package-quality-report.spec.tsscripts/tests/static-misuse-check.spec.tsscripts/tests/strict-contract-typecheck.spec.tstsconfig/contract-strict.baseline.json
Fixes #981.
Summary
Verification
Self-review gates
Independent review
A read-only adversarial review initially found three issues: generated-app smoke did not run the new gates, oxlint only covered controller paths, and the strict typecheck parser could pass fatal unparsed compiler output. The final patch adds smoke preflight gates, broadens the import-aware oxlint override to all generated template TypeScript files, and treats global/unclassified TypeScript output as fatal with regression coverage.
Risk
Low-medium. The strict gate currently filters diagnostics to @croco/protocols-core so transitive dependency strict failures do not block this rollout stage; additional packages should be added explicitly with their own strict-clean state or reviewed baselines.
Summary by CodeRabbit
릴리스 노트
새로운 기능
문서