Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pipeline Plan 17

Seth Ford edited this page Feb 11, 2026 · 4 revisions

The plan has been fully developed. Here's the complete implementation plan:


SQLite Persistence Layer for Team State — Implementation Plan

Summary

Replace JSON file-based state management with SQLite for atomic concurrent writes, efficient aggregate queries, and schema migration support. Dual-write approach: events go to both JSONL and SQLite for backward compatibility. Falls back to JSON when sqlite3 is unavailable.

Files to Create (6 new files)

File Purpose
scripts/lib/migrations/001_initial_schema.sql 7 tables: events, pipeline_runs, sessions, developers, cost_entries, metrics, memory_entries + schema_version
scripts/lib/migrations/002_indexes.sql Composite indexes on type+epoch, issue, stage, repo_hash
scripts/lib/db.sh Bash SQLite helper library — sw_db_init(), sw_db_migrate(), sw_db_available(), insert/query wrappers
dashboard/db.ts TypeScript module using bun:sqlite — typed query helpers replacing O(n) JS loops with indexed SQL
scripts/sw-db.sh CLI subcommand: shipwright db migrate/status/export/import/query
scripts/sw-db-test.sh 15+ test cases covering CRUD, migrations, concurrency, fallback

Files to Modify (9 existing files)

File Change
scripts/lib/helpers.sh Add dual-write db_emit_event() — writes both JSONL and SQLite
scripts/sw-daemon.sh Track pipeline_runs in SQLite; SQL-based DORA metric queries
scripts/sw-cost.sh Write cost_entries; SQL aggregation for summaries
scripts/sw-connect.sh Upsert developers table from heartbeats
scripts/sw-memory.sh Write memory_entries for patterns/failures
dashboard/server.ts Use dashboard/db.ts for reads, JSON fallback
scripts/sw Register db subcommand
package.json Add sw-db-test.sh to test chain
.claude/CLAUDE.md Document db subcommand and schema

14 Task Checklist

  1. Create migration SQL files (schema + indexes)
  2. Create scripts/lib/db.sh — bash SQLite helpers
  3. Create dashboard/db.ts — TypeScript SQLite module
  4. Modify helpers.sh — dual-write event emission
  5. Modify sw-daemon.sh — pipeline_runs + SQL DORA queries
  6. Modify sw-cost.sh — SQLite cost recording
  7. Modify sw-connect.sh — SQLite developer registry
  8. Modify sw-memory.sh — SQLite memory entries
  9. Modify dashboard/server.ts — SQL reads with JSON fallback
  10. Create sw-db.sh — CLI subcommand
  11. Register db in scripts/sw router
  12. Create sw-db-test.sh — test suite
  13. Update package.json + CLAUDE.md
  14. Run full test suite, fix regressions

Key Architecture Decisions

  • Dual-write: Events written to both JSONL and SQLite — no migration cutover needed
  • WAL mode: Concurrent dashboard reads while daemon writes
  • Zero dependencies: bun:sqlite for TypeScript, sqlite3 CLI for bash (ships with macOS/Linux)
  • JSON blob columns: data TEXT on events/developers/memory for flexible fields alongside indexed columns
  • Graceful degradation: Every SQLite read has a JSON fallback path — sw_db_available() gates all SQL paths

The full detailed plan with SQL schemas, example queries, and test specifications is ready. The plan was written to .claude/pipeline-artifacts/plan.md.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /