Skip to content

Centralize OpenWork runtime DB#2071

Open
benjaminshafii wants to merge 1 commit into
devfrom
feat/runtime-db-foundation
Open

Centralize OpenWork runtime DB#2071
benjaminshafii wants to merge 1 commit into
devfrom
feat/runtime-db-foundation

Conversation

@benjaminshafii
Copy link
Copy Markdown
Member

Summary

  • Add a shared OpenWork runtime SQLite DB layer with schema_migrations and migration_state scaffolding.
  • Move runtime OpenCode config and OpenWork workspace config stores onto the shared DB helper without changing table names or DB path behavior.
  • Serialize runtime JSON row updates to preserve unrelated keys during concurrent MCP/plugin/provider writes.
  • Expose runtime DB path, schema version, migrations, and table counts in Advanced runtime config diagnostics.
  • Add runtime DB end-user eval runbook coverage.

Tests

  • pnpm --filter openwork-server test src/runtime-db.test.ts src/runtime-opencode-config-store.test.ts src/desktop-cloud-sync.test.ts ✅
  • pnpm --filter openwork-server typecheck ✅
  • pnpm --filter @openwork/app typecheck ✅

E2E eval coverage

  • Added evals/runtime-db-flows.md with user-visible flows for runtime DB initialization, MCP/plugin persistence, cloud import metadata, malformed config diagnostics, old runtime DB upgrade, and Den-provisioned provider task execution.
  • I did not capture a new Daytona video in this turn; the eval runbook documents the exact flows reviewers can replay.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview, Comment Jun 3, 2026 4:11am
openwork-den Ready Ready Preview, Comment Jun 3, 2026 4:11am
openwork-den-worker-proxy Ready Ready Preview, Comment Jun 3, 2026 4:11am
openwork-landing Ready Ready Preview, Comment, Open in v0 Jun 3, 2026 4:11am

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 10 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/server/src/runtime-db.ts">

<violation number="1" location="apps/server/src/runtime-db.ts:208">
P2: DB open cache set too late. Race can open same path twice, and failed open gets stuck in cache. Store a single in-flight promise before await and clear cache on reject.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

const path = runtimeDbPath(config);
const existing = dbByPath.get(path);
if (existing) return existing;
await ensureDir(dirname(path));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: DB open cache set too late. Race can open same path twice, and failed open gets stuck in cache. Store a single in-flight promise before await and clear cache on reject.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/server/src/runtime-db.ts, line 208:

<comment>DB open cache set too late. Race can open same path twice, and failed open gets stuck in cache. Store a single in-flight promise before await and clear cache on reject.</comment>

<file context>
@@ -0,0 +1,240 @@
+  const path = runtimeDbPath(config);
+  const existing = dbByPath.get(path);
+  if (existing) return existing;
+  await ensureDir(dirname(path));
+  const db = typeof process.versions.bun === "string" ? openBunRuntimeDb(path) : openNodeRuntimeDb(path);
+  dbByPath.set(path, db);
</file context>

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