Skip to content

refactor(server): remove ~4k LOC of dead legacy surface from openwork-server - #4188

Merged
benjaminshafii merged 2 commits into
devfrom
thin/server-phase1
Aug 28, 2026
Merged

benjaminshafii merged 2 commits into
devfrom
thin/server-phase1

Conversation

@benjaminshafii

@benjaminshafii benjaminshafii commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Why

apps/server is ~38k LOC of non-test src on top of an engine (opencode) that already ships sessions, events, files, config, and MCP surfaces. For comparison, T3 Code drives opencode as one of five providers with ~2.6k LOC behind a 135-line adapter interface. The gap is duplication, dead surface, and legacy migrations — not features. This is phase 1 of thinning openwork-server to the smallest layer that adds real value over opencode: -3,951 / +66 lines, all of it surface with zero production callers (each verified by repo-wide sweeps across apps/, packages/, ee/, and evals/).

Explicitly untouched: OpenWork Connect MCP (managed MCP connections, connect state/catalogs, cloud MCP health) and cloud provider injection / managed provider auth.

What's removed

Surface Evidence it was dead
Blueprint session seeding: POST /workspace/:id/blueprint/sessions/materialize, blueprint-sessions.ts, opencode-db.ts (direct writes into opencode's SQLite) Only reference in the app is a comment noting the route-state caller was already removed (use-workspace-route-state.ts). The direct opencode-SQLite coupling is gone; dependency declaration cleanup is deferred to avoid unrelated lockfile churn. sanitizeOpenworkTemplateConfig moved to workspace-export-safety.ts (still used by the kept GET /export).
Workspace import: POST /workspace/:id/import, POST /workspace/:id/import/preview, workspace-import-preview.ts Renderer client methods importWorkspace/previewWorkspaceImport had zero call sites; desktop imports archives via its own workspace-archive.mjs. Export (GET /workspace/:id/export) stays.
POST /workspace/:id/extensions/export, extensions-export.ts No callers anywhere.
Legacy GET/POST /experimental/google-workspace/* (7 routes) + the OAuth connect-flow manager wiring Repo-wide grep: only the route definitions and one test referenced these paths. The same payloads flow through POST /experimental/extensions/call (the gating test asserted equality between both paths; it now probes the extensions path). The google-workspace extension module and all 14 data actions are untouched.
One-time legacy config migrations: POST /workspace/:id/runtime-config/migrate + merge/strip helpers, legacy-config-sweep.ts boot sweep, legacyOpenwork/migratableKeys/sweep fields on GET /runtime-config Migration shipped long ago. The Settings → Advanced section keeps its config-source inspection (now AdvancedRuntimeConfigSourcesSection); only the Migrate action and the sweep display in Debug are gone.
File-session extras: read-batch, write-batch, renew, catalog/events No callers anywhere. catalog/snapshot and ops stay (used by the app). The den-gateway allowlist test hits a mock upstream and still passes unchanged.

Verification

  • pnpm --filter openwork-server typecheck — pass
  • pnpm --filter @openwork/app typecheck — pass
  • pnpm --filter openwork-server test (bun):
    • this branch: 751 pass / 8 skip / 1 fail / 1 error — 760 tests, 99 files
    • clean origin/dev baseline (same machine): 791 pass / 8 skip / 1 fail / 1 error — 800 tests, 105 files
    • The single fail+error is identical on both: workspace-kv-store.node.test.ts cannot resolve node:sqlite under bun 1.3.5 (pre-existing env issue, file untouched here). The −40 tests / −6 files are exactly the deleted test files. Zero new failures.
  • Edited test files re-run green: extensions-connect-gating, runtime-opencode-config-store, file-sessions, artifact-files.e2e — 15 pass / 0 fail.
  • CI install path validated locally: pnpm install --frozen-lockfile --prefer-offline passes with the trusted existing lockfile metadata.

Follow-ups (not in this PR)

  1. Single config-delivery path: collapse the ~1.1k-LOC engine-MCP live registration machine in server.ts into "write runtime DB → write OPENCODE_CONFIG → reload" (needs care: cloud-mcp-health + diagnostics read its state).
  2. Extract cloud/Den coupling (~13k LOC: cloud-mcp-health, agent-context diagnostics, provider/plugin sync, connect catalogs, extensions) behind its existing narrow interface into a sidecar package.
  3. Route automation-runner.mjs + @openwork/headless-threads through the opencode proxy and drop the duplicated session wrapper endpoints.
  4. Sweep now-unused i18n keys (settings.runtime_config_legacy_cleanup_* etc.) and the now-caller-less google-workspace connect-flow exports.

Deletes server surface with zero production callers, verified by
repo-wide caller sweeps:

- blueprint session seeding (+ direct opencode-DB writes) — the UI
  caller was removed earlier; drops the better-sqlite3 native dep
- workspace import preview/apply routes — desktop imports archives via
  workspace-archive.mjs; the renderer client methods were never called
- POST /workspace/:id/extensions/export — no callers
- legacy /experimental/google-workspace/* routes — superseded by
  /experimental/extensions/call (gating test now probes that path)
- one-time legacy config migrations: /runtime-config/migrate route +
  helpers, the legacy-config-sweep boot sweep, and the
  Settings > Advanced migrate action (config source inspection stays)
- file-session read-batch/write-batch/renew/catalog-events routes — no
  callers anywhere (den-gateway test hits a mock upstream, still green)

Kept intact: OpenWork Connect MCP (managed MCP, connect state and
catalogs, cloud MCP health) and cloud provider injection / managed
provider auth.

openwork-server suite: 751 pass / 8 skip / 1 fail / 1 error — the same
single pre-existing env failure as clean origin/dev (bun 1.3.5 lacks
node:sqlite for workspace-kv-store.node.test.ts); zero new failures.
Server and app typechecks pass.
@vercel

vercel Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview Aug 28, 2026 4:45am
openwork-den Ready Ready Preview Aug 28, 2026 4:45am
openwork-diagnostics Ready Ready Preview Aug 28, 2026 4:45am
openwork-landing Ready Ready Preview, v0 Aug 28, 2026 4:45am

diff-warden[bot]
diff-warden Bot previously approved these changes Aug 28, 2026

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (7cc5e1db4fdf2fcaf15917312c1980d676eeba2d). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (56e13e93a7d2e1a1722780910727e004a7521140). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@benjaminshafii
benjaminshafii merged commit 2af0c98 into dev Aug 28, 2026
18 checks passed
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026
benjaminshafii pushed a commit that referenced this pull request Aug 28, 2026

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 56e13e93 Deployed Aug 28, 2026 by vercel[bot]
Preview – openwork-den — 56e13e93 Deployed Aug 28, 2026 by vercel[bot]
Preview – openwork-app — 56e13e93 Deployed Aug 28, 2026 by vercel[bot]
Preview – openwork-diagnostics — 56e13e93 Deployed Aug 28, 2026 by vercel[bot]
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