Skip to content

fix(sdk): respect @@strict inherited from mixins in type def generation - #2812

Merged
ymc9 merged 1 commit into
devfrom
fix/strict-inherited-mixin
Aug 23, 2026
Merged

fix(sdk): respect @@strict inherited from mixins in type def generation#2812
ymc9 merged 1 commit into
devfrom
fix/strict-inherited-mixin

Conversation

@ymc9

@ymc9 ymc9 commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • The strict: true flag in generated type-def schemas was gated on hasAttribute(td, '@@strict'), which only inspects attributes declared directly on the type def, while the attributes array is built with getAllAttributes (which walks mixins). A type def inheriting @@strict from a mixin (type Profile with Strict) carried the attribute in its attributes array but never got strict: true, so the Zod validation and strict typing paths silently treated it as loose.
  • Fixed by checking the inherited attribute collection from getAllAttributes(td). The lite-filtered local attributes variable is deliberately not reused so the flag is emitted regardless of lite mode.

Testing

  • Added a "supports @@strict inherited from mixins" case to packages/cli/test/ts-schema-gen.test.ts alongside the existing direct-@@strict test; both pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Corrected generated type definitions so they correctly inherit strictness from strict mixins.
    • Ensured types using inherited strict behavior are generated with strict: true.
  • Tests

    • Added coverage verifying strictness is preserved for types inheriting from strict mixins.

The strict flag check used hasAttribute, which only inspects attributes
declared directly on the type def, while the attributes array is built
with getAllAttributes (including mixins). A type def inheriting @@strict
from a mixin thus never got \`strict: true\` in the generated schema.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 186098b1-b4a0-46d8-8491-fa08a0c9fc2a

📥 Commits

Reviewing files that changed from the base of the PR and between a46d1a6 and a84710a.

📒 Files selected for processing (2)
  • packages/cli/test/ts-schema-gen.test.ts
  • packages/sdk/src/ts-schema-generator.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The TypeScript schema generator now detects @@strict on resolved attributes, including inherited mixins. A CLI test verifies that the generated definition sets strict: true.

Changes

Inherited strictness detection

Layer / File(s) Summary
Resolve strictness from inherited attributes
packages/sdk/src/ts-schema-generator.ts, packages/cli/test/ts-schema-gen.test.ts
createTypeDefObject checks resolved attributes for @@strict. The test verifies strict output for a type that uses a Strict mixin.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a8471

The change makes generated schemas honor inherited @@strict behavior from mixins and adds coverage for that case; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: sanny-io

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix for inherited @@strict handling in type definition generation.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/strict-inherited-mixin

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli/test/ts-schema-gen.test.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

packages/sdk/src/ts-schema-generator.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ymc9
ymc9 merged commit ca354fe into dev Aug 23, 2026
8 checks passed
@ymc9
ymc9 deleted the fix/strict-inherited-mixin branch August 23, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant