Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jun 29, 2025

Summary by CodeRabbit

  • Tests

    • Added a new test suite to validate client extension behaviors for policy-enforced database queries, including plugin-based query overrides and result mutations.
  • Chores

    • Updated dependency versions for langium and langium-cli in workspace and package configuration files to improve consistency and alignment with other dependencies.

ymc9 and others added 2 commits June 29, 2025 08:37
* test: policy + client extension interaction

* Update packages/runtime/test/policy/client-extensions.test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* remove log

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2025 06:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR merges changes from the dev branch into main and updates dependencies as well as introduces new tests. Key changes include dependency version updates in the workspace configuration and package manifest, along with the addition of extensive tests for query override behavior in the runtime policies.

Reviewed Changes

Copilot reviewed 3 out of 7 changed files in this pull request and generated 1 comment.

File Description
pnpm-workspace.yaml Updated langium and added langium-cli with version 3.5.0
packages/runtime/test/policy/client-extensions.test.ts Added new tests for different query override scenarios
packages/language/package.json Changed langium-cli dependency from "~3.3.0" to "catalog:" format
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@coderabbitai
Copy link

coderabbitai bot commented Jun 29, 2025

Walkthrough

The changes update dependency version specifications for langium and langium-cli in both the workspace and a package, introducing a new protocol for one. Additionally, a comprehensive test suite is added to validate client extension behaviors in policy-enforced query scenarios using plugins.

Changes

File(s) Change Summary
packages/language/package.json Updated langium-cli devDependency version specifier to use the catalog: protocol.
pnpm-workspace.yaml Updated langium version to 3.5.0 and added langium-cli at version 3.5.0.
packages/runtime/test/policy/client-extensions.test.ts Added new test suite for client extension plugin behaviors with policy-enforced queries.

Sequence Diagram(s)

sequenceDiagram
    participant TestSuite
    participant TestClient
    participant Plugin
    participant Database

    TestSuite->>TestClient: Setup with model and policy
    TestSuite->>Database: Create raw records (bypassing policy)
    TestSuite->>TestClient: Register Plugin (override query)
    TestSuite->>TestClient: Invoke query (e.g., findMany)
    TestClient->>Plugin: Intercept query (modify/filter/mutate)
    Plugin->>TestClient: Return modified query/result
    TestClient->>Database: Execute query with overrides
    Database-->>TestClient: Return results
    TestClient-->>TestSuite: Return filtered/mutated results
    TestSuite->>TestSuite: Assert results as expected
Loading

Poem

In the warren of code, dependencies hop,
Langium and friends get a version swap.
New tests appear, plugins take flight—
Filtering queries by day and by night.
With each assertion, the carrots abound,
As client extensions leap and bound! 🥕

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/runtime/test/policy/client-extensions.test.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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.

Actionable comments posted: 0

♻️ Duplicate comments (4)
packages/runtime/test/policy/client-extensions.test.ts (4)

72-73: Same duplicate assertion pattern - consider documentation.

Similar to the previous test, if the duplicate assertion is intentional for idempotency testing, a comment would improve clarity.


107-108: Consistent duplicate assertion pattern across tests.

The same pattern of duplicate assertions appears across all tests. Consider adding explanatory comments if this is intentional behavior testing.


142-143: Final duplicate assertion in this test pattern.

Maintaining consistency with the previous tests' duplicate assertion pattern.


177-179: Duplicate assertion with different expected value structure.

This test uses a different expected value format (expect.objectContaining) but maintains the same duplicate assertion pattern.

🧹 Nitpick comments (2)
packages/runtime/test/policy/client-extensions.test.ts (2)

37-38: Consider consolidating duplicate assertions or add explanation.

The same assertion is repeated twice. If this is intentional for testing idempotency, consider adding a comment to clarify the purpose.

 await expect(db.$use(ext).model.findMany()).resolves.toHaveLength(1);
-await expect(db.$use(ext).model.findMany()).resolves.toHaveLength(1);
+// Test idempotency - second call should return same result
+await expect(db.$use(ext).model.findMany()).resolves.toHaveLength(1);

28-32: Consider improving type safety in plugin definitions.

While any types are common in test code, consider using more specific types for better type safety and IDE support.

-model: {
-    findMany({ args, query }: any) {
+model: {
+    findMany({ args, query }: { args?: any; query: (args: any) => Promise<any> }) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50a3a79 and eebc676.

⛔ Files ignored due to path filters (4)
  • packages/language/src/generated/ast.ts is excluded by !**/generated/**
  • packages/language/src/generated/grammar.ts is excluded by !**/generated/**
  • packages/language/src/generated/module.ts is excluded by !**/generated/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/language/package.json (1 hunks)
  • packages/runtime/test/policy/client-extensions.test.ts (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime/test/policy/client-extensions.test.ts (1)
packages/runtime/test/policy/utils.ts (1)
  • createPolicyTestClient (5-13)
🔇 Additional comments (4)
pnpm-workspace.yaml (1)

9-10: LGTM! Coordinated dependency version management.

The upgrade to fixed versions 3.5.0 for both langium and langium-cli provides consistency across the workspace. The addition of langium-cli to the catalog properly supports the protocol change in the package file.

packages/language/package.json (1)

54-54: Previous concern resolved - dependency now properly cataloged.

The change to "catalog:" protocol is now correct since langium-cli: 3.5.0 has been properly added to the workspace catalog in pnpm-workspace.yaml.

packages/runtime/test/policy/client-extensions.test.ts (2)

1-4: LGTM! Proper test setup and imports.

The imports are correctly structured for a vitest-based test suite with appropriate client extension utilities.


146-180: Excellent coverage of result mutation functionality.

This test effectively validates that client extensions can modify query results post-execution, demonstrating the plugin system's flexibility for data transformation scenarios.

@ymc9 ymc9 added this pull request to the merge queue Jun 29, 2025
Merged via the queue into main with commit 7322db8 Jun 29, 2025
6 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.

2 participants