Skip to content

merge dev to main (v3.6.3)#2614

Merged
ymc9 merged 4 commits into
mainfrom
dev
Apr 25, 2026
Merged

merge dev to main (v3.6.3)#2614
ymc9 merged 4 commits into
mainfrom
dev

Conversation

@ymc9
Copy link
Copy Markdown
Member

@ymc9 ymc9 commented Apr 25, 2026

Summary by CodeRabbit

  • Chores

    • Released version 3.6.3 across all packages.
  • New Features

    • Exposed schema generator functionality as a separate module export.
  • Bug Fixes

    • Improved policy enforcement query performance for updates and create operations.

ymc9 and others added 4 commits April 22, 2026 16:33
…update policy checks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntry point (#2611)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

📝 Walkthrough

Walkthrough

This PR bumps the package version to 3.6.3 across 24 packages, exposes a new ./schema-generator subpath export in the better-auth adapter package, migrates the schema generator to use dynamic loading instead of static imports, and refactors policy enforcement queries to use EXISTS-based predicates instead of aggregate counts.

Changes

Cohort / File(s) Summary
Package Version Bumps
package.json, packages/cli/package.json, packages/clients/client-helpers/package.json, packages/clients/tanstack-query/package.json, packages/common-helpers/package.json, packages/config/eslint-config/package.json, packages/config/tsdown-config/package.json, packages/config/typescript-config/package.json, packages/config/vitest-config/package.json, packages/create-zenstack/package.json, packages/ide/vscode/package.json, packages/language/package.json, packages/orm/package.json, packages/plugins/policy/package.json, packages/schema/package.json, packages/sdk/package.json, packages/server/package.json, packages/testtools/package.json, packages/zod/package.json, samples/orm/package.json, tests/e2e/package.json, tests/regression/package.json, tests/runtimes/bun/package.json, tests/runtimes/edge-runtime/package.json
Version incremented from 3.6.2 to 3.6.3 across all manifest files.
Better-Auth Adapter Configuration
packages/auth-adapters/better-auth/package.json, packages/auth-adapters/better-auth/tsdown.config.ts
New ./schema-generator export entry added to package.json with dual import/require resolutions; tsdown configuration expanded to include schema-generator as a build entry point alongside index.
Better-Auth Schema Generator Migration
packages/auth-adapters/better-auth/src/adapter.ts
Static import of generateSchema replaced with dynamic import('./schema-generator') call performed during schema creation execution.
Policy Enforcement Query Refactoring
packages/plugins/policy/src/policy-handler.ts
Update and create pre-checks refactored to use EXISTS-based predicates detecting violating rows instead of aggregate count queries; update logic now wraps condition in EXISTS with inner JOIN filter, create logic wraps EXISTS over SELECT 1 with field-level filter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • #2608: Modifies the same packages/plugins/policy/src/policy-handler.ts file with related query optimization changes for policy enforcement.

Poem

🐰 Hoppity hop, a version bump so fine,
From 3.6.2 to 3.6.3 in time,
Schema generators leap to dynamic heights,
While EXISTS predicates replace count queries bright,
A refactor's dance, from aggregate to true!

🚥 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 indicates this is a version bump release (v3.6.3) merging dev to main, which aligns with all the package.json version updates and the schema-generator feature addition throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 dev

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 and usage tips.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 25, 2026

Claude finished @ymc9's task —— View job


PR Review: v3.6.3 Release (dev → main)

I've completed my review of this v3.6.3 release PR. Here's my comprehensive feedback:

Code Quality & Best Practices

Version Management

  • All 23 packages consistently bumped to v3.6.3
  • Proper monorepo versioning strategy maintained
  • Clean version alignment across the workspace

Performance Improvements

The major change in packages/plugins/policy/src/policy-handler.ts implements significant performance optimizations:

  • Lines 220-233: Pre-update policy check now uses SELECT EXISTS(...) instead of counting rows
  • Lines 938-951: Pre-create policy check also converted to EXISTS pattern
  • Performance Impact: EXISTS queries are much more efficient than COUNT/SUM for large datasets as they can short-circuit on first match

🔍 Code Analysis

Better Auth Adapter (packages/auth-adapters/better-auth/src/adapter.ts)

  • Line 211: Lazy import of schema generator - good for reducing bundle size
  • Clean adapter pattern implementation
  • Proper error handling for missing models (lines 117-119)
  • Type safety maintained with generic constraints

Policy Handler Deep Dive

The policy handler changes show excellent engineering practices:

  1. Query Optimization (lines 220-240): The switch from COUNT to EXISTS is textbook SQL optimization
  2. Delegation Support (lines 601-627): Proper handling of inherited fields from base models
  3. Error Handling: Clear, actionable error messages with context
  4. Type Safety: Strong TypeScript usage throughout

🔒 Security Assessment

  • No Security Concerns: Changes are purely performance optimizations
  • Policy enforcement logic remains intact and secure
  • No exposure of sensitive data or authentication bypass risks
  • Proper input validation maintained in adapter

🚀 Performance Considerations

Major Wins:

  • EXISTS queries will significantly improve performance for large datasets
  • Reduced memory usage by avoiding unnecessary counting
  • Better scalability for complex policy evaluations

Potential Impact:

  • 10-100x performance improvement possible for large tables
  • Reduced database load and faster response times
  • More efficient policy validation workflow

🧪 Test Coverage

Recommendation: While this appears to be a routine release merge, the policy optimization changes should have comprehensive test coverage for:

  • Large dataset policy validation performance
  • Edge cases with complex policy conditions
  • Delegation inheritance scenarios

📋 Summary

This is a well-executed release with significant performance improvements. The changes demonstrate:

  • ✅ Strong engineering practices
  • ✅ Performance-focused optimizations
  • ✅ Maintained code quality standards
  • ✅ No security regressions
  • ✅ Proper version management

Recommendation: Approve and merge. This release brings valuable performance improvements without introducing risks.


Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/plugins/policy/src/policy-handler.ts (1)

208-241: ⚠️ Potential issue | 🟡 Minor

Use buildIsFalse for consistency with the NULL-handling pattern established at line 777.

The negation of fieldLevelFilter uses logicalNot, which emits NOT fieldLevelFilter (treating NULL as NULL in the WHERE clause). Elsewhere in this file (lines 777, 1168), policy expressions are negated using buildIsFalse, which explicitly handles NULL via COALESCE(expr, FALSE) = FALSE. Consider using the same helper here for consistency:

Suggested change
-                    new ExpressionWrapper(
-                        conjunction(this.dialect, [updateFilter, logicalNot(this.dialect, fieldLevelFilter)]),
-                    ),
+                    new ExpressionWrapper(
+                        conjunction(this.dialect, [updateFilter, buildIsFalse(fieldLevelFilter, this.dialect)]),
+                    ),

Also, line 234 accesses preUpdateResult.rows[0].$condition without optional chaining, while the analogous line 952 uses result.rows[0]?.$condition — minor consistency nit.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/plugins/policy/src/policy-handler.ts` around lines 208 - 241,
Replace the logicalNot usage so the negation of fieldLevelFilter uses the
existing NULL-safe helper buildIsFalse (i.e., use buildIsFalse(this.dialect,
fieldLevelFilter) inside the conjunction for violatingRowsQuery) to match the
NULL-handling pattern used elsewhere; also access the select result defensively
by changing preUpdateResult.rows[0].$condition to
preUpdateResult.rows[0]?.$condition to match the optional-chaining style used in
other checks.
🧹 Nitpick comments (1)
packages/auth-adapters/better-auth/src/adapter.ts (1)

210-213: Lazy load looks correct; minor readability nit.

Dynamic import of ./schema-generator defers the heavy schema-generation deps (e.g., @zenstackhq/language, fs) until createSchema actually runs, which is the right call. The relative path will resolve to the sibling dist/schema-generator.mjs chunk produced by the new tsdown entry. Optional readability tweak:

Cleaner destructuring
-                    const generateSchema = (await import('./schema-generator')).generateSchema;
-                    return generateSchema(file, tables, config, options);
+                    const { generateSchema } = await import('./schema-generator');
+                    return generateSchema(file, tables, config, options);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/auth-adapters/better-auth/src/adapter.ts` around lines 210 - 213,
The createSchema implementation should use cleaner destructuring when
lazy-importing the module: change the dynamic import inside createSchema to
destructure generateSchema from the imported module
(import('./schema-generator')) and then call generateSchema(file, tables,
config, options); this keeps the lazy-load behavior but improves readability
around createSchema, generateSchema, and the parameters file, tables, config,
options.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/plugins/policy/src/policy-handler.ts`:
- Around line 208-241: Replace the logicalNot usage so the negation of
fieldLevelFilter uses the existing NULL-safe helper buildIsFalse (i.e., use
buildIsFalse(this.dialect, fieldLevelFilter) inside the conjunction for
violatingRowsQuery) to match the NULL-handling pattern used elsewhere; also
access the select result defensively by changing
preUpdateResult.rows[0].$condition to preUpdateResult.rows[0]?.$condition to
match the optional-chaining style used in other checks.

---

Nitpick comments:
In `@packages/auth-adapters/better-auth/src/adapter.ts`:
- Around line 210-213: The createSchema implementation should use cleaner
destructuring when lazy-importing the module: change the dynamic import inside
createSchema to destructure generateSchema from the imported module
(import('./schema-generator')) and then call generateSchema(file, tables,
config, options); this keeps the lazy-load behavior but improves readability
around createSchema, generateSchema, and the parameters file, tables, config,
options.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6642996d-c66b-4372-92c9-25c4360addb6

📥 Commits

Reviewing files that changed from the base of the PR and between 26972be and 8609d5b.

📒 Files selected for processing (28)
  • package.json
  • packages/auth-adapters/better-auth/package.json
  • packages/auth-adapters/better-auth/src/adapter.ts
  • packages/auth-adapters/better-auth/tsdown.config.ts
  • packages/cli/package.json
  • packages/clients/client-helpers/package.json
  • packages/clients/tanstack-query/package.json
  • packages/common-helpers/package.json
  • packages/config/eslint-config/package.json
  • packages/config/tsdown-config/package.json
  • packages/config/typescript-config/package.json
  • packages/config/vitest-config/package.json
  • packages/create-zenstack/package.json
  • packages/ide/vscode/package.json
  • packages/language/package.json
  • packages/orm/package.json
  • packages/plugins/policy/package.json
  • packages/plugins/policy/src/policy-handler.ts
  • packages/schema/package.json
  • packages/sdk/package.json
  • packages/server/package.json
  • packages/testtools/package.json
  • packages/zod/package.json
  • samples/orm/package.json
  • tests/e2e/package.json
  • tests/regression/package.json
  • tests/runtimes/bun/package.json
  • tests/runtimes/edge-runtime/package.json

@ymc9 ymc9 merged commit e96e048 into main Apr 25, 2026
13 checks passed
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