Skip to content

fix(world): give isolated headless worlds their own OpenCode sessions database - #4372

Merged
yomgui merged 1 commit into
devfrom
fix/headless-isolated-engine-data
Sep 3, 2026
Merged

yomgui merged 1 commit into
devfrom
fix/headless-isolated-engine-data

Conversation

@yomgui

@yomgui yomgui commented Sep 3, 2026

Copy link
Copy Markdown
Member

Why

pnpm world up dev-headless (state isolated) spawned its managed opencode serve with the person's HOME and no OPENCODE_DB, so it opened the same ~/.local/share/opencode/opencode.db as the installed desktop app. Two long-lived engines on one SQLite file means every journal write in one is a busy_timeout wait in the other, and world sessions land in the person's history. On the reporting machine a headless engine from Sep 1 was still holding the desktop's 1.5 GB database open while the desktop engine was timing out. Only installed-production worlds isolated engine data (installedProductionHeadlessEnv).

What

  • resolveHeadlessWorldRuntimePaths exposes opencodeDbPath: tmp/dev-headless-opencode.db for the compatibility world, tmp/worlds/runtime/<name>/opencode.db for named worlds.
  • New isolatedHeadlessEngineEnv(runtimePaths, env) sets exactly OPENCODE_DB for the isolated branch. HOME/XDG_* are deliberately untouched so the world keeps the person's provider auth.json and engine log; an explicit OPENCODE_DB still wins.
  • The managed engine inherits the server's process.env (managed-opencode.ts), so the variable reaches opencode serve without further plumbing.
  • AGENTS.md documents the location.

Behavior change: the isolated world no longer sees desktop sessions — which is what "isolated" means. installed-production is unchanged.

Verification

Lane: local (pure path/env resolution; no Daytona prerequisite applies).

pnpm evals:pr specs/headless-world-engine-isolation.test.ts
  ✓ an isolated headless world gives its engine a private sessions database  (1 passed, 0 failed, 0 skipped) exit 0
pnpm --filter @openwork/world exec node --test test/headless-isolation.test.ts test/headless-production.test.ts   9 pass / 0 fail
pnpm --filter @openwork/world typecheck                                                                            exit 0

Verdict: Passed.

Related: #4371 (server log file). Follow-ups: engine-rollover fingerprint, engine-stall UX.

… database

The isolated headless world inherited HOME and no OPENCODE_DB, so its managed
engine opened ~/.local/share/opencode/opencode.db alongside the installed
desktop app. Two long-lived engines then contended for SQLite's single writer
(every journal write in one was a busy_timeout wait in the other) and world
sessions landed in the person's history. Only installed-production worlds
isolated this.

- resolveHeadlessWorldRuntimePaths exposes opencodeDbPath
  (tmp/dev-headless-opencode.db, or <runtime dir>/opencode.db for named worlds).
- isolatedHeadlessEngineEnv sets exactly OPENCODE_DB for the isolated branch;
  HOME/XDG stay untouched so the person's provider auth.json still resolves.
  An explicit OPENCODE_DB wins.
- AGENTS.md documents the location.
@vercel

vercel Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 3, 2026 9:46pm UTC
openwork-den Ready Ready Preview Sep 3, 2026 9:46pm UTC
openwork-diagnostics Ready Ready Preview Sep 3, 2026 9:46pm UTC
openwork-landing Ready Ready Preview, v0 Sep 3, 2026 9:46pm UTC

@yomgui

yomgui commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

Test evidence — an-isolated-headless-world-gives-its-engine-a-private-sessions-database — ✅ passed

✅ passed · 2 expectations passed · 0 failed · 0 pending

verdict passed · 0 user observations · 0 probes · steps 0/0

ℹ️ ASSERTION — 1. The isolated world's engine opens tmp/dev-headless-opencode.db

resolveHeadlessWorldRuntimePaths yields a world-owned database path and isolatedHeadlessEngineEnv sets exactly OPENCODE_DB to it, leaving HOME and XDG_DATA_HOME untouched so provider credentials still resolve.

  • ✅ PASS The isolated world's engine opens tmp/dev-headless-opencode.db — resolveHeadlessWorldRuntimePaths yields a world-owned database path and isolatedHeadlessEngineEnv sets exactly OPENCODE_DB to it, leaving HOME and XDG_DATA_HOME untouched so provider credentials still resolve.

ℹ️ ASSERTION — 2. Explicit overrides and the installed-production world are unchanged

An explicit OPENCODE_DB still wins, and the installed-production env test keeps pointing at the installed database.

  • ✅ PASS Explicit overrides and the installed-production world are unchanged — An explicit OPENCODE_DB still wins, and the installed-production env test keeps pointing at the installed database.

Test run created 2026-09-03T21:45:23.785Z · Source: evals/results/test-runs/2026-09-03T21-45-23-784Z-an-isolated-headless-world-gives-its-engine-a-private-sessions-database/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4372 --test-run 2026-09-03T21-45-23-784Z-an-isolated-headless-world-gives-its-engine-a-private-sessions-database

@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 (8481eba7921852ec9ff514f76084c7b2dbd87928). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 8481eba7 Deployed Sep 3, 2026 by vercel[bot]
Preview – openwork-den — 8481eba7 Deployed Sep 3, 2026 by vercel[bot]
Preview – openwork-app — 8481eba7 Deployed Sep 3, 2026 by vercel[bot]
Preview – openwork-diagnostics — 8481eba7 Deployed Sep 3, 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