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-4/

{
  "context": "Tests whether the agent applies SQLite best practices when building a task queue that requires atomic claim operations and concurrent access from HTTP handlers. Key challenges: the claim operation needs a transaction for atomicity, SetMaxOpenConns(1) is essential since multiple HTTP requests hit the DB concurrently, context propagation from HTTP handlers is important for cancellation, and busy_timeout is critical for a service that receives concurrent requests.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "modernc.org/sqlite driver",
      "description": "Uses modernc.org/sqlite (pure Go) rather than mattn/go-sqlite3",
      "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 via DSN",
      "description": "Foreign key enforcement is enabled via connection string pragma",
      "max_score": 5
    },
    {
      "name": "busy_timeout set",
      "description": "busy_timeout pragma is configured -- especially important for a service handling concurrent HTTP requests",
      "max_score": 10
    },
    {
      "name": "SetMaxOpenConns(1)",
      "description": "db.SetMaxOpenConns(1) is called -- critical for a concurrent HTTP service using SQLite",
      "max_score": 12
    },
    {
      "name": "Atomic claim with transaction",
      "description": "The claim operation uses a transaction (BeginTx) that atomically selects the next pending task and updates its status to 'processing' -- preventing two workers from claiming the same task",
      "max_score": 15
    },
    {
      "name": "HTTP context propagated to DB",
      "description": "Database functions accept context.Context (from r.Context()) and use QueryContext/ExecContext/BeginTx",
      "max_score": 10
    },
    {
      "name": "defer tx.Rollback() pattern",
      "description": "All transactions use defer tx.Rollback() immediately after BeginTx",
      "max_score": 7
    },
    {
      "name": "defer rows.Close()",
      "description": "Every QueryContext call is followed by defer rows.Close()",
      "max_score": 5
    },
    {
      "name": "Parameterized queries",
      "description": "All queries use ? placeholders -- no string interpolation",
      "max_score": 10
    },
    {
      "name": "CHECK constraint on status",
      "description": "The tasks table includes a CHECK constraint on status limiting to valid values",
      "max_score": 4
    },
    {
      "name": "Index on status and priority",
      "description": "The migration creates an index on (status, priority) or similar to optimize the claim query that finds pending tasks ordered by priority",
      "max_score": 5
    }
  ]
}

evals

tile.json