Skip to content

test(evals)+fix(app): align desktop-policy-restricted-mode with the simplified Library add flow - #4741

Merged
yomgui merged 3 commits into
devfrom
e2e/library-restricted-mode-drift
Sep 11, 2026
Merged

yomgui merged 3 commits into
devfrom
e2e/library-restricted-mode-drift

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Root cause

Triage Cluster 6 / Brief G in reports/e2e-red-2026-09-09/triage.md ("Library add options changed; restricted-mode spec drifted") reported desktop-policy-restricted-mode red at lines 93 (Add under the MCPs filter) and 552 (text=Organization MCP) after #4645 simplified the Library add flow.

That red was a runner/ref mismatch, not a spec drift on dev: the "dev baseline" run executed the spec file from the runner's worktree (feat/api-quality-spectral @ ea1e9546e, which merged dev at 10:21 -0400) against a sandbox built from dev @ 61b41901c. dev had already re-expressed the spec in 05b9fe2b3 (#4664, 08:47 -0700, commit "test(policy): align Library checks with current add controls"): Add workspace MCP single-kind button under the MCPs filter, Local MCP absent from the picker and Connection retained under restriction, no Organization MCP. Line 93/552 with those texts only exist in the spec before #4664. No Library claim needed re-expressing; the product (libraryAddKindsForFilter, LibraryAddControl) matches the spec.

Running the spec pinned to origin/dev @ c744e2d7b (runs 1–2, OPENWORK_EVAL_REF set, sandbox source verified c744e2d7b…) showed the Library claims pass and exposed three other failures that block this spec on dev:

  1. press("Escape") → immediate notSee(...) on the Library add picker (library-add-choices, spec lines 310/839) and the Add workspace MCP modal (App name textbox, line 102): the plain Dialog keeps its 100 ms data-closed:animate-out fade-out-0 exit motion, so the popup is still visible on assertAbsent's first inspection. Same class as Cluster 7 / fix(app): close the restart prompt and command palette synchronously on dismiss #4724, which fixed alert-dialog.tsx and command.tsx and explicitly left dialog.tsx out of scope (its "Noticed, not touched" Add engine doctor + guided OpenCode install #3). 3 of 4 dismissals lost the race across two runs.
  2. POST /workspace/:id/opencode-config by the restricted member returned 409 policy_identity_changed instead of the policy's 403 (line 1082, a policy-enforcement assertion). Since fix(desktop): recover credentials before engine readiness #4718 (1c455cfab, merged after fix(server): retry transient managed policy verification failures #4664's green proof) the desktop pushes the same Den session twice per launch/reload/resume (PUT /den-session/identity then PUT /den-session); every push bumped ManagedDesktopPolicy.generation, so any enforcement check in flight failed with 409 although the account never changed.
  3. press("Escape") → immediate notSee(menuitem Account) on the account dropdown (line 276). The menu already has animate-none!; its unmount is still a React commit away from the CDP key event and the first inspection landed 33 ms later.

What changed

  • apps/app/src/components/ui/dialog.tsx — dismissal hides the overlay and popup in the same frame (data-closed:hidden, exit motion removed, entrance motion unchanged), mirroring fix(app): close the restart prompt and command palette synchronously on dismiss #4724.
  • apps/server/src/managed-desktop-policy.ts — setSession bumps the generation only when baseUrl, token, or orgId actually differ, so re-delivering the same identity no longer invalidates in-flight policy checks. Unit witness added to managed-desktop-policy.test.ts (fails without the fix: 1 fail; passes with it: 8 pass).
  • evals/specs/desktop-policy-restricted-mode.e2e.test.ts — after Escape on the account menu, observe the popup leaving the DOM (probe.eventually, bounded) before the unchanged strict notSee(..., { timeoutMs: 10_000 }), following command-palette-search.e2e.test.ts:103-109. No policy-enforcement assertion was loosened; no sleeps added.

Proof

pnpm evals:e2e desktop-policy-restricted-mode --daytona with OPENWORK_EVAL_REF=3b896f5a8750c4101d4a4dbca8de4c5773616203 (sandbox log: HEAD is now at 3b896f5a, source verified 3b896f5a8…):

✓ an admin restricts the default policy and the member desktop enforces it  442151ms
✓ managed policy evaluation bounds transient Den retries and never reuses stale access  171868ms
✓ team access overrides overlapping grants and restores only selected desktop capabilities  562986ms
Test Files  1 passed (1) · Tests  3 passed (3)
{"command":"evals:e2e","lane":"e2e","daytona":true,"placement":"daytona","engine":"legacy","surface":"legacy","case":null,"vision":"defer","files":["desktop-policy-restricted-mode"],"passed":3,"failed":0,"skipped":0,"skips":[],"consented":["OPENWORK_EVAL_E2E_TESTS"],"verdict":"passed"}

Steps 10/10, 7/7, 8/8; expectations 9 + 7 + 43 passed, 0 failed. Library witnesses observed: "Before the policy change the member can open the local workspace MCP add form", "The Library removes local MCP creation while retaining Connection as a separate picker choice" (×3), "Direct config and extension requests cannot bypass the restricted member's UI" (403/403/200). Vision judgments deferred (default vision: defer). All 8 sandboxes deleted by the testkit.

Earlier runs on this branch, same command: c744e2d7b (dev) → 2 passed / 1 failed (line 839 race), then 1 passed / 2 failed (lines 102, 839); 3086f1315 (dialog fix only) → 1 passed / 2 failed (line 276 menu race; line 1082 409 ≠ 403).

Also: pnpm --filter openwork-server test src/managed-desktop-policy.test.ts 8 pass; pnpm --dir apps/app typecheck and pnpm --filter openwork-server typecheck exit 0.

This branch is based on c744e2d7b and merges cleanly onto current dev (which added a 4th rollback journey to this spec in #4725, not exercised here).

Noticed, not touched

  1. Runner/ref mismatch is silent. The Daytona lane builds OPENWORK_EVAL_REF in the sandbox but runs the spec files from the local checkout; nothing warns when the two differ, and test-run.json records the runner worktree's gitSha (this run: c744e2d7b correctly only because the worktree matched). A warning when OPENWORK_EVAL_REF ≠ local HEAD (and recording the ref) would have made Brief G a non-issue.
  2. assertAbsent throwing on the first inspection makes every press → notSee on any popup a race with one React commit, even without exit motion (item 3 above). fix(app): close the restart prompt and command palette synchronously on dismiss #4724 and this PR narrow the window component by component; a harness semantic of "becomes absent within a bound, then stays absent" would remove the class.
  3. press("Escape") followed directly by click("Library") at spec line 821 (team journey) has the same latent race but is not asserted; it passed in all 4 runs.
  4. The GitHub daytona-e2e.yml nightly at c744e2d7b failed in the Product journeys job before running any journey, so there is no nightly evidence for this spec on current dev.

Base UI keeps a closing Dialog mounted until its exit animation ends, so the
Library add picker and the Add workspace MCP modal stayed visible for the
100 ms fade-out after Escape. Hide the overlay and popup with data-closed:hidden
(entrance motion unchanged), matching the AlertDialog and command palette fix.
…e-delivered

Since #4718 the desktop pushes its Den session twice per launch or reload
(identity, then sync). Each PUT bumped the managed-policy generation, so any
enforcement check in flight failed with 409 policy_identity_changed even though
the account never changed; the restricted member's opencode-config write came
back 409 instead of the policy's 403. Bump the generation only when the
baseUrl, token, or orgId actually differ.
…sence

The dropdown menu has no exit motion, yet its unmount is still a React commit
away from the Escape key event; on Daytona the first notSee inspection landed
33 ms later while the menu was still mounted. Follow command-palette-search:
wait for the menu popup to leave the DOM, then hold the strict absence window.
@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-den Ready Ready Preview Sep 10, 2026 3:19am UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 3:19am UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 3:19am UTC
1 Skipped Deployment
Project Deployment Actions Updated
openwork-app Ignored Ignored Sep 10, 2026 3:19am 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 (24660 ms), confidentiality-review (26153 ms), spec-provenance-review (32345 ms), desktop-den-sync-review (22348 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 (3b896f5a8750c4101d4a4dbca8de4c5773616203). 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 3b896f5a8750c4101d4a4dbca8de4c5773616203 · selected evidence

Open review report

This branch was successfully deployed

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