"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(desktop): validate packaged Windows lifecycle
QCYTSN32d312566c10
diff --git a/.github/workflows/desktop-windows.yml b/.github/workflows/desktop-windows.ymlindex 5f6cb00f4..d852324e0 100644--- a/.github/workflows/desktop-windows.yml+++ b/.github/workflows/desktop-windows.yml@@ -15,7 +15,7 @@ permissions:jobs:package:- runs-on: windows-latest+ runs-on: windows-2025timeout-minutes: 90steps:@@ -28,7 +28,7 @@ jobs:- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0with:- node-version: "24"+ node-version: "22"cache: npmcache-dependency-path: |frontend/package-lock.json@@ -63,6 +63,15 @@ jobs:CSC_IDENTITY_AUTO_DISCOVERY: "false"run: npm run installer:win:review+ - name: Verify packaged startup and parent-death cleanup+ working-directory: desktop/electron+ shell: powershell+ run: |+ $env:VIBE_TRADING_DESKTOP_ELECTRON_EXECUTABLE = (+ Resolve-Path 'release\win-unpacked\Vibe-Trading Desktop (Unofficial Community Build).exe'+ ).Path+ node scripts/smoke-parent-death.mjs+- name: Verify installer and record checksumworking-directory: desktop/electronshell: powershelldiff --git a/agent/src/api/settings_routes.py b/agent/src/api/settings_routes.pyindex 53e4d2a75..4ea385cd1 100644--- a/agent/src/api/settings_routes.py+++ b/agent/src/api/settings_routes.py@@ -326,6 +326,8 @@ async def _list_provider_models(models=models or fallback,source="provider" if discovered else "default",)++# ---------------------------------------------------------------------------# Response builders# ---------------------------------------------------------------------------diff --git a/agent/tests/test_settings_api.py b/agent/tests/test_settings_api.pyindex c9d4ee8ff..7ae9f0889 100644--- a/agent/tests/test_settings_api.py+++ b/agent/tests/test_settings_api.py@@ -256,6 +256,7 @@ def test_update_deepseek_settings_uses_exact_reported_payload(assert "DEEPSEEK_API_KEY=sk-deepseek-test" in env_textassert "DEEPSEEK_BASE_URL=https://api.deepseek.com/v1" in env_text+def test_desktop_secure_mode_never_persists_injected_llm_key(client: TestClient,tmp_path: Path,@@ -279,6 +280,7 @@ def test_desktop_secure_mode_never_persists_injected_llm_key(assert "dpapi-decrypted-key" not in env_textassert "DEEPSEEK_API_KEY=" in env_text+@pytest.mark.parametrize(("provider", "api_key_env", "base_url_env", "base_url"),[diff --git a/desktop/electron/THREAT_MODEL.md b/desktop/electron/THREAT_MODEL.mdindex 419872232..dca6d0cde 100644--- a/desktop/electron/THREAT_MODEL.md+++ b/desktop/electron/THREAT_MODEL.md@@ -155,8 +155,9 @@ therefore security-significant.credentials required by the backend.- Forceful tree termination can interrupt in-progress local work after thegraceful shutdown timeout.-- This source-only change does not provide a signing identity, installer- reputation, update authenticity, or an official HKUDS release channel.+- The review installer is deliberately unsigned and unpublished. This change+ does not provide a signing identity, installer reputation, update+ authenticity, or an official HKUDS release channel.## Non-goalsdiff --git a/desktop/electron/WINDOWS_PACKAGING.md b/desktop/electron/WINDOWS_PACKAGING.mdindex 05e38f6f8..1998934fe 100644--- a/desktop/electron/WINDOWS_PACKAGING.md+++ b/desktop/electron/WINDOWS_PACKAGING.md@@ -108,7 +108,8 @@ be re-audited whenever Electron Builder publishes a repaired dependency tree.## Local validation record-Windows host validation on 2026-07-31:+Windows host validation on 2026-08-08 against the current upstream+`vibe-trading-ai` 0.1.13 source:- [x] all 183 installed third-party Python distributions exactly match thecommitted Windows lock; the checked-out `vibe-trading-ai` package is the only@@ -121,16 +122,20 @@ Windows host validation on 2026-07-31:absent;- [x] authenticated random-port startup and graceful shutdown succeed with noresidual embedded Python process;+- [x] the exact packaged application loads the current production frontend and+ embedded backend, then removes the Python child and loopback listener when+ only the Electron main PID is force-terminated;- [x] safeStorage migration, plaintext removal, allowlisting, replacement, andclearing succeed against an isolated temporary Windows profile;- [ ] the exact current branch's packaged application loads the frontend andbackend on a clean Windows VM and closes its owned process tree cleanly;- [x] the generated installer is reported as `NotSigned` by WindowsAuthenticode inspection;-- [x] the unsigned review installer is 323.2 MiB and its generated- `SHA256SUMS.txt` matches an independent SHA-256 calculation.+- [x] the unsigned review installer is 324.3 MiB and its generated+ `SHA256SUMS.txt` matches an independent SHA-256 calculation+ (`173f353fcb8517e9caaf3c715222d619c010bc615823df5e2ee414ace297783b`).-The assembled backend is 801.1 MiB before installer compression. An earlier+The assembled backend is 804.9 MiB before installer compression. An earlierprototype passed the isolated-profile startup/shutdown check, but that resultpredates the current-main rebuild and is deliberately not credited above. Aclean Windows VM re-run remains a release/review gate; this host record is notdiff --git a/desktop/electron/scripts/smoke-credentials.cjs b/desktop/electron/scripts/smoke-credentials.cjsindex 61e6fff52..820d70001 100644--- a/desktop/electron/scripts/smoke-credentials.cjs+++ b/desktop/electron/scripts/smoke-credentials.cjs@@ -96,7 +96,7 @@ async function run() {assert.equal(store.environment().OPENAI_API_KEY, undefined);await assert.rejects(store.set("UNSUPPORTED_SECRET", "not-allowed"),- /Unsupported credential key/u,+ /This credential key is not supported\./u,);console.log(diff --git a/desktop/electron/src/backend-manager.ts b/desktop/electron/src/backend-manager.tsindex 1884cdb91..77f461c11 100644--- a/desktop/electron/src/backend-manager.ts+++ b/desktop/electron/src/backend-manager.ts@@ -113,7 +113,9 @@ export class BackendManager {const watchdogPath = path.join(__dirname, "backend-watchdog.js");const watchdog = spawn(process.execPath, [watchdogPath], {- cwd: __dirname,+ // In a packaged app __dirname is inside app.asar. Electron's fs layer can+ // read that path, but Windows cannot use an ASAR path as a process cwd.+ cwd: this.options.resourcesPath,windowsHide: true,env: childEnvironment,stdio: ["ignore", "pipe", "pipe", "ipc"],diff --git a/desktop/electron/src/locales.ts b/desktop/electron/src/locales.tsindex 9e98eb196..f1189887a 100644--- a/desktop/electron/src/locales.ts+++ b/desktop/electron/src/locales.ts@@ -11,6 +11,11 @@ export type DesktopMessages = {backendHealthTimeout: string;backendNotFound: string;portUnavailable: string;+ credentialEncryptionUnavailable: string;+ credentialFileUnsupported: string;+ credentialKeyUnsupported: string;+ credentialRequestInvalid: string;+ credentialStoreUnavailable: string;closingService: string;menuApplication: string;menuRestartService: string;@@ -65,6 +70,11 @@ const messages: Record<DesktopLocale, DesktopMessages> = {backendHealthTimeout: "Timed out waiting for the Vibe-Trading backend.\n{details}",backendNotFound: "Could not find vibe-trading.exe. Install the backend first or set VIBE_TRADING_EXECUTABLE.",portUnavailable: "Could not allocate a local port.",+ credentialEncryptionUnavailable: "Credential encryption is unavailable for this Windows user session.",+ credentialFileUnsupported: "The desktop credential file format is not supported.",+ credentialKeyUnsupported: "This credential key is not supported.",+ credentialRequestInvalid: "The credential request is invalid.",+ credentialStoreUnavailable: "Secure credential storage has not been initialized.",closingService: "Closing the local service…",menuApplication: "Application",menuRestartService: "Restart local service",@@ -95,6 +105,11 @@ const messages: Record<DesktopLocale, DesktopMessages> = {backendHealthTimeout: "等待 Vibe-Trading 后端就绪超时。\n{details}",backendNotFound: "找不到 vibe-trading.exe。请先安装后端,或设置 VIBE_TRADING_EXECUTABLE。",portUnavailable: "无法分配本地端口。",+ credentialEncryptionUnavailable: "当前 Windows 用户会话无法使用凭据加密。",+ credentialFileUnsupported: "桌面凭据文件格式不受支持。",+ credentialKeyUnsupported: "不支持该凭据键。",+ credentialRequestInvalid: "凭据请求无效。",+ credentialStoreUnavailable: "安全凭据存储尚未初始化。",closingService: "正在关闭本地服务…",menuApplication: "应用",menuRestartService: "重启本地服务",@@ -125,6 +140,11 @@ const messages: Record<DesktopLocale, DesktopMessages> = {backendHealthTimeout: "Vibe-Trading バックエンドの準備待ちがタイムアウトしました。\n{details}",backendNotFound: "vibe-trading.exe が見つかりません。バックエンドをインストールするか、VIBE_TRADING_EXECUTABLE を設定してください。",portUnavailable: "ローカルポートを割り当てられませんでした。",+ credentialEncryptionUnavailable: "この Windows ユーザーセッションでは資格情報の暗号化を利用できません。",+ credentialFileUnsupported: "デスクトップ資格情報ファイルの形式はサポートされていません。",+ credentialKeyUnsupported: "この資格情報キーはサポートされていません。",+ credentialRequestInvalid: "資格情報の要求が無効です。",+ credentialStoreUnavailable: "安全な資格情報ストアが初期化されていません。",closingService: "ローカルサービスを終了しています…",menuApplication: "アプリケーション",menuRestartService: "ローカルサービスを再起動",@@ -155,6 +175,11 @@ const messages: Record<DesktopLocale, DesktopMessages> = {backendHealthTimeout: "Vibe-Trading 백엔드 준비를 기다리는 동안 시간이 초과되었습니다.\n{details}",backendNotFound: "vibe-trading.exe를 찾을 수 없습니다. 백엔드를 설치하거나 VIBE_TRADING_EXECUTABLE을 설정하세요.",portUnavailable: "로컬 포트를 할당할 수 없습니다.",+ credentialEncryptionUnavailable: "현재 Windows 사용자 세션에서 자격 증명 암호화를 사용할 수 없습니다.",+ credentialFileUnsupported: "데스크톱 자격 증명 파일 형식이 지원되지 않습니다.",+ credentialKeyUnsupported: "지원되지 않는 자격 증명 키입니다.",+ credentialRequestInvalid: "자격 증명 요청이 올바르지 않습니다.",+ credentialStoreUnavailable: "보안 자격 증명 저장소가 초기화되지 않았습니다.",closingService: "로컬 서비스를 종료하는 중…",menuApplication: "애플리케이션",menuRestartService: "로컬 서비스 다시 시작",@@ -185,6 +210,11 @@ const messages: Record<DesktopLocale, DesktopMessages> = {backendHealthTimeout: "انتهت مهلة انتظار جاهزية الواجهة الخلفية لـ Vibe-Trading.\n{details}",backendNotFound: "تعذّر العثور على vibe-trading.exe. ثبّت الواجهة الخلفية أولاً أو اضبط VIBE_TRADING_EXECUTABLE.",portUnavailable: "تعذّر تخصيص منفذ محلي.",+ credentialEncryptionUnavailable: "تشفير بيانات الاعتماد غير متاح لجلسة مستخدم Windows الحالية.",+ credentialFileUnsupported: "تنسيق ملف بيانات اعتماد سطح المكتب غير مدعوم.",+ credentialKeyUnsupported: "مفتاح بيانات الاعتماد هذا غير مدعوم.",+ credentialRequestInvalid: "طلب بيانات الاعتماد غير صالح.",+ credentialStoreUnavailable: "لم تتم تهيئة مخزن بيانات الاعتماد الآمن.",closingService: "جارٍ إغلاق الخدمة المحلية…",menuApplication: "التطبيق",menuRestartService: "إعادة تشغيل الخدمة المحلية",diff --git a/desktop/electron/src/main.ts b/desktop/electron/src/main.tsindex 630a94abd..496c37cde 100644--- a/desktop/electron/src/main.ts+++ b/desktop/electron/src/main.ts@@ -28,7 +28,7 @@ let desktopMessages = getDesktopMessages(desktopLocale);const apiAuthKey = randomBytes(32).toString("base64url");const productName = "Vibe-Trading Desktop (Unofficial Community Build)";const testUserData = process.env.VIBE_TRADING_DESKTOP_TEST_USER_DATA;-const credentialStore = new SecureCredentialStore();+let credentialStore: SecureCredentialStore | undefined;if (testUserData) app.setPath("userData", path.resolve(testUserData));app.setName(productName);@@ -53,6 +53,7 @@ async function ready(): Promise<void> {desktopMessages = getDesktopMessages(desktopLocale);nativeTheme.themeSource = "dark";app.setAppLogsPath();+ credentialStore = new SecureCredentialStore({ messages: desktopMessages });await credentialStore.initialize();createWindow();registerIpc();@@ -131,15 +132,16 @@ function registerIpc(): void {});ipcMain.handle("desktop:get-credential-status", (event) => {assertMainWindowSender(event.sender);- return credentialStore.status();+ return requireCredentialStore().status();});ipcMain.handle("desktop:set-credential", async (event, name: unknown, value: unknown) => {assertMainWindowSender(event.sender);if (typeof name !== "string" || (typeof value !== "string" && value !== null)) {- throw new Error("Invalid credential request");+ throw new Error(desktopMessages.credentialRequestInvalid);}- await credentialStore.set(name, value);- return credentialStore.status();+ const store = requireCredentialStore();+ await store.set(name, value);+ return store.status();});}@@ -172,7 +174,7 @@ async function bootInternal(): Promise<void> {logDirectory: app.getPath("logs"),apiAuthKey,messages: desktopMessages,- credentialEnvironment: credentialStore.environment(),+ credentialEnvironment: requireCredentialStore().environment(),onStatus: (message) => mainWindow?.webContents.send("desktop:status", message),onUnexpectedExit: (message) => {if (!quitting) void reportBootError(message);@@ -181,8 +183,8 @@ async function bootInternal(): Promise<void> {try {const url = await backend.start();- writeParentDeathSmokeRecord(url);await mainWindow.loadURL(url);+ writeParentDeathSmokeRecord(url);} catch (error) {await backend.stop();await reportBootError(errorText(error));@@ -239,6 +241,11 @@ function assertMainWindowSender(sender: Electron.WebContents): void {if (sender !== mainWindow?.webContents) throw new Error("Desktop request rejected");}+function requireCredentialStore(): SecureCredentialStore {+ if (!credentialStore) throw new Error(desktopMessages.credentialStoreUnavailable);+ return credentialStore;+}+async function shutdownAndQuit(): Promise<void> {if (quitting) return;quitting = true;diff --git a/desktop/electron/src/secure-credentials.ts b/desktop/electron/src/secure-credentials.tsindex 907caba6a..64bd719aa 100644--- a/desktop/electron/src/secure-credentials.ts+++ b/desktop/electron/src/secure-credentials.ts@@ -2,6 +2,7 @@ import { app, safeStorage } from "electron";import { promises as fs } from "node:fs";import os from "node:os";import path from "node:path";+import type { DesktopMessages } from "./locales";type CredentialFile = {version: 1;@@ -50,11 +51,24 @@ export type CredentialStatus = {export type SecureCredentialStoreOptions = {userDataDirectory?: string;homeDirectory?: string;+ messages?: Pick<+ DesktopMessages,+ | "credentialEncryptionUnavailable"+ | "credentialFileUnsupported"+ | "credentialKeyUnsupported"+ >;+};++const defaultMessages: NonNullable<SecureCredentialStoreOptions["messages"]> = {+ credentialEncryptionUnavailable: "Credential encryption is unavailable for this Windows user session.",+ credentialFileUnsupported: "The desktop credential file format is not supported.",+ credentialKeyUnsupported: "This credential key is not supported.",};export class SecureCredentialStore {private readonly filePath: string;private readonly homeDirectory: string;+ private readonly messages: NonNullable<SecureCredentialStoreOptions["messages"]>;private values: Record<string, string> = {};private migrated: string[] = [];@@ -64,11 +78,12 @@ export class SecureCredentialStore {"credentials.v1.json",);this.homeDirectory = options.homeDirectory ?? os.homedir();+ this.messages = options.messages ?? defaultMessages;}async initialize(): Promise<void> {if (!safeStorage.isEncryptionAvailable()) {- throw new Error("Windows credential encryption is unavailable for this user session.");+ throw new Error(this.messages.credentialEncryptionUnavailable);}await this.load();await this.migrateDotenv(path.join(this.homeDirectory, ".vibe-trading", ".env"));@@ -117,7 +132,7 @@ export class SecureCredentialStore {private assertAllowed(name: string): void {if (!ENV_CREDENTIALS.has(name)) {- throw new Error("Unsupported credential key");+ throw new Error(this.messages.credentialKeyUnsupported);}}@@ -125,7 +140,7 @@ export class SecureCredentialStore {try {const parsed = JSON.parse(await fs.readFile(this.filePath, "utf8")) as CredentialFile;if (parsed.version !== 1 || !parsed.values || typeof parsed.values !== "object") {- throw new Error("Unsupported desktop credential file");+ throw new Error(this.messages.credentialFileUnsupported);}this.values = Object.fromEntries(Object.entries(parsed.values).filter(