fix(app): gate Run Task only when Den is required
Safety contract — read this first
This PR must not gate Run Task for the general user population.
The fail-closed readiness gate is entered only when both conditions are true:
- the action starts an agent prompt (not direct shell execution), and
- the desktop bootstrap explicitly has
requireSignin: true.
A user merely being signed in to Den is not enough. Users may be signed in for Cloud models or organization metadata without requiring Den-backed Connect skills. Keying this gate off denAuth.isSignedIn, a saved token, or general Cloud availability would recreate the historical global-lockout risk.
Behavior matrix
| Context | Gate behavior | If Den/tool readiness fails |
|---|---|---|
Optional install (requireSignin: false), signed out |
Bypass | Agent prompt sends normally |
Optional install (requireSignin: false), signed in |
Bypass | Agent prompt sends normally |
Den-required install (requireSignin: true), agent prompt |
Required | No run is recorded or sent; draft is preserved with Retry/Open Connect |
| Den-required install while saved auth is restoring | Required | Exact submission waits; repeated clicks deduplicate |
| Direct shell execution | Bypass | Shell command is not coupled to Den agent context |
| Cloud MCP explicitly disabled or removed | Existing bypass remains | Agent prompt is not held by this readiness gate |
The empty-state flow may create and navigate to a blank session before readiness finishes. The important boundary is that the agent turn, analytics run start, and prompt submission do not happen until a required gate succeeds.
Why this caution is necessary
The pre-send readiness coordinator performs strict checks: it restores saved Den auth, verifies or repairs openwork-cloud, checks the direct MCP tools, and requires proof that the selected model received the projected capability tools.
That strict projection check can fail on an otherwise usable engine when the engine reports only generic provider tool capability instead of experimental_tool projection evidence. A previous global version of this gate blocked every message and was subsequently bypassed in #2790. This PR therefore does not simply remove skipGate: true; it adds an explicit policy boundary before restoring the gate.
Do not broaden this condition from requireSignin to “signed in,” “has a token,” or “Connect is available” without a separately reviewed rollout and end-to-end proof.
What changed
- replace the optional
skipGateinput with a requiredgatePolicyso every sender must state its intent - derive that policy from prompt mode plus the synchronous bootstrap
requireSigninrequirement - retain the existing Den auth wait, Cloud MCP repair, tool verification, deduplication, failure UI, and draft preservation behavior for the required cohort
- add focused regression coverage for both sides of the boundary
Intentional tradeoff / non-goal
Optional installations are deliberately fail-open here, including optional users who happen to be signed in to Den. This avoids another population-wide lockout, but it also means this PR does not guarantee pre-send Den skill readiness for optional installs. Expanding that cohort needs a distinct, measurable requirement signal and live rollout validation.
For Den-required installations, failure remains intentionally fail-closed: if Den is unavailable or the engine cannot prove tool injection, Run Task stays blocked. A misconfigured installation with requireSignin: true can therefore block its own users, but cannot block optional installations.
Focused check
Passed:
./bin/openwork-hub run mcp den-run-task-readiness -- pnpm --filter @openwork/app exec bun test --isolate tests/cloud-mcp-submit-readiness.test.ts
10 pass, 0 fail
The focused file covers:
- optional prompt bypass
- Den-required prompt gating
- shell bypass
- cached-auth waiting and exactly-once send
- auth timeout creating no run
- permanent injection failure preserving the draft
- signed-out, tokenless optional startup, disabled, and removed bypasses
- workspace/model context changes cancelling stale queued submissions
Not yet verified
- live desktop startup timing
- end-to-end Den outage and recovery
- a real Den-required distribution
- broader app suite
The PR remains draft until the Den-required and optional-install journeys are exercised manually.
@reachjalil is attempting to deploy a commit to the Different AI Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated (UTC) |
|---|---|---|---|
| openwork-landing | Preview, Comment, Open in v0 | Jul 29, 2026 2:28pm |