CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlalchemy-best-practices

SQLAlchemy patterns — engine setup, session management, declarative models,

98

1.96x
Quality

99%

Does it follow best practices?

Impact

98%

1.96x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-4/

{
  "context": "Tests whether the agent proactively applies SQLAlchemy best practices when building an inventory system with multiple related entities. The task says nothing about IntegrityError handling, eager loading, cascade rules, or Mapped type syntax.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Mapped types used (not Column)",
      "description": "All model columns use Mapped[type] = mapped_column(...), not legacy Column(). The task did not specify SQLAlchemy version.",
      "max_score": 10
    },
    {
      "name": "back_populates on all relationships",
      "description": "All bidirectional relationships (Category-Product, Product-StockMovement) use back_populates, not backref.",
      "max_score": 8
    },
    {
      "name": "cascade='all, delete-orphan' on parent relationships",
      "description": "Category.products and Product.stock_movements include cascade='all, delete-orphan'. The agent was NOT told about cascade rules.",
      "max_score": 10
    },
    {
      "name": "IntegrityError caught in add_product",
      "description": "The add_product function catches IntegrityError for duplicate SKU and calls db.rollback() before raising a user-friendly error. The agent was NOT told to handle this error specifically.",
      "max_score": 14
    },
    {
      "name": "Eager loading in get_product_detail",
      "description": "get_product_detail uses selectinload/joinedload to load both the category and stock_movements without N+1 queries. The agent was NOT told about eager loading.",
      "max_score": 14
    },
    {
      "name": "select() API used (not db.query)",
      "description": "Queries use the 2.0-style select() construct with db.execute(), not legacy db.query().",
      "max_score": 8
    },
    {
      "name": "pool_pre_ping enabled",
      "description": "Engine created with pool_pre_ping=True.",
      "max_score": 8
    },
    {
      "name": "Session yield/finally cleanup",
      "description": "Session dependency uses yield with finally for safe cleanup.",
      "max_score": 8
    },
    {
      "name": "Foreign key columns indexed",
      "description": "Product.category_id and StockMovement.product_id have index=True.",
      "max_score": 6
    },
    {
      "name": "ondelete='CASCADE' on ForeignKeys",
      "description": "ForeignKey definitions include ondelete='CASCADE' for database-level cascading.",
      "max_score": 6
    },
    {
      "name": "expire_on_commit=False",
      "description": "sessionmaker configured with expire_on_commit=False.",
      "max_score": 8
    }
  ]
}

evals

tile.json