Skip to content

Persist SQL and DuckDB artifacts in storage database#62

Merged
skgbafa merged 1 commit into
mainfrom
tc-1388-storage-backend
May 18, 2026
Merged

Persist SQL and DuckDB artifacts in storage database#62
skgbafa merged 1 commit into
mainfrom
tc-1388-storage-backend

Conversation

@skgbafa
Copy link
Copy Markdown
Contributor

@skgbafa skgbafa commented May 16, 2026

Summary

  • Adds a database_artifact migration/model and a SeaORM repository backed by storage.database for SQL/DuckDB artifact payloads and metadata.
  • Treats local SQL/DuckDB files as cache: cold opens hydrate from the durable artifact row, and stale local-only cache files are removed when no durable row exists.
  • Persists checkpointed/exported SQL and DuckDB artifacts after successful writes/imports before returning success; durable-save failure returns an error and evicts local cache state.
  • Adds service tests for SQL restart with empty cache, DuckDB restart/export with empty cache, DuckDB import restart with empty cache, and durable persistence failure.

Verification

  • cargo test -p tinycloud-core - passed, 53 tests + doc tests.
  • cargo test -p tinycloud-node - passed, 31 lib tests, 3 main tests + doc tests.
  • git diff --check - passed.

Residual Risks / Follow-ups

  • Artifacts are stored as database blobs for this vertical slice. Very large SQL/DuckDB databases may need a follow-up backend that stores payload bytes through the configured block store while keeping metadata/revisions in storage.database.
  • This does not automatically migrate pre-existing local-only SQL/DuckDB cache files into the durable artifact table; an explicit one-time migration/import flow may be needed for legacy local data.
  • Invocation metadata is still committed before the SQL/DuckDB service path runs. Artifact persistence failure now fails the request, but the invocation metadata row can already exist.

@skgbafa skgbafa merged commit dfe776d into main May 18, 2026
15 checks passed
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