Skip to content

fix(server): make workspace permission changes reach the engine's effective permissions (composer-run-mode) - #4747

Merged
yomgui merged 3 commits into
devfrom
e2e/workspace-permission-reload
Sep 10, 2026
Merged

yomgui merged 3 commits into
devfrom
e2e/workspace-permission-reload

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Fixes Cluster 9 of the 2026-09-09 E2E triage (composer-run-mode: "workspace opencode.json gets permission:{"*":"ask"} but GET permissions/effective keeps reporting the mcp probe as allow / source:"engine" for 60 s").

Root cause

Not a server or engine-reload bug. The engine reload fires, completes, and the rebuilt instance reads the new workspace config; the workspace rule is then shadowed by an ancestor .opencode/opencode.json.

  • emptySession (evals/worlds/desktop.ts) declares /tmp/openwork-empty-session-<ts> but called seed.workspace() without create, so createAndSelectWorkspace adopted the app's existing workspace instead. Since 51c0ab92f (Streamline first launch and complete onboarding before desktop return #4608, Sep 8) first launch auto-creates a default workspace at <dev profile>/openwork-dev-data/home/OpenWork Chat; on Daytona the dev profile lives under /workspace/.openwork-daytona/..., i.e. inside the repo checkout.
  • OpenCode's ConfigPaths.directories walks from the instance directory up to the git worktree and merges every .opencode/opencode.json it finds after the workspace's own opencode.json. The engine log from a red run shows exactly that order:
    loading path=".../home/OpenWork Chat/opencode.jsonc"        <- workspace: {"*":"ask"}
    loading path=/workspace/.opencode/opencode.json             <- repo:      "permission": "allow"
    
    The repo's .opencode/opencode.json ("permission": "allow", since 012bd56ae) wins, so the governing agent's catch-all stays * * allow; OpenWork attributes it to engine because it matches none of the three layers it knows about. The PUT permissions/mode reload confirmation only checks that a snapshot exists, so it reports refresh: "reloaded".
  • This is deterministic since Streamline first launch and complete onboarding before desktop return #4608 (5/5 red on origin/dev @ c744e2d7b in this session; last green nightlies were the two Sep 8 runs before Streamline first launch and complete onboarding before desktop return #4608 merged). The Sep 6-7 reds of this spec were a different, still-flaky failure (see below).

What changed

  1. evals/worlds/desktop.ts — emptySession passes { create: true } so the spec runs against the tmp workspace it declares (same as session-shell, browser-panel, models-analytics). No assertion changed.
  2. evals/specs/composer-run-mode.e2e.test.ts — the read helper includes the server error body in its status assertion message (diagnostic only).
  3. apps/app/src/react-app/shell/desktop-runtime-boot.ts — exposed by (1): workspaces created from the app exist only in the server registry, so after a renderer reload the boot path hit startServerWithoutDesktopWorkspace and restarted the embedded server and engine although both were healthy (Drained engine closed. cause=shutdown, then ~5 s of opencode_unconfigured 400s). Before Streamline first launch and complete onboarding before desktop return #4608 this was hidden because an absent desktop workspace-state file triggered recovery from server.json. The boot now reuses a ready server whose remote-access mode matches and only restarts when nothing usable is running.

Proof (OPENWORK_EVAL_REF exported, fresh sandbox per run, placement daytona)

  • Repro on origin/dev @ c744e2d7b: pnpm evals:e2e composer-run-mode --daytona → 0 passed / 1 failed (engine applies workspace MCP ask timed out, allow / source:"engine"), 5 of 5 runs.
  • a740eb41b (world fix only): step "Ask before actions … reaches the engine" green; next step failed with permissions/effective 400 opencode_unconfigured right after user.reload() (server restart described above).
  • 561b5c03a (this PR head): pnpm evals:e2e composer-run-mode --daytona → passed:1 failed:0 skipped:0, twice in a row (source verified 561b5c03a…). One earlier run at the same sha failed only in the final step (run mode flag disabled after 5 s, last value true) — the same pre-existing flake as the Sep 7 nightly, see below.
  • pnpm evals:e2e composer-draft-reload --daytona at 561b5c03a (the only other emptySession consumer) → passed:1 failed:0 skipped:0.
  • pnpm --filter @openwork/app exec tsc --noEmit clean.

Noticed, not touched

  • Flag toggle flake (pre-existing; Sep 7 nightly and 1 of 3 runs here): clicking workspace-run-mode-flag a second time in Settings → Advanced sometimes leaves the preference true. The harness clicks at coordinates resolved ~250 ms earlier (waitForLocated then clickAt); Advanced has several async sections above the switch. Belongs with Brief B2 (harness click hardening).
  • permissions/effective attributes rules from ancestor .opencode/opencode.json files to engine; a user whose workspace sits inside a repo with such a file sees "Ask before actions" selected while the engine runs everything, and PUT permissions/mode still reports refresh: "reloaded". Worth a project layer and a real post-reload check.
  • Workspaces created from the app never enter the desktop workspace store; on relaunch bootRuntimeForSelectedWorkspace skips with no-local-workspace and the renderer starts the server instead.
  • The repo's own .opencode/opencode.json ("permission": "allow") leaks into any Daytona eval whose workspace is the first-launch default folder; other specs relying on the default workspace inherit it.

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.
…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.
@vercel

vercel Bot commented Sep 10, 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 10, 2026 3:54am UTC
3 Skipped Deployments
Project Deployment Actions Updated
openwork-den Skipped Skipped Sep 10, 2026 3:54am UTC
openwork-diagnostics Skipped Skipped Sep 10, 2026 3:54am UTC
openwork-landing Skipped Skipped v0 Sep 10, 2026 3:54am 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 (46399 ms), confidentiality-review (12633 ms), spec-provenance-review (37623 ms), desktop-den-sync-review (14553 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 (561b5c03abb30875248afdc1bae554727536ba2b). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

Copy link
Copy Markdown
Contributor

Passed · 3/3 tests · 4/4 assertions · 2 images

Commit 561b5c03abb30875248afdc1bae554727536ba2b · selected evidence

Open review report

yomgui added a commit that referenced this pull request Sep 10, 2026
… into e2e/permission-ask-and-orphans-after-abort

Stacks on #4747: creating the world's declared tmp workspace needs its
desktop-runtime-boot fix so user.reload() reuses the running server instead
of restarting the engine (which would drop every pending request). Its files
are not modified here.
yomgui added a commit that referenced this pull request Sep 10, 2026
…lared tmp path

Test 2 of parent-child-permission-approval ran bash without asking although the
world wrote permission.bash="ask" to the workspace opencode.json. The world
called seed.workspace() without create, so it adopted the first-launch default
workspace under the dev profile, which on Daytona lives inside the repo
checkout; the engine merges /workspace/.opencode/opencode.json
("permission": "allow") after the workspace file and the agent ruleset ends
as [* allow, bash ask, * allow] (last match wins; permissions/effective reported
shell allow, source engine, workspace file .../home/OpenWork Chat/opencode.jsonc).

Same trap and same remedy as #4747 for emptySession; opt-in so the other
splitPaneQuestions worlds keep their arrangement.
yomgui added a commit that referenced this pull request Sep 10, 2026
@yomgui
yomgui merged commit 9a60a4b into dev Sep 10, 2026
27 checks passed
diff-warden Bot pushed a commit that referenced this pull request Sep 10, 2026
…ne's effective permissions (composer-run-mode) (#4747)" (#4870)

This reverts commit 9a60a4b.
yomgui added a commit that referenced this pull request Sep 11, 2026
…ed permission requests after Stop (#4798)

* fix(app): seed the delegated-task eval with a running parent thread

The eval.task_activity.seed hook rendered an in-flight child under a parent
whose thread status stayed "ready": it only marked the activity store busy.
Since #4635 MessageList reads that as a stopped parent and the unobserved
child shows "Waiting for task result" instead of the Working shimmer, so
task-activity-shimmer and parent-child-permission-approval lost their
[data-subagent-activity="shimmer"] row. A delegating parent is mid-run;
mark the eval thread streaming like the chat-loading seed already does.

* fix(app): seed a created session's snapshot so its composer can send immediately

A freshly created session had no cached snapshot, so deriveSessionRenderModel
reported "switching" while the first snapshot round trip ran and the composer
disabled Run task. On Daytona that window is ~0.9 s and a click or Enter inside
it was silently dropped with the draft intact. Seed the snapshot cache from the
create response (stale, so the real fetch still runs as a background refresh).

* fix(app): let a send that settled with a server failure recover instead of wedging

A prompt_async answered with 5xx/408 is an uncertain admission (#4635), but
the hold it created could never end: the acceptance check treated absence as
no evidence, Stop refused while the admission was unknown, and the failure body
was dropped, so the person saw a paused composer with no explanation.

- Keep the settled response body on PromptAdmissionUnknownError and show it as
  the session error card right away; the hold still prevents any resend.
- readPromptAdmission: after the exact-message GET misses, list the idle
  conversation; when native lists it without the message the POST is settled
  and did not admit, so the drain receives admission_rejected and halts like
  any definite failure (explicit retry only, never an automatic resend).
- On release the pending row is removed and the submitted composer is kept as
  an unsent message to restore; on confirmed acceptance the stale failure card
  is cleared.

* test(evals): read an empty Lexical composer as an empty draft

Lexical keeps one empty paragraph in an empty editor, which innerText reports
as "\n". readComposerState now drops that trailing line break so draftText
matches what the person sees; user.see("composer", { text }) already trimmed.

* test(evals): open the fresh conversation through the sidebar's New session button

The sidebar button was renamed from "New task" to "New session" in #4491
(Sep 5) and the "new" scenario added in #4631 (Sep 8) still targeted the old
label, so it could never find the button. Same user action, current label.

* test(evals): create the empty-session workspace at its declared tmp path

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.

* test(evals): name the server error when a run-mode read is not 200

* fix(app): reuse the running OpenWork server when the selected workspace 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.

* fix(app): re-read pending questions when a session reaches a terminal edge

An interrupted question tool leaves the engine's pending list through its
finalizer without a question.rejected event, so Stop on a delegated child
left its question (and option buttons) in the parent view. Reconcile
questions alongside permissions on terminal edges, for both engines.

* Revert "fix(app): re-read pending questions when a session reaches a terminal edge"

This reverts commit 9e70982.

* fix(app): withdraw the stopped tree's unanswered questions after Stop

OpenCode v1 runs tools on detached fibers: aborting a session marks the
question tool part as aborted but leaves its request in GET /question, so a
parent that stopped a delegated child kept showing the child's question and
its option buttons. After Stop confirms the tree idle, reject the pending
questions owned by the stopped sessions; other roots are left untouched.

* test(evals): create the permission-stop-recovery workspace at its declared tmp path

Test 2 of parent-child-permission-approval ran bash without asking although the
world wrote permission.bash="ask" to the workspace opencode.json. The world
called seed.workspace() without create, so it adopted the first-launch default
workspace under the dev profile, which on Daytona lives inside the repo
checkout; the engine merges /workspace/.opencode/opencode.json
("permission": "allow") after the workspace file and the agent ruleset ends
as [* allow, bash ask, * allow] (last match wins; permissions/effective reported
shell allow, source engine, workspace file .../home/OpenWork Chat/opencode.jsonc).

Same trap and same remedy as #4747 for emptySession; opt-in so the other
splitPaneQuestions worlds keep their arrangement.

* fix(app): withdraw the stopped tree's unanswered permission requests after Stop

OpenCode v1 runs tools on detached fibers: aborting a session marks the tool
part as aborted but leaves its Permission.ask pending in /permission, exactly
as #4786 found for questions. The stopped tree would keep showing Allow once /
Deny in every pane and after reload although nothing can consume the answer.

After stopForegroundTree confirms every stopped session idle, also list pending
permissions and reject the ones owned by the stopped tree; other roots are
never touched and each withdrawal kind is best-effort on its own.
yomgui added a commit that referenced this pull request Sep 11, 2026
…reusing stale per-workspace provider config (#4876)

* test(server): reload a second workspace in place after another workspace'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.

* fix(server): track in-place engine reloads per directory instead of per 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.

* fix(app): reuse the running OpenWork server when the selected workspace 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.

* test(evals): name the server error when a run-mode read is not 200

* test(evals): create the empty-session workspace at its declared tmp path

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.
yomgui added a commit that referenced this pull request Sep 11, 2026
… route-commit wait in world open() (#4810)

* fix(app): seed the delegated-task eval with a running parent thread

The eval.task_activity.seed hook rendered an in-flight child under a parent
whose thread status stayed "ready": it only marked the activity store busy.
Since #4635 MessageList reads that as a stopped parent and the unobserved
child shows "Waiting for task result" instead of the Working shimmer, so
task-activity-shimmer and parent-child-permission-approval lost their
[data-subagent-activity="shimmer"] row. A delegating parent is mid-run;
mark the eval thread streaming like the chat-loading seed already does.

* fix(app): seed a created session's snapshot so its composer can send immediately

A freshly created session had no cached snapshot, so deriveSessionRenderModel
reported "switching" while the first snapshot round trip ran and the composer
disabled Run task. On Daytona that window is ~0.9 s and a click or Enter inside
it was silently dropped with the draft intact. Seed the snapshot cache from the
create response (stale, so the real fetch still runs as a background refresh).

* fix(app): let a send that settled with a server failure recover instead of wedging

A prompt_async answered with 5xx/408 is an uncertain admission (#4635), but
the hold it created could never end: the acceptance check treated absence as
no evidence, Stop refused while the admission was unknown, and the failure body
was dropped, so the person saw a paused composer with no explanation.

- Keep the settled response body on PromptAdmissionUnknownError and show it as
  the session error card right away; the hold still prevents any resend.
- readPromptAdmission: after the exact-message GET misses, list the idle
  conversation; when native lists it without the message the POST is settled
  and did not admit, so the drain receives admission_rejected and halts like
  any definite failure (explicit retry only, never an automatic resend).
- On release the pending row is removed and the submitted composer is kept as
  an unsent message to restore; on confirmed acceptance the stale failure card
  is cleared.

* test(evals): read an empty Lexical composer as an empty draft

Lexical keeps one empty paragraph in an empty editor, which innerText reports
as "\n". readComposerState now drops that trailing line break so draftText
matches what the person sees; user.see("composer", { text }) already trimmed.

* test(evals): open the fresh conversation through the sidebar's New session button

The sidebar button was renamed from "New task" to "New session" in #4491
(Sep 5) and the "new" scenario added in #4631 (Sep 8) still targeted the old
label, so it could never find the button. Same user action, current label.

* test(evals): create the empty-session workspace at its declared tmp path

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.

* test(evals): name the server error when a run-mode read is not 200

* fix(app): reuse the running OpenWork server when the selected workspace 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.

* test(evals): open the saved-app verification return tab as a person's new tab

returnVerification drove the agent browser entry point (browser.openUrl, the
IPC behind browser.open_url) with no requesting conversation. Since #4434 the
task host refuses that, and it never accepted an about:blank destination.
The tab only stands in for the person's own browser so the openwork:// return
link can be navigated without OS protocol registration, so create it the way a
person opens a new tab and find its CDP target by diffing the page targets.

* fix(app): re-read pending questions when a session reaches a terminal edge

An interrupted question tool leaves the engine's pending list through its
finalizer without a question.rejected event, so Stop on a delegated child
left its question (and option buttons) in the parent view. Reconcile
questions alongside permissions on terminal edges, for both engines.

* Revert "fix(app): re-read pending questions when a session reaches a terminal edge"

This reverts commit 9e70982.

* fix(app): withdraw the stopped tree's unanswered questions after Stop

OpenCode v1 runs tools on detached fibers: aborting a session marks the
question tool part as aborted but leaves its request in GET /question, so a
parent that stopped a delegated child kept showing the child's question and
its option buttons. After Stop confirms the tree idle, reject the pending
questions owned by the stopped sessions; other roots are left untouched.

* test(evals): temporary Z2 diagnostics around dashboard delete route change

* test(evals): saved-apps world.open returns once the destination page root has rendered

* test(evals): create the permission-stop-recovery workspace at its declared tmp path

Test 2 of parent-child-permission-approval ran bash without asking although the
world wrote permission.bash="ask" to the workspace opencode.json. The world
called seed.workspace() without create, so it adopted the first-launch default
workspace under the dev profile, which on Daytona lives inside the repo
checkout; the engine merges /workspace/.opencode/opencode.json
("permission": "allow") after the workspace file and the agent ruleset ends
as [* allow, bash ask, * allow] (last match wins; permissions/effective reported
shell allow, source engine, workspace file .../home/OpenWork Chat/opencode.jsonc).

Same trap and same remedy as #4747 for emptySession; opt-in so the other
splitPaneQuestions worlds keep their arrangement.

* fix(app): withdraw the stopped tree's unanswered permission requests after Stop

OpenCode v1 runs tools on detached fibers: aborting a session marks the tool
part as aborted but leaves its Permission.ask pending in /permission, exactly
as #4786 found for questions. The stopped tree would keep showing Allow once /
Deny in every pane and after reload although nothing can consume the answer.

After stopForegroundTree confirms every stopped session idle, also list pending
permissions and reject the ones owned by the stopped tree; other roots are
never touched and each withdrawal kind is best-effort on its own.

* test(evals): remove temporary Z2 diagnostics from saved-app-creation

* test(evals): make locate() misses list every candidate of the requested role plus route and page roots

A miss used to quote only the first 8 visible buttons in DOM order, which
are always the shell rail, so every miss read as "the page has no
buttons" (#4794's diagnosis detour). The browser-side report now lists
every rendered element of the requested role (buttons/links for
role-less targets), the current route/hash, and whether the
[data-app-header] / [data-dashboard-page] roots are mounted. The Node
side caps the list at 40 and says how many the page really had.
Matching is unchanged.

* test(evals): run the serialized locate() miss callback against a fake page DOM

Proves the browser-side branch the way Chromium will execute it: the
report lists every rendered menuitem on a dashboard whose shell rail has
nine buttons, names the route and mounted page roots, and a role-less
miss lists all nine buttons instead of the first eight.

This branch was successfully deployed

1 active and 3 inactive deployments
Preview – openwork-app — 561b5c03 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-landing — 561b5c03 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-den — 561b5c03 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-diagnostics — 561b5c03 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