Skip to content

fix(app): re-land #4747 — reach engine effective permissions without reusing stale per-workspace provider config - #4876

Merged
yomgui merged 6 commits into
devfrom
fix/workspace-switch-provider-config-after-4747
Sep 11, 2026
Merged

yomgui merged 6 commits into
devfrom
fix/workspace-switch-provider-config-after-4747

Conversation

@yomgui

@yomgui yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member

Re-lands #4747 (reverted by #4870 as f0a62791b) together with the server fix for the regression #4747 exposed.

Root cause

#4747's product change (desktop-runtime-boot.ts: reuse a healthy embedded server on renderer reload instead of openworkServerRestart) is correct; the restart it removed was masking a bug in the engine pool.

EnginePool.requestRollover skips a reload as unchanged when the current runtime-config fingerprint equals primary.fingerprint, and an in-place reload (idle engine) set primary.fingerprint = fingerprint. But an in-place reload only disposes one directory instance (/instance/dispose?directory=<workspace>). So after POST /workspace/w1/engine/reload rebuilt w1's instance, the reloads for w2 and w3 were skipped as unchanged, and their instances kept serving the provider catalog they had built before PATCH /workspace/:id/config wrote the (engine-global) provider. Before #4747 the renderer reload restarted the whole server/engine, rebuilding every instance and hiding this. With #4747, workspace 1 (the one actually reloaded) worked, workspace 2 showed only "OpenCode Zen · 7 models" and Model no longer available / Retry — the signature in gate runs 34529322422 / 34531506976.

The hypothesis in the brief (boot hook targeting the previously active workspace) was checked first and is not what happens: the boot path is unchanged from #4747 and correct. The red→green unit test therefore lives in apps/server/src/engine-pool.test.ts, not apps/app/tests/.

What changed

  • apps/server/src/engine-pool.ts — a generation now records the fingerprint per directory it reloaded in place (reloadedDirectories) instead of overwriting the process fingerprint. The skip guard is primary.fingerprint === current || reloadedDirectories.get(dir) === current. A real rollover (new process) still marks everything current; repeated no-op syncs for the same directory still skip. Same bug class also affected managed_provider_reload / workspace_bootstrap reloads for the non-first workspace.
  • apps/server/src/engine-pool.test.ts — new test: after an in-place reload of workspace A, workspace B still reloads in place; repeats for both skip; a rollover resets.
  • Cherry-picked verbatim from fix(server): make workspace permission changes reach the engine's effective permissions (composer-run-mode) #4747: 29b01227f (boot: reuse running server for server-owned workspace), 0a0b08e35, e154ecafd (evals: emptySession world created at its tmp path; run-mode error detail). git diff 9a60a4b59 -- <those 3 files> is empty.

Proof (sha e154ecafd15aeeb9ae978a67e818e08cbe28215f, Daytona lane, OPENWORK_EVAL_REF exported)

  • Unit red→green: bun --conditions=development test src/engine-pool.test.ts -t "does not skip the other workspaces" — red on dev ({ action: "skipped", reason: "unchanged" } for the second workspace), green after: engine-pool suite 29 pass / 0 fail.
  • Typecheck: pnpm --dir apps/server typecheck exit 0; pnpm --dir apps/app typecheck exit 0.
  • pnpm evals:e2e active-session-workspace-storm --daytona at e154ecafd: passed, passed (2 sequential green runs: sandboxes …-235328-45204, …-000217-90634). One earlier run at the same sha failed at a different assertion (bodyHasMarker read immediately after openExactSessionRoute for workspace 1, line 624 — after all three workspaces had already selected the mock model and reached live tools); same spec is recorded flaking once at a7cf63527 in Revert "fix(server): make workspace permission changes reach the engine's effective permissions (composer-run-mode)" (#4747) #4870 and is green on dev in run 34542680782. Not touched.
  • pnpm evals:e2e active-session-workspace-storm --daytona at aa1441f2b (pre-revert dev + this fix): passed — confirms the fix on the tree where the regression reproduced.
  • pnpm evals:e2e composer-run-mode --daytona at e154ecafd: passed (fix(server): make workspace permission changes reach the engine's effective permissions (composer-run-mode) #4747's intent preserved).
  • Control for unrelated red: apps/server/src/cloud-provider-sync-drain-defer.test.ts fails with failed to set Den session: 403 identically on origin/dev with this patch removed — pre-existing, unrelated.

Noticed, not touched

…ace's in-place reload

Red on dev: the engine pool skips the second workspace's reload as
"unchanged" because the first in-place reload marked the whole primary
generation current, although only that one directory instance was rebuilt.
…er process

An in-place reload disposes ONE directory instance, but the pool recorded
its fingerprint on the primary generation. Every other workspace's reload
was then skipped as unchanged and kept serving the provider catalog it
read before the config change. Before #4747 the renderer reload restarted
the embedded server, which rebuilt every instance and hid this.
…ce is server-owned

Workspaces created from the app live only in the server registry, so a
renderer reload reaches startServerWithoutDesktopWorkspace and restarted
the embedded server (and its engine) although it was healthy and already
serving that workspace. Reuse it when it is ready with the preferred
remote-access mode; only restart when nothing usable is running.
The emptySession world declared /tmp/openwork-empty-session-<ts> but
seed.workspace() adopted the existing first-launch default workspace
instead ("OpenWork Chat" under the dev profile home). On Daytona that
profile lives inside the repo checkout, so the engine merged
/workspace/.opencode/opencode.json ("permission": "allow") over the
workspace's own catch-all and composer-run-mode never saw the workspace
MCP rule take effect.
@vercel

vercel Bot commented Sep 11, 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 11, 2026 12:10am UTC
openwork-den Ready Ready Preview Sep 11, 2026 12:10am UTC
openwork-diagnostics Ready Ready Preview Sep 11, 2026 12:10am UTC
openwork-landing Ready Ready Preview, v0 Sep 11, 2026 12:10am UTC

@github-actions

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (83312 ms), confidentiality-review (79682 ms), spec-provenance-review (58386 ms), desktop-den-sync-review (56710 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

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

@github-actions

Copy link
Copy Markdown
Contributor

Passed · 12/12 tests · 18/18 assertions · 8 images

Commit e154ecafd15aeeb9ae978a67e818e08cbe28215f · selected evidence

Open review report

@yomgui
yomgui merged commit 3724f97 into dev Sep 11, 2026
27 checks passed

This branch was successfully deployed

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