CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlite-go-best-practices

SQLite best practices for Go — WAL mode, foreign_keys, busy_timeout, SetMaxOpenConns, context-aware queries, transactions, migrations

98

2.36x
Quality

99%

Does it follow best practices?

Impact

97%

2.36x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-1/

{
  "context": "Tests whether the agent proactively applies SQLite best practices when building an HTTP API with SQLite. The task describes a REST API with relationships (bookmarks and folders via join table) but never mentions WAL, foreign keys, connection settings, or context propagation from HTTP handlers. Key areas: context from http.Request propagated to DB calls, foreign_keys ON for cascade deletes, transaction for bookmark+folder creation.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "modernc.org/sqlite driver",
      "description": "Uses modernc.org/sqlite (pure Go) rather than mattn/go-sqlite3 (CGO)",
      "max_score": 7
    },
    {
      "name": "WAL mode enabled",
      "description": "WAL journal mode is set via connection string pragma or PRAGMA statement",
      "max_score": 10
    },
    {
      "name": "foreign_keys enabled",
      "description": "Foreign key enforcement is enabled via the connection string so it applies to every pooled connection. This is critical because the schema uses ON DELETE CASCADE.",
      "max_score": 10
    },
    {
      "name": "busy_timeout configured",
      "description": "busy_timeout pragma is set to prevent immediate SQLITE_BUSY errors",
      "max_score": 7
    },
    {
      "name": "SetMaxOpenConns(1)",
      "description": "db.SetMaxOpenConns(1) is called to prevent 'database is locked' errors from concurrent HTTP requests",
      "max_score": 12
    },
    {
      "name": "HTTP request context propagated to DB",
      "description": "Database query functions accept context.Context (typically from r.Context() in HTTP handlers) and use QueryContext/ExecContext/BeginTx -- enabling cancellation when clients disconnect",
      "max_score": 12
    },
    {
      "name": "defer rows.Close()",
      "description": "Every QueryContext call is followed by defer rows.Close()",
      "max_score": 7
    },
    {
      "name": "rows.Err() checked",
      "description": "rows.Err() is checked after iterating rows",
      "max_score": 5
    },
    {
      "name": "Parameterized queries",
      "description": "All queries use ? placeholders -- no string interpolation or concatenation",
      "max_score": 10
    },
    {
      "name": "Transaction for bookmark with folders",
      "description": "Creating a bookmark with folder associations uses a transaction to ensure the bookmark and all folder links are created atomically",
      "max_score": 8
    },
    {
      "name": "defer tx.Rollback()",
      "description": "Transactions use defer tx.Rollback() immediately after BeginTx",
      "max_score": 5
    },
    {
      "name": "ON DELETE CASCADE in schema",
      "description": "The bookmark_folders join table uses ON DELETE CASCADE on the bookmark foreign key so deleting a bookmark automatically removes associations",
      "max_score": 7
    }
  ]
}

evals

scenario-1

criteria.json

task.md

tile.json