Skip to content

Commit f71a50a

Browse files
committed
feat: OpenShell fleet - spawn, delegate, drain-then-delete workers
1 parent 28bcb73 commit f71a50a

116 files changed

Lines changed: 13043 additions & 146 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: OpenShell gateway smoke
2+
3+
# Opt-in live check of the OpenShell fleet integration against a REAL gateway.
4+
# The job runs only when a repository administrator configures gateway access;
5+
# otherwise every step skips and pull requests stay green.
6+
#
7+
# How to enable (repository secrets, set once by an administrator):
8+
# OPENSHELL_SMOKE_GATEWAY_URL the gateway control-plane base URL (https)
9+
# OPENSHELL_SMOKE_GATEWAY_CREDENTIAL the bearer credential the gateway's OIDC
10+
# token provider returns to the OpenShell SDK
11+
# Optional repository variable:
12+
# OPENSHELL_SMOKE_TEMPLATE sandbox template to spawn; unset falls
13+
# back to a worker-labeled template listed
14+
# by the gateway.
15+
# What the gateway must expose: health, sandbox template listing, sandbox
16+
# create/wait/get/delete, and label filtering on `t3-managed-by`.
17+
# Budget: the script defaults to 900 seconds (OPENSHELL_SMOKE_TIMEOUT_SECS).
18+
19+
on:
20+
workflow_dispatch:
21+
schedule:
22+
# Avoid minute zero, when GitHub scheduled jobs are busiest.
23+
- cron: "17 4 * * 1"
24+
pull_request:
25+
paths:
26+
- "packages/openshell/**"
27+
- "apps/server/src/environment/**"
28+
- "scripts/openshell-smoke.ts"
29+
- ".github/workflows/openshell-smoke.yml"
30+
31+
permissions:
32+
contents: read
33+
34+
concurrency:
35+
group: openshell-smoke-${{ github.event.pull_request.number || github.sha }}
36+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
37+
38+
jobs:
39+
smoke:
40+
name: Gateway smoke
41+
runs-on: ubuntu-24.04
42+
timeout-minutes: 25
43+
steps:
44+
# Same presence pattern as the EXPO_TOKEN check in mobile-eas-production.yml.
45+
- id: smoke-secrets
46+
name: Check for gateway secrets
47+
env:
48+
SMOKE_URL: ${{ secrets.OPENSHELL_SMOKE_GATEWAY_URL }}
49+
SMOKE_CREDENTIAL: ${{ secrets.OPENSHELL_SMOKE_GATEWAY_CREDENTIAL }}
50+
run: |
51+
if [ -n "$SMOKE_URL" ] && [ -n "$SMOKE_CREDENTIAL" ]; then
52+
echo "present=true" >> "$GITHUB_OUTPUT"
53+
else
54+
echo "present=false" >> "$GITHUB_OUTPUT"
55+
echo "OPENSHELL_SMOKE_GATEWAY_URL and OPENSHELL_SMOKE_GATEWAY_CREDENTIAL are not configured; skipping the live gateway smoke."
56+
fi
57+
58+
- name: Checkout
59+
if: steps.smoke-secrets.outputs.present == 'true'
60+
uses: actions/checkout@v6
61+
62+
- name: Setup Vite+
63+
if: steps.smoke-secrets.outputs.present == 'true'
64+
uses: ./.github/actions/setup-ci-deps
65+
with:
66+
task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
67+
68+
- name: Run the gateway smoke
69+
if: steps.smoke-secrets.outputs.present == 'true'
70+
env:
71+
OPENSHELL_SMOKE_GATEWAY_URL: ${{ secrets.OPENSHELL_SMOKE_GATEWAY_URL }}
72+
OPENSHELL_SMOKE_GATEWAY_CREDENTIAL: ${{ secrets.OPENSHELL_SMOKE_GATEWAY_CREDENTIAL }}
73+
OPENSHELL_SMOKE_TEMPLATE: ${{ vars.OPENSHELL_SMOKE_TEMPLATE }}
74+
run: node scripts/openshell-smoke.ts

‎apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx‎

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-en
8080
import {
8181
changeDraftProject,
8282
editDraft,
83+
leavesSandboxWorkspace,
8384
parseIntervalMinutes,
8485
scheduledTaskDefaultModel,
8586
scheduleFromDraft,
@@ -891,11 +892,13 @@ function TaskForm({
891892
? { type: "root" }
892893
: draft.workspace === "existing_worktree"
893894
? { type: "existing_worktree", worktreePath: draft.checkoutPath.trim() }
894-
: {
895-
type: "worktree",
896-
baseRef: worktreeBaseRef,
897-
startFromOrigin: draft.startFromOrigin,
898-
},
895+
: draft.workspace === "sandbox"
896+
? { type: "sandbox" }
897+
: {
898+
type: "worktree",
899+
baseRef: worktreeBaseRef,
900+
startFromOrigin: draft.startFromOrigin,
901+
},
899902
// Tasks have no mode picker; a mode above the administrator's ceiling is refused.
900903
runtimeMode:
901904
clampManagedRuntimeMode(config?.managedPolicy, draft.runtimeMode) ?? draft.runtimeMode,
@@ -1091,9 +1094,20 @@ function TaskForm({
10911094
? gt("New worktree")
10921095
: draft.workspace === "root"
10931096
? gt("Project checkout")
1094-
: gt("Specific checkout")
1097+
: draft.workspace === "sandbox"
1098+
? gt("Fleet worker sandbox")
1099+
: gt("Specific checkout")
10951100
}
10961101
actions={[
1102+
...(draft.storedSandbox
1103+
? [
1104+
{
1105+
id: "sandbox",
1106+
title: gt("Fleet worker sandbox"),
1107+
state: draft.workspace === "sandbox" ? ("on" as const) : undefined,
1108+
},
1109+
]
1110+
: []),
10971111
{
10981112
id: "worktree",
10991113
title: gt("New worktree"),
@@ -1111,10 +1125,22 @@ function TaskForm({
11111125
},
11121126
]}
11131127
onSelect={(id) => {
1114-
if (id === "worktree" || id === "root" || id === "existing_worktree")
1128+
if (
1129+
id === "worktree" ||
1130+
id === "root" ||
1131+
id === "existing_worktree" ||
1132+
id === "sandbox"
1133+
)
11151134
setDraft((current) => ({ ...current, workspace: id }));
11161135
}}
11171136
/>
1137+
{leavesSandboxWorkspace(draft) ? (
1138+
<Text className="px-4 pb-3 text-sm text-warning-foreground">
1139+
<T>
1140+
Future runs will no longer use the fleet worker sandbox this task is paired with.
1141+
</T>
1142+
</Text>
1143+
) : null}
11181144
{draft.workspace === "worktree" ? (
11191145
<PickerRow
11201146
label={gt("Base branch")}

‎apps/mobile/src/features/settings/scheduledTaskDraft.test.ts‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { describe, expect, it } from "vite-plus/test";
22
import {
33
DEFAULT_SERVER_SETTINGS,
4+
type ScheduledTask,
45
type ServerConfig,
56
ProviderDriverKind,
67
ProviderInstanceId,
78
ProjectId,
89
ScheduledTaskId,
9-
type ScheduledTask,
1010
} from "@t3tools/contracts";
1111
import {
1212
createDraft,
1313
editDraft,
14+
hasScheduledTaskDraftChanges,
15+
leavesSandboxWorkspace,
1416
scheduledTaskDefaultModel,
1517
DEFAULT_SCHEDULE,
1618
scheduleDraftForTask,
@@ -245,3 +247,52 @@ describe("scheduled task worktree base", () => {
245247
).toBe("release");
246248
});
247249
});
250+
251+
describe("sandbox workspace retention", () => {
252+
const task = (workspaceStrategy: ScheduledTask["workspaceStrategy"]): ScheduledTask => ({
253+
id: ScheduledTaskId.make("task"),
254+
title: "Nightly review",
255+
prompt: "Review open issues",
256+
enabled: true,
257+
schedule: { type: "interval", everyMs: 60_000 },
258+
projectId: ProjectId.make("project"),
259+
threadId: null,
260+
workspaceStrategy,
261+
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
262+
runtimeMode: "full-access",
263+
interactionMode: "default",
264+
createdBy: "user",
265+
creationSource: "mobile",
266+
createdAt: "2026-09-17T00:00:00.000Z",
267+
updatedAt: "2026-09-17T00:00:00.000Z",
268+
nextRunAt: null,
269+
lastRunAt: null,
270+
lastRunStatus: "never",
271+
lastRunError: null,
272+
runCount: 0,
273+
});
274+
275+
it("keeps a stored sandbox strategy when editing an unrelated field", () => {
276+
const initial = editDraft(task({ type: "sandbox" }));
277+
expect(initial.workspace).toBe("sandbox");
278+
expect(initial.storedSandbox).toBe(true);
279+
expect(leavesSandboxWorkspace(initial)).toBe(false);
280+
// Renaming the task does not move it off its fleet worker.
281+
const renamed = { ...initial, title: "Renamed" };
282+
expect(hasScheduledTaskDraftChanges(initial, renamed)).toBe(true);
283+
expect(leavesSandboxWorkspace(renamed)).toBe(false);
284+
});
285+
286+
it("surfaces a warning only when the workspace control leaves the sandbox", () => {
287+
const initial = editDraft(task({ type: "sandbox" }));
288+
const moved = { ...initial, workspace: "worktree" as const };
289+
expect(leavesSandboxWorkspace(moved)).toBe(true);
290+
expect(hasScheduledTaskDraftChanges(initial, moved)).toBe(true);
291+
// A task that never ran in a sandbox is never flagged.
292+
const worktreeDraft = editDraft(
293+
task({ type: "worktree", baseRef: "release", startFromOrigin: false }),
294+
);
295+
expect(worktreeDraft.storedSandbox).toBe(false);
296+
expect(leavesSandboxWorkspace({ ...worktreeDraft, workspace: "root" as const })).toBe(false);
297+
});
298+
});

‎apps/mobile/src/features/settings/scheduledTaskDraft.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export function scheduleFromDraft(draft: ScheduleDraft): ScheduledTaskUpsertSche
197197
};
198198
}
199199

200-
type Workspace = "worktree" | "root" | "existing_worktree";
200+
type Workspace = "worktree" | "root" | "existing_worktree" | "sandbox";
201201
export type ScheduledTaskDraft = {
202202
readonly task: ScheduledTask | null;
203203
readonly title: string;
@@ -209,6 +209,8 @@ export type ScheduledTaskDraft = {
209209
readonly schedule: ScheduleDraft;
210210
readonly threadMode: ScheduledTaskThreadMode;
211211
readonly workspace: Workspace;
212+
/** The stored task runs in a fleet worker sandbox; leaving it is surfaced. */
213+
readonly storedSandbox: boolean;
212214
readonly baseRef: string;
213215
readonly checkoutPath: string;
214216
readonly enabled: boolean;
@@ -301,6 +303,7 @@ export function createDraft(
301303
schedule: DEFAULT_SCHEDULE,
302304
threadMode: "new_thread",
303305
workspace: "worktree",
306+
storedSandbox: false,
304307
baseRef: "",
305308
checkoutPath: "",
306309
enabled: true,
@@ -309,6 +312,11 @@ export function createDraft(
309312
};
310313
}
311314

315+
/** An edit that moves a stored sandbox task off its fleet worker; the editor surfaces it. */
316+
export function leavesSandboxWorkspace(draft: ScheduledTaskDraft): boolean {
317+
return draft.storedSandbox && draft.workspace !== "sandbox";
318+
}
319+
312320
export function editDraft(task: ScheduledTask): ScheduledTaskDraft {
313321
return {
314322
task,
@@ -320,7 +328,11 @@ export function editDraft(task: ScheduledTask): ScheduledTaskDraft {
320328
modelSelectionIsExplicit: true,
321329
schedule: scheduleDraftForTask(task),
322330
threadMode: scheduledTaskThreadMode(task),
331+
// A sandbox workspace stays: editing an unrelated field must not silently
332+
// move the task off its fleet worker.
323333
workspace: task.workspaceStrategy.type,
334+
storedSandbox: task.workspaceStrategy.type === "sandbox",
335+
// Main's newer editor keeps the base automatic unless a worktree pinned one.
324336
baseRef: task.workspaceStrategy.type === "worktree" ? task.workspaceStrategy.baseRef : "",
325337
checkoutPath:
326338
task.workspaceStrategy.type === "existing_worktree"

‎apps/mobile/src/i18n/translations/de.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,6 +3595,7 @@
35953595
"85728e592594c929": "Ausführen in",
35963596
"c7fe4313def0ef2f": "Neuer Worktree",
35973597
"e91a39ca1b5d9bbd": "Projekt-Checkout",
3598+
"c1b7be381b2a2df1": "Fleet worker sandbox",
35983599
"27a6259d0e7c054e": "Bestimmter Checkout",
35993600
"8b724804e55e48e6": "Checkout-Pfad",
36003601
"b325f97ceab8bc64": "Zeitplan",
@@ -3653,6 +3654,7 @@
36533654
"3c5185df378edef9": "Wird nur ausgeführt, wenn alle Filter zutreffen. Andere Anfragen werden als gefiltert protokolliert. Trenne „ist eines von“-Werte mit Kommas; ein Wert darf kein Komma enthalten.",
36543655
"d1a74724f70edb0b": "Diese Aufgabe existiert nicht mehr.",
36553656
"c191069dded46bcc": "Diese Umgebung ist getrennt. Verbinde sie erneut, bevor du speicherst.",
3657+
"46cea643e5ae4196": "Future runs will no longer use the fleet worker sandbox this task is paired with.",
36563658
"0d15db4c81851479": "Anfragen mit demselben Schlüssel werden innerhalb von 7 Tagen nur einmal ausgeführt.",
36573659
"a5bbe09b0c89d86c": "Beim Zusammenfassen wird die neueste Payload ausgeführt, wenn das Zeitfenster ab der ersten Zustellung endet. Leere Schlüssel werden normal ausgeführt.",
36583660
"0e2233fb297f7c07": "Intervalle müssen mindestens 1 Minute betragen. Passe dieses Intervall vor dem Speichern an.",

‎apps/mobile/src/i18n/translations/en.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,6 +3597,7 @@
35973597
"85728e592594c929": "Run in",
35983598
"c7fe4313def0ef2f": "New worktree",
35993599
"e91a39ca1b5d9bbd": "Project checkout",
3600+
"c1b7be381b2a2df1": "Fleet worker sandbox",
36003601
"27a6259d0e7c054e": "Specific checkout",
36013602
"8b724804e55e48e6": "Checkout path",
36023603
"b325f97ceab8bc64": "Schedule",
@@ -3655,6 +3656,7 @@
36553656
"3c5185df378edef9": "Runs only when every filter matches. Other requests are logged as filtered. Separate “is one of” values with commas; a value can't contain a comma.",
36563657
"d1a74724f70edb0b": "This task no longer exists.",
36573658
"c191069dded46bcc": "This environment is disconnected. Reconnect before saving.",
3659+
"46cea643e5ae4196": "Future runs will no longer use the fleet worker sandbox this task is paired with.",
36583660
"0d15db4c81851479": "Requests with the same key run only once within 7 days.",
36593661
"a5bbe09b0c89d86c": "Coalescing runs the latest payload when the window from the first delivery closes. Empty keys run normally.",
36603662
"0e2233fb297f7c07": "Intervals must be at least 1 minute. Update this interval before saving.",

‎apps/mobile/src/i18n/translations/es.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,6 +3590,7 @@
35903590
"85728e592594c929": "Ejecutar en",
35913591
"c7fe4313def0ef2f": "Nuevo worktree",
35923592
"e91a39ca1b5d9bbd": "Checkout del proyecto",
3593+
"c1b7be381b2a2df1": "Fleet worker sandbox",
35933594
"27a6259d0e7c054e": "Checkout concreto",
35943595
"8b724804e55e48e6": "Ruta del checkout",
35953596
"b325f97ceab8bc64": "Programación",
@@ -3648,6 +3649,7 @@
36483649
"3c5185df378edef9": "Se ejecuta solo cuando coinciden todos los filtros. Las demás solicitudes se registran como filtradas. Separa los valores de «es uno de» con comas; un valor no puede contener una coma.",
36493650
"d1a74724f70edb0b": "Esta tarea ya no existe.",
36503651
"c191069dded46bcc": "Este entorno está desconectado. Vuelve a conectarlo antes de guardar.",
3652+
"46cea643e5ae4196": "Future runs will no longer use the fleet worker sandbox this task is paired with.",
36513653
"0d15db4c81851479": "Las solicitudes con la misma clave solo se ejecutan una vez en 7 días.",
36523654
"a5bbe09b0c89d86c": "La agrupación ejecuta la carga más reciente cuando se cierra la ventana abierta por la primera entrega. Las claves vacías se ejecutan con normalidad.",
36533655
"0e2233fb297f7c07": "Los intervalos deben ser de al menos 1 minuto. Actualiza este intervalo antes de guardar.",

‎apps/mobile/src/i18n/translations/fr.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,6 +3590,7 @@
35903590
"85728e592594c929": "Exécuter dans",
35913591
"c7fe4313def0ef2f": "Nouveau worktree",
35923592
"e91a39ca1b5d9bbd": "Checkout du projet",
3593+
"c1b7be381b2a2df1": "Fleet worker sandbox",
35933594
"27a6259d0e7c054e": "Checkout précis",
35943595
"8b724804e55e48e6": "Chemin du checkout",
35953596
"b325f97ceab8bc64": "Planification",
@@ -3648,6 +3649,7 @@
36483649
"3c5185df378edef9": "S’exécute uniquement si tous les filtres correspondent. Les autres requêtes sont journalisées comme filtrées. Séparez les valeurs « fait partie de » par des virgules ; une valeur ne peut pas contenir de virgule.",
36493650
"d1a74724f70edb0b": "Cette tâche n’existe plus.",
36503651
"c191069dded46bcc": "Cet environnement est déconnecté. Reconnectez-le avant d’enregistrer.",
3652+
"46cea643e5ae4196": "Future runs will no longer use the fleet worker sandbox this task is paired with.",
36513653
"0d15db4c81851479": "Les requêtes avec la même clé ne s’exécutent qu’une fois en 7 jours.",
36523654
"a5bbe09b0c89d86c": "Le regroupement exécute la dernière charge utile quand la fenêtre ouverte par la première livraison se ferme. Les clés vides s’exécutent normalement.",
36533655
"0e2233fb297f7c07": "Les intervalles doivent être d’au moins 1 minute. Modifiez cet intervalle avant d’enregistrer.",

‎apps/mobile/src/i18n/translations/ja.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,7 @@
35863586
"85728e592594c929": "実行場所",
35873587
"c7fe4313def0ef2f": "新しいワークツリー",
35883588
"e91a39ca1b5d9bbd": "プロジェクトのチェックアウト",
3589+
"c1b7be381b2a2df1": "Fleet worker sandbox",
35893590
"27a6259d0e7c054e": "特定のチェックアウト",
35903591
"8b724804e55e48e6": "チェックアウトのパス",
35913592
"b325f97ceab8bc64": "スケジュール",
@@ -3644,6 +3645,7 @@
36443645
"3c5185df378edef9": "すべてのフィルターに一致した場合のみ実行します。それ以外のリクエストはフィルター済みとして記録されます。「いずれかに一致」の値はカンマで区切ってください。値にカンマを含めることはできません。",
36453646
"d1a74724f70edb0b": "このタスクは存在しません。",
36463647
"c191069dded46bcc": "この環境は切断されています。保存する前に再接続してください。",
3648+
"46cea643e5ae4196": "Future runs will no longer use the fleet worker sandbox this task is paired with.",
36473649
"0d15db4c81851479": "同じキーのリクエストは 7 日以内に 1 回だけ実行されます。",
36483650
"a5bbe09b0c89d86c": "集約すると、最初の配信からの期間が終了したときに最新のペイロードで実行します。キーが空の場合は通常どおり実行します。",
36493651
"0e2233fb297f7c07": "間隔は 1 分以上にする必要があります。保存する前にこの間隔を更新してください。",

‎apps/mobile/src/i18n/translations/ko.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,6 +3590,7 @@
35903590
"85728e592594c929": "실행 위치",
35913591
"c7fe4313def0ef2f": "새 워크트리",
35923592
"e91a39ca1b5d9bbd": "프로젝트 체크아웃",
3593+
"c1b7be381b2a2df1": "Fleet worker sandbox",
35933594
"27a6259d0e7c054e": "특정 체크아웃",
35943595
"8b724804e55e48e6": "체크아웃 경로",
35953596
"b325f97ceab8bc64": "일정",
@@ -3648,6 +3649,7 @@
36483649
"3c5185df378edef9": "모든 필터가 일치할 때만 실행합니다. 다른 요청은 필터링됨으로 기록됩니다. “다음 중 하나” 값은 쉼표로 구분하며, 값에는 쉼표를 넣을 수 없습니다.",
36493650
"d1a74724f70edb0b": "이 작업은 더 이상 존재하지 않습니다.",
36503651
"c191069dded46bcc": "이 환경의 연결이 끊어졌습니다. 저장하기 전에 다시 연결하세요.",
3652+
"46cea643e5ae4196": "Future runs will no longer use the fleet worker sandbox this task is paired with.",
36513653
"0d15db4c81851479": "키가 같은 요청은 7일 이내에 한 번만 실행됩니다.",
36523654
"a5bbe09b0c89d86c": "병합하면 첫 전송부터 시작된 기간이 끝날 때 최신 페이로드로 실행합니다. 키가 비어 있으면 정상적으로 실행됩니다.",
36533655
"0e2233fb297f7c07": "간격은 1분 이상이어야 합니다. 저장하기 전에 간격을 업데이트하세요.",

0 commit comments

Comments
 (0)