SQLite storage layer #9109

Closed
opened 2026-02-16 18:11:40 -05:00 by yindo · 2 comments
Owner

Originally created by @florianleibert on GitHub (Feb 11, 2026).

Originally assigned to: @thdxr on GitHub.

Task: SQLite storage layer

Description

Create the SQLite storage layer for the quality monitoring system using bun:sqlite. This includes database initialization, schema creation, migrations, CRUD operations for responses and regressions, query helpers for aggregations, and automatic retention cleanup.

Acceptance Criteria

  • packages/opencode/src/quality/store.ts created with full SQLite wrapper
  • Database initialized at configurable path (default .opencode/quality.db)
  • responses table with columns: id, session_id, model_id, provider_id, timestamp, prompt_hash, response_hash, composite_score, correctness_score, feedback_score, analysis_score, diagnostic_notes (JSON), is_collaborative, tokens_input, tokens_output, cost
  • regressions table with columns: id, response_id, detected_at, score_delta, severity, component, description
  • Indexes on: responses(session_id), responses(model_id), responses(timestamp), regressions(severity)
  • CRUD operations: insertResponse, updateResponseScore, insertRegression, getResponsesBySession, getResponsesByModel, getRecentResponses(limit)
  • Aggregation queries: getModelAverages, getRollingAverage(windowSize), getScoreTrend(days)
  • Retention cleanup: deleteOlderThan(days) runs on DB init
  • Schema version tracking for future migrations
  • Graceful error handling — DB failures logged, never crash main workflow

Technical Details

  • Use bun:sqlite (built-in, zero dependencies)
  • Use Database class from bun:sqlite with WAL mode for performance
  • Store DB path resolved relative to project directory via Instance.directory
  • Follow existing Instance.state() pattern for per-project DB lifecycle
  • Create packages/opencode/src/quality/schema.ts with Zod schemas for type safety on insert/query results

Dependencies

  • None — this is a foundation task

Effort Estimate

  • Size: M
  • Hours: 6-8
  • Parallel: true
Originally created by @florianleibert on GitHub (Feb 11, 2026). Originally assigned to: @thdxr on GitHub. # Task: SQLite storage layer ## Description Create the SQLite storage layer for the quality monitoring system using `bun:sqlite`. This includes database initialization, schema creation, migrations, CRUD operations for responses and regressions, query helpers for aggregations, and automatic retention cleanup. ## Acceptance Criteria - [ ] `packages/opencode/src/quality/store.ts` created with full SQLite wrapper - [ ] Database initialized at configurable path (default `.opencode/quality.db`) - [ ] `responses` table with columns: id, session_id, model_id, provider_id, timestamp, prompt_hash, response_hash, composite_score, correctness_score, feedback_score, analysis_score, diagnostic_notes (JSON), is_collaborative, tokens_input, tokens_output, cost - [ ] `regressions` table with columns: id, response_id, detected_at, score_delta, severity, component, description - [ ] Indexes on: responses(session_id), responses(model_id), responses(timestamp), regressions(severity) - [ ] CRUD operations: insertResponse, updateResponseScore, insertRegression, getResponsesBySession, getResponsesByModel, getRecentResponses(limit) - [ ] Aggregation queries: getModelAverages, getRollingAverage(windowSize), getScoreTrend(days) - [ ] Retention cleanup: deleteOlderThan(days) runs on DB init - [ ] Schema version tracking for future migrations - [ ] Graceful error handling — DB failures logged, never crash main workflow ## Technical Details - Use `bun:sqlite` (built-in, zero dependencies) - Use `Database` class from `bun:sqlite` with WAL mode for performance - Store DB path resolved relative to project directory via `Instance.directory` - Follow existing `Instance.state()` pattern for per-project DB lifecycle - Create `packages/opencode/src/quality/schema.ts` with Zod schemas for type safety on insert/query results ## Dependencies - [ ] None — this is a foundation task ## Effort Estimate - Size: M - Hours: 6-8 - Parallel: true
yindo added the needs:compliance label 2026-02-16 18:11:40 -05:00
yindo closed this issue 2026-02-16 18:11:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 11, 2026):

This issue doesn't fully meet our contributing guidelines.

What needs to be fixed:

  • This issue uses a custom "Task" format instead of one of the three required templates: Bug Report, Feature Request, or Question
  • Every issue must use one of these standard templates for consistent triage and processing

Please edit this issue to follow one of the required templates within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions[bot] commented on GitHub (Feb 11, 2026): <!-- issue-compliance --> This issue doesn't fully meet our [contributing guidelines](../blob/dev/CONTRIBUTING.md). **What needs to be fixed:** - This issue uses a custom "Task" format instead of one of the three required templates: Bug Report, Feature Request, or Question - Every issue must use one of these standard templates for consistent triage and processing Please edit this issue to follow one of the required templates within **2 hours**, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 11, 2026):

This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new issue that follows our issue templates.

@github-actions[bot] commented on GitHub (Feb 11, 2026): This issue has been automatically closed because it was not updated to meet our [contributing guidelines](../blob/dev/CONTRIBUTING.md) within the 2-hour window. Feel free to open a new issue that follows our issue templates.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9109