Skip to content

feat(localfirst): PR2 spikes (Worker/OPFS, migration loader, decisions) - #12

Open
kattsushi wants to merge 4 commits into
masterfrom
feat/localfirst-infra-v1-spikes
Open

kattsushi wants to merge 4 commits into
masterfrom
feat/localfirst-infra-v1-spikes

Conversation

@kattsushi

Copy link
Copy Markdown
Owner

Goal

Implement PR2 from openspec/changes/localfirst-infra-v1/tasks.md: de-risk Web Worker bundling + SQLite OPFS worker bootstrap, validate migration loading approach, and close the effect-qb + migration DX decisions.

What’s in this PR

Web spikes

  • Route: /spike-localfirstapps/web/src/routes/spike-localfirst.tsx
    • Worker bundling smoke (Start worker + Ping)
    • SQLite OPFS worker smoke (Start sqlite worker + SELECT 1)
    • Migration loader spike (import.meta.glob raw SQL)
  • Worker modules:
    • apps/web/src/spikes/localfirst/worker.ts
    • apps/web/src/spikes/localfirst/sqlite-opfs-worker.ts
    • apps/web/src/spikes/localfirst/migrations/loader.spike.ts
    • apps/web/src/spikes/localfirst/migrations/sql/0001_spike.sql

Dev header support

  • Adds COOP/COEP headers for local dev in apps/web/vite.config.ts (needed for SharedArrayBuffer/OPFS perf).

Decisions recorded

  • openspec/changes/localfirst-infra-v1/decision-effect-qb.md
  • openspec/changes/localfirst-infra-v1/decision-migration-dx.md

Tooling note

  • Adjusted root lint-staged to run Ultracite only on JS/TS/CSS/SCSS to avoid failing commits that touch only md/json.

Key outcomes

  • Migration loader approach validated: import.meta.glob(..., { as: "raw", eager: true }) works in this Vite/TanStack Start setup.
  • effect-qb:
    • SQLite SQL rendering works (see tools/spikes/effect-qb-sqlite.mjs).
    • BUT importing effect-qb into TS code breaks tsgo due to library-internal typecheck errors → rejected for V1 runtime.
  • Migration DX: no effect-qb migration CLI found → choose Nx workspace generator for V1.

Verification

  • pnpm nx typecheck web
  • pnpm nx test web

Review path

  1. apps/web/src/routes/spike-localfirst.tsx
  2. apps/web/src/spikes/localfirst/sqlite-opfs-worker.ts
  3. apps/web/src/spikes/localfirst/migrations/loader.spike.ts
  4. Decision docs under openspec/changes/localfirst-infra-v1/

Follow-ups (next PRs)

  • PR3 (base: this branch): localfirst-db core contract + in-memory adapter + migration runner tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant