chore(api): Prohibit new direct SQLAlchemy in controller#38624
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an ast-grep–based CI guard to prevent introducing new direct SQLAlchemy usage in api/controllers, while also extracting shared “net-new violation” logic into a reusable helper module for similar lints.
Changes:
- Introduces a shared
scripts/ast_grep_guard.pymodule and refactorscheck_no_new_getattr.pyto use it. - Adds a new controller-focused guard (
check_no_new_controller_sqlalchemy.py) plus a full-tree inventory scanner (lint_controller_sqlalchemy.py). - Wires the new guard/rules into existing GitHub Actions workflows.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/ast_grep_guard.py | Adds shared diff/hunk parsing + ast-grep execution utilities for “net-new” lint guards. |
| scripts/check_no_new_getattr.py | Refactors the getattr guard to use the shared helper API. |
| scripts/check_no_new_controller_sqlalchemy.py | New CI guard to block net-new direct SQLAlchemy usage in controllers (with allow/suppress logic). |
| scripts/lint_controller_sqlalchemy.py | New report/inventory script to enumerate direct SQLAlchemy patterns in controller code. |
| scripts/ast_grep_rules/no_new_controller_sqlalchemy.yml | New ast-grep rule defining what “direct SQLAlchemy usage” matches. |
| .github/workflows/style.yml | Runs the new controller SQLAlchemy guard in the style workflow when relevant files change. |
| .github/workflows/main-ci.yml | Ensures CI considers the new guard/rule files as “api” changes for workflow filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Pyrefly Type Coverage
|
asukaminato0721
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fixes #<issue number>.Summary
No issue
This extracts the common pattern for ast-grep based lints, and adds a script with CI guard to prevent new directly SQLAlchemy code in controllers.
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods