Files
suaveplan/openspec/archive/2026-05-19-wire-surreal-export-store/tasks.md
2026-05-27 23:29:53 +01:00

4.3 KiB

Tasks: wire-surreal-export-store

Ordered checklist. Each task corresponds to a discrete ### Requirement / #### Scenario in specs/api-plugin-export/spec.md.

1. Store contract

  • 1.1 Author src/store/types/types.ts — ExportJobStore async interface (get, set, delete, list, has, clear) + ExportJobStoreListQuery (mirrors ExportJobListQuery without pagination defaults required by SurrealDB).
  • 1.2 Author sibling src/store/types/types.md (≥ 200 words).

2. In-memory backend

  • 2.1 Author src/store/memory/memory-store.ts — MemoryExportJobStore class wrapping Map<string, ExportJob> with ExportJobStore-conformant async methods.
  • 2.2 Author src/store/memory/memory-store.test.ts — 100% coverage of every branch (get / set / delete / list filters + pagination / has / clear).
  • 2.3 Author sibling src/store/memory/memory-store.md (≥ 200 words).
  • 2.4 Author src/store/memory/index.ts barrel (explicit named re-exports — §6a).

3. SurrealDB backend

  • 3.1 Author src/store/surreal/surreal-store.ts — SurrealExportStore class implementing ExportJobStore. Positional $p0…$pN SurQL. Every failure wrapped in ExportError(EXPORT_CODES.JOB_PERSISTENCE_FAILED) with cause chain.
  • 3.2 Author src/store/surreal/surreal-store.types.ts — SurrealExportStoreConfig (Zod-validated, db: SurrealAdapter, tableName optional default "export_job").
  • 3.3 Author sibling src/store/surreal/surreal-store.md (≥ 200 words).
  • 3.4 Author src/store/surreal/index.ts barrel.
  • 3.5 Author src/store/index.ts barrel.

4. Error code registry

  • 4.1 Extend src/error-codes/error-codes.ts — add JOB_PERSISTENCE_FAILED to EXPORT_CODES.
  • 4.2 Update src/error-codes/error-codes.md to describe the new code.
  • 4.3 Extend src/error-codes/error-codes.test.ts with a narrowing test for the new code.

5. SurrealDB schema migration

  • 5.1 Author surql/tables/export_job.surql — DEFINE TABLE OVERWRITE export_job SCHEMAFULL with one field per ExportJobSchema property plus indexes on (status), (format), (resource), (created_at).

6. Service-registry augmentation

  • 6.1 Extend src/services/registry-augmentation.ts — add exportJobStore: ExportJobStore slot.

7. Barrel + subpath exports

  • 7.1 Extend src/index.ts — re-export ExportJobStore (type), MemoryExportJobStore, SurrealExportStore, SurrealExportStoreConfig (type).
  • 7.2 Extend package.json exports map — add ./store/types/types, ./store/memory/memory-store, ./store/surreal/surreal-store.
  • 7.3 Add @suaveplan/surrealdb to dependencies (workspace:^).
  • 7.4 Add @suaveplan/testing-integration-surrealdb to devDependencies.
  • 7.5 Update files array in package.json to include "surql".

8. Integration test (real SurrealDB testcontainer — no mocks)

  • 8.1 Author tests/setup/polyfills.ts mirroring the api-plugin-events setup (in-memory OTel MeterProvider).
  • 8.2 Author tests/integration/surreal-store.test.ts — boots SurrealDBFixture, applies the migration, exercises every ExportJobStore method round-trip.
  • 8.3 Extend vitest.config.ts — add setupFiles: ["./tests/setup/polyfills.ts"], include tests/**/*.test.ts, register the new surreal-store.ts file in coverage excludes only if integration test is the verifier (it is — integration test counts towards coverage).

9. Spec-conformance pin

  • 9.1 Extend src/api-plugin-export.spec-conformance.test.ts to assert JOB_PERSISTENCE_FAILED is thrown from a production source file.

10. Gates

  • 10.1 bunx biome check src/ — zero diagnostics.
  • 10.2 bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-export — green.
  • 10.3 bunx turbo test:coverage --filter=@suaveplan/api-plugin-export — 100 / 100 / 100 / 100.
  • 10.4 bun scripts/openspec-conformance.ts @suaveplan/api-plugin-export — 0 errors.
  • 10.5 bunx turbo build --filter=@suaveplan/api-plugin-export — green.

11. Archive

  • 11.1 Fold specs/api-plugin-export/spec.md into openspec/specs/api-plugin-export/spec.md (## ADDED block appended, ## MODIFIED applied to existing requirement).
  • 11.2 mv openspec/changes/wire-surreal-export-store openspec/archive/2026-05-19-wire-surreal-export-store.