Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(plugin-market): 阻止启动扫描损坏插件安装状态

david34f97bb4cf32
diff --git a/apps/desktop/scripts/smoke-packaged.mjs b/apps/desktop/scripts/smoke-packaged.mjs
index 3e81645edb..560c01bb35 100644
--- a/apps/desktop/scripts/smoke-packaged.mjs
+++ b/apps/desktop/scripts/smoke-packaged.mjs
@@ -58,10 +58,11 @@ function parseArgs() {
const arch = out.arch || process.arch;
const outDir = out['out-dir'] || null;
const appName = out['app-name'] || PACKAGED_APP_NAME;
- return { platform, arch, outDir, appName };
+ const pluginStorage = args.includes('--plugin-storage');
+ return { platform, arch, outDir, appName, pluginStorage };
}
-const { platform, arch, outDir, appName } = parseArgs();
+const { platform, arch, outDir, appName, pluginStorage } = parseArgs();
if (!['win32', 'darwin', 'linux'].includes(platform)) {
console.error(`[smoke] ERROR: unsupported --platform=${platform}`);
@@ -170,6 +171,7 @@ const child = spawn(
[
'--smoke-test',
`--smoke-user=${SMOKE_USER}`,
+ ...(pluginStorage ? ['--smoke-plugin-storage'] : []),
`--user-data-dir=${tmpUserData}`,
],
{
@@ -252,6 +254,24 @@ child.on('exit', (code, signal) => {
process.exit(1);
}
}
+ if (pluginStorage) {
+ const storage = parsed.plugin_storage || {};
+ if (storage.ownerGhostFound !== true) {
+ console.error('[smoke] FAIL: owner Plugin was not found after signed-out startup recovery');
+ cleanupUserData();
+ process.exit(1);
+ }
+ if (storage.ledgerInstalledAfterEmptySnapshot !== true) {
+ console.error('[smoke] FAIL: passive empty snapshot changed installed ledger state');
+ cleanupUserData();
+ process.exit(1);
+ }
+ if (storage.optOutAfterEmptySnapshot !== false) {
+ console.error('[smoke] FAIL: passive empty snapshot wrote a default-install opt-out');
+ cleanupUserData();
+ process.exit(1);
+ }
+ }
if (code !== 0) {
console.error(`[smoke] FAIL: child exit code ${code} (expected 0)`);
cleanupUserData();
@@ -260,7 +280,8 @@ child.on('exit', (code, signal) => {
console.log(
`✅ smoke test passed: schema_version=${parsed.schema_version}, ` +
- `sessions=${t.sessions}, messages=${t.messages}, migration_meta=${t.migration_meta}`,
+ `sessions=${t.sessions}, messages=${t.messages}, migration_meta=${t.migration_meta}` +
+ (pluginStorage ? ', plugin_storage=passed' : ''),
);
cleanupUserData();
process.exit(0);
diff --git a/apps/desktop/src/main/bootstrap-electron.ts b/apps/desktop/src/main/bootstrap-electron.ts
index 268e8fee4f..45d4dc0843 100644
--- a/apps/desktop/src/main/bootstrap-electron.ts
+++ b/apps/desktop/src/main/bootstrap-electron.ts
@@ -707,6 +707,7 @@ import { registerPluginMarketIpc, syncDefaultMarketPlugins } from './plugin-mark
import { findCindyFileInArgv } from './cindy-brain/argv.js';
import { handleIncomingCindyFile } from './cindy-brain/openFileInstall.js';
import { registerCindyFileAssociation } from './cindy-brain/fileAssociation.js';
+import { runPluginStorageSmoke } from './smoke/pluginStorageSmoke.js';
import { setMainLocale, t } from './i18n.js';
import { requireObject, throwIpcError } from './utils/ipcValidate.js';
import { pickNativeAtResource } from './nativeAtResourcePicker.js';
@@ -5947,14 +5948,31 @@ const registerIpcHandlers = () => {
// schema_version + core tables, emit JSON to stdout, and exit. Electron's
// native `--user-data-dir` flag is expected to be passed by the smoke script
// so the fake DB lives in a scratch directory.
-function parseSmokeArgs(): { enabled: boolean; userId: string } {
- const enabled = process.argv.includes('--smoke-test');
+function parseSmokeArgs(): {
+ enabled: boolean;
+ userId: string;
+ pluginStorage: boolean;
+ resultFile: string | null;
+} {
+ const resultFile = !app.isPackaged
+ ? process.env.XDT_PLUGIN_STORAGE_SMOKE_RESULT_FILE?.trim() || null
+ : null;
+ const enabled = process.argv.includes('--smoke-test') || resultFile !== null;
const userFlag = process.argv.find((a) => a.startsWith('--smoke-user='));
const userId = userFlag ? userFlag.slice('--smoke-user='.length) : '__smoke_test__';
- return { enabled, userId };
+ return {
+ enabled,
+ userId,
+ pluginStorage: process.argv.includes('--smoke-plugin-storage') || resultFile !== null,
+ resultFile,
+ };
}
-async function runSmokeTest(userId: string): Promise<void> {
+async function runSmokeTest(
+ userId: string,
+ pluginStorage: boolean,
+ resultFile: string | null,
+): Promise<void> {
try {
const result = await localDbEnsureReady(userId);
if (!result.ready) {
@@ -5977,8 +5995,10 @@ async function runSmokeTest(userId: string): Promise<void> {
const metaCount = (
db.prepare('SELECT COUNT(*) AS c FROM migration_meta').get() as { c: number }
).c;
- process.stdout.write(
- `${JSON.stringify({
+ const pluginStorageResult = pluginStorage
+ ? await runPluginStorageSmoke(userId)
+ : undefined;
+ const payload = {
ok: true,
schema_version: schemaVersion,
tables: {
@@ -5986,8 +6006,11 @@ async function runSmokeTest(userId: string): Promise<void> {
messages: messagesCount,
migration_meta: metaCount,
},
- })}\n`,
- );
+ ...(pluginStorageResult ? { plugin_storage: pluginStorageResult } : {}),
+ };
+ const serialized = `${JSON.stringify(payload)}\n`;
+ if (resultFile) fs.writeFileSync(resultFile, serialized, { mode: 0o600 });
+ process.stdout.write(serialized);
localDbCloseDb();
app.quit();
} catch (err) {
@@ -6085,7 +6108,7 @@ app.on('ready', async () => {
// Smoke-test flag short-circuit: skip all normal init paths.
const smoke = parseSmokeArgs();
if (smoke.enabled) {
- await runSmokeTest(smoke.userId);
+ await runSmokeTest(smoke.userId, smoke.pluginStorage, smoke.resultFile);
return;
}
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/repoRoot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/repoRoot.test.ts
index d9c32cd875..d5f622ce43 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/repoRoot.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/repoRoot.test.ts
@@ -6,7 +6,11 @@
import { describe, it, expect, vi } from 'vitest';
import path from 'node:path';
-import { resolveGhostRepoRoot, type GhostRepoRootDeps } from '../repoRoot';
+import {
+ resolveCachedGhostRepoRoot,
+ resolveGhostRepoRoot,
+ type GhostRepoRootDeps,
+} from '../repoRoot';
const USER_DATA = path.join(path.sep, 'fake', 'userData');
const ROOT = path.join(USER_DATA, 'cindy-brain');
@@ -62,3 +66,66 @@ describe('resolveGhostRepoRoot', () => {
expect(rename).not.toHaveBeenCalled();
});
});
+
+describe('resolveCachedGhostRepoRoot', () => {
+ it('reuses the resolved root while the owner scope is unchanged', () => {
+ const first = makeDeps([]);
+ const cached = resolveCachedGhostRepoRoot(null, 'signed-out:none:0', first.deps);
+ const second = makeDeps([], {
+ userDataDir: path.join(path.sep, 'unused'),
+ exists: vi.fn(() => false),
+ });
+
+ const resolved = resolveCachedGhostRepoRoot(
+ cached,
+ 'signed-out:none:0',
+ second.deps,
+ );
+
+ expect(resolved).toBe(cached);
+ expect(second.deps.exists).not.toHaveBeenCalled();
+ });
+
+ it('resolves the real owner root after signed-out startup restores an account', () => {
+ const signedOut = makeDeps([], {
+ userDataDir: path.join(path.sep, 'userData', 'cindy-no-session', '123'),
+ });
+ const initial = resolveCachedGhostRepoRoot(
+ null,
+ 'signed-out:none:0',
+ signedOut.deps,
+ );
+ const ownerDataDir = path.join(path.sep, 'userData', 'owners', 'user-1');
+ const restored = makeDeps([], { userDataDir: ownerDataDir });
+
+ const resolved = resolveCachedGhostRepoRoot(
+ initial,
+ 'cloud:user-1:1',
+ restored.deps,
+ );
+
+ expect(resolved).not.toBe(initial);
+ expect(resolved).toEqual({
+ ownerScopeKey: 'cloud:user-1:1',
+ rootDir: path.join(ownerDataDir, 'cindy-brain'),
+ });
+ });
+
+ it('does not reuse one account root for another account', () => {
+ const ownerA = path.join(path.sep, 'userData', 'owners', 'user-a');
+ const ownerB = path.join(path.sep, 'userData', 'owners', 'user-b');
+ const initial = resolveCachedGhostRepoRoot(
+ null,
+ 'cloud:user-a:1',
+ makeDeps([], { userDataDir: ownerA }).deps,
+ );
+
+ const resolved = resolveCachedGhostRepoRoot(
+ initial,
+ 'cloud:user-b:2',
+ makeDeps([], { userDataDir: ownerB }).deps,
+ );
+
+ expect(resolved.rootDir).toBe(path.join(ownerB, 'cindy-brain'));
+ });
+});
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index c81365de8c..9947f47493 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -74,7 +74,10 @@ import { serverApiFetch } from '../serverApiClient.js';
import { getClientEndpoint } from '../clientEndpointsService.js';
import { createGhostOauthBrokerClient } from './ghostOauthBroker.js';
import { readRefImagesWithinBudget } from './refImageBudget.js';
-import { resolveGhostRepoRoot } from './repoRoot.js';
+import {
+ resolveCachedGhostRepoRoot,
+ type GhostRepoRootCacheEntry,
+} from './repoRoot.js';
import { takePendingCindyInstall } from './openFileInstall.js';
import { GhostRuntime } from './runtime/GhostRuntime.js';
import {
@@ -751,17 +754,19 @@ export function suspendAllGhosts(): void {
let ipcRegistered = false;
/** 意识仓库根(userData/cindy-brain;旧 brain 目录首次解析时原地迁移)。 */
-let brainRootCache: string | null = null;
+let brainRootCache: GhostRepoRootCacheEntry | null = null;
function brainRootDir(): string {
- if (!brainRootCache) {
- brainRootCache = resolveGhostRepoRoot({
+ brainRootCache = resolveCachedGhostRepoRoot(
+ brainRootCache,
+ activeOwnerScopeKey(),
+ {
userDataDir: ownerScopedUserDataPath(),
exists: (p) => fs.existsSync(p),
rename: (from, to) => fs.renameSync(from, to),
log,
- });
- }
- return brainRootCache;
+ },
+ );
+ return brainRootCache.rootDir;
}
/**
diff --git a/apps/desktop/src/main/cindy-brain/repoRoot.ts b/apps/desktop/src/main/cindy-brain/repoRoot.ts
index 54269e2a77..85c417438a 100644
--- a/apps/desktop/src/main/cindy-brain/repoRoot.ts
+++ b/apps/desktop/src/main/cindy-brain/repoRoot.ts
@@ -20,6 +20,11 @@ export interface GhostRepoRootDeps {
};
}
+export interface GhostRepoRootCacheEntry {
+ ownerScopeKey: string;
+ rootDir: string;
+}
+
/** 解析意识仓库根;调用方自行缓存结果(迁移只应尝试一次)。 */
export function resolveGhostRepoRoot(deps: GhostRepoRootDeps): string {
const root = path.join(deps.userDataDir, 'cindy-brain');
@@ -45,3 +50,16 @@ export function resolveGhostRepoRoot(deps: GhostRepoRootDeps): string {
}
return root;
}
+
+/** Cache the resolved repository root only for the owner scope that produced it. */
+export function resolveCachedGhostRepoRoot(
+ cache: GhostRepoRootCacheEntry | null,
+ ownerScopeKey: string,
+ deps: GhostRepoRootDeps,
+): GhostRepoRootCacheEntry {
+ if (cache?.ownerScopeKey === ownerScopeKey) return cache;
+ return {
+ ownerScopeKey,
+ rootDir: resolveGhostRepoRoot(deps),
+ };
+}
diff --git a/apps/desktop/src/main/plugin-market/__tests__/service-custom-sources.test.ts b/apps/desktop/src/main/plugin-market/__tests__/service-custom-sources.test.ts
index aa0c63465e..fde0d646b9 100644
--- a/apps/desktop/src/main/plugin-market/__tests__/service-custom-sources.test.ts
+++ b/apps/desktop/src/main/plugin-market/__tests__/service-custom-sources.test.ts
@@ -225,6 +225,28 @@ describe('PluginMarketService 自定义市场聚合', () => {
});
});
+ it('does not mark a custom market installation removed when discovery is temporarily empty', async () => {
+ const h = harness([], []);
+ const pluginId = customMarketPluginId('team-lib', 'alpha');
+ h.ledger.upsertInstallation({
+ pluginId,
+ ghostId: 'alpha',
+ releaseId: customMarketReleaseId('team-lib', 'alpha', '1.0.0'),
+ version: '1.0.0',
+ sha256: 'custom-unverified',
+ scope: 'public',
+ organizationId: null,
+ source: 'local-market',
+ installed: true,
+ updatedAt: '2026-07-30T02:00:00.000Z',
+ });
+
+ await expect(h.service.snapshot()).resolves.toMatchObject({ items: [] });
+
+ expect(h.ledger.installationForGhost('alpha')?.installed).toBe(true);
+ expect(h.ledger.isDefaultInstallSuppressed('user-1', pluginId)).toBe(false);
+ });
+
it('does not expose custom market releases that require a newer Cindy version', async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-custom-fixture-'));
roots.push(root);
diff --git a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts b/apps/desktop/src/main/plugin-market/__tests__/service.test.ts
index dafa0a38ad..5a9a46b3ca 100644
--- a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts
+++ b/apps/desktop/src/main/plugin-market/__tests__/service.test.ts
@@ -1649,9 +1649,9 @@ describe('PluginMarketService migration and defaultInstall', () => {
});
});
- it('treats a missing previously-managed directory as an opt-out and does not reinstall', async () => {
+ it('does not turn a temporarily missing managed directory into an uninstall or opt-out', async () => {
const item = summary({ defaultInstall: true });
- const h = harness([item]);
+ const h = harness([]);
h.ledger.upsertInstallation({
pluginId: item.id,
ghostId: item.ghostId,
@@ -1668,8 +1668,9 @@ describe('PluginMarketService migration and defaultInstall', () => {
const snapshot = await h.service.snapshot();
expect(runtime.install).not.toHaveBeenCalled();
- expect(snapshot.items[0]?.installState).toBe('not-installed');
- expect(h.ledger.isDefaultInstallSuppressed('user-1', item.id)).toBe(true);
+ expect(snapshot.items).toEqual([]);
+ expect(h.ledger.installationForGhost(item.ghostId)?.installed).toBe(true);
+ expect(h.ledger.isDefaultInstallSuppressed('user-1', item.id)).toBe(false);
});
it('records an opt-out only after a tracked local uninstall succeeds', async () => {
@@ -1686,6 +1687,25 @@ describe('PluginMarketService migration and defaultInstall', () => {
expect(h.ledger.isDefaultInstallSuppressed('user-1', item.id)).toBe(true);
});
+ it('does not reinstall a default Plugin when a snapshot races its explicit uninstall', async () => {
+ const item = summary({ defaultInstall: true });
+ const h = harness([item]);
+ h.ledger.upsertInstallation(recordForTest(item));
+ runtime.ghosts = [ghostEntry(item.ghostId)];
+ let racingSnapshot: ReturnType<typeof h.service.snapshot> | null = null;
+ runtime.uninstall.mockImplementationOnce(async () => {
+ runtime.ghosts = [];
+ racingSnapshot = h.service.snapshot();
+ });
+
+ await expect(h.service.uninstall(item.id)).resolves.toEqual({ ok: true });
+ await expect(racingSnapshot).resolves.toMatchObject({ unavailableReason: null });
+
+ expect(runtime.install).not.toHaveBeenCalled();
+ expect(h.ledger.installationForGhost(item.ghostId)?.installed).toBe(false);
+ expect(h.ledger.isDefaultInstallSuppressed('user-1', item.id)).toBe(true);
+ });
+
it('records local-mode defaultInstall opt-out under the local owner', async () => {
runtime.session = {
mode: 'local',
diff --git a/apps/desktop/src/main/plugin-market/service.ts b/apps/desktop/src/main/plugin-market/service.ts
index 26caf2c7b3..f334be4f0e 100644
--- a/apps/desktop/src/main/plugin-market/service.ts
+++ b/apps/desktop/src/main/plugin-market/service.ts
@@ -441,8 +441,14 @@ export class PluginMarketService {
const ledger = this.ledgerForOwner(owner);
await this.adoptLegacyInstallations(plugins, ledger, owner);
await this.backfillOfficialCindyGithubTrust(ledger, owner);
- await this.reconcileRemovedInstallations(ledger, owner);
+ // A snapshot is passive discovery: an empty runtime list can be caused by
+ // startup, an owner transition, or a transient filesystem view. Only an
+ // explicit uninstall may turn that absence into installed=false/opt-out.
await this.applyServerRemovals(removals, owner, ledger);
+ // Explicit uninstall completion is allowed to finish its physical removal
+ // before its ledger write. Wait for queued ledger mutations before deciding
+ // whether a default plugin should be installed again.
+ await this.ledgerMutation;
// 自定义来源只影响自己的目录发现;暂时不可读的来源不能阻塞官方默认安装。
// 已经落地的同 id 插件仍由 applyDefaultInstalls → installDetail 的本地事实检查保护。
await this.applyDefaultInstalls(plugins, owner, ledger);
@@ -1461,26 +1467,6 @@ export class PluginMarketService {
}
}
- private async reconcileRemovedInstallations(
- ledger: PluginMarketLedger,
- owner: ActiveAppSession,
- ): Promise<void> {
- const installSubject = defaultInstallSubject(owner);
- for (const record of Object.values(ledger.read().installations)) {
- if (!record.installed) continue;
- await this.withLedgerMutation(owner, () => {
- // 在场判定必须与写入同处一把锁内且即时重取:manager.update 的两次
- // rename 之间 ghosts/<id> 短暂不存在,锁外的一次性快照会把这类瞬态
- // 误判成"已卸载",把 pluginId 永久写进 defaultInstallOptOuts,该
- // 默认安装插件从此不再自动装回。
- const stillInstalled = getGhostManager()
- .list()
- .some((ghost) => ghost.manifest.id === record.ghostId);
- if (!stillInstalled) ledger.markRemoved(record.ghostId, installSubject);
- });
- }
- }
-
private async applyServerRemovals(
removals: readonly PluginRemovalNotice[],
owner: ActiveAppSession,
@@ -1607,6 +1593,14 @@ export class PluginMarketService {
try {
await this.withMutation(summary.id, async () => {
requireSameMarketOwner(owner);
+ const freshLedgerData = ledger.read();
+ if (freshLedgerData.defaultInstallOptOuts[installSubject]?.includes(summary.id)) {
+ return;
+ }
+ const freshLocal = this.localInstallSnapshot(ledger, freshLedgerData.installations);
+ if (this.toItem(summary, freshLocal).installState !== 'not-installed') {
+ return;
+ }
const detail = await this.api.detail(summary.id);
requireSameMarketOwner(owner);
assertDetailMatchesSummary(summary, detail);
diff --git a/apps/desktop/src/main/smoke/pluginStorageSmoke.ts b/apps/desktop/src/main/smoke/pluginStorageSmoke.ts
new file mode 100644
index 0000000000..f0b7a1a203
--- /dev/null
+++ b/apps/desktop/src/main/smoke/pluginStorageSmoke.ts
@@ -0,0 +1,130 @@
+import fs from 'node:fs';
+import path from 'node:path';
+
+import { app } from 'electron';
+import { CLIENT_ENDPOINT_KEYS, type ClientEndpointMap } from '@cindy/maker-shared/client-endpoints';
+import type { VisiblePluginSummary } from '@cindy/plugin-protocol';
+
+import {
+ commitActiveAppSession,
+ dataOwnerStorageKey,
+} from '../appSessionState.js';
+import { getGhostManager } from '../cindy-brain/index.js';
+import { resetClientEndpointsForTest } from '../clientEndpointsService.js';
+import type { PluginMarketApi } from '../plugin-market/api.js';
+import { PluginMarketLedger } from '../plugin-market/ledger.js';
+import { PluginMarketService } from '../plugin-market/service.js';
+import { MarketSourceStore } from '../plugin-market/sources/store.js';
+
+const GHOST_ID = 'cindy-smoke-storage';
+const PLUGIN_ID = `c${'f'.repeat(24)}`;
+
+export interface PluginStorageSmokeResult {
+ initialSignedOutCount: number;
+ ownerGhostFound: boolean;
+ ownerGhostDir: string | null;
+ ledgerInstalledAfterEmptySnapshot: boolean;
+ optOutAfterEmptySnapshot: boolean;
+}
+
+function endpointFixture(): ClientEndpointMap {
+ const endpoints = Object.fromEntries(
+ CLIENT_ENDPOINT_KEYS.map((key) => [key, '']),
+ ) as ClientEndpointMap;
+ endpoints.pluginApiBaseUrl = 'https://plugin-smoke.invalid';
+ return endpoints;
+}
+
+function pluginSummary(): VisiblePluginSummary {
+ return {
+ id: PLUGIN_ID,
+ ghostId: GHOST_ID,
+ name: 'Plugin storage smoke',
+ description: 'Packaged smoke fixture',
+ author: 'Cindy',
+ scope: 'public',
+ organizationId: null,
+ defaultInstall: false,
+ currentRelease: {
+ id: 'release-smoke-1',
+ version: '1.0.0',
+ sha256: 'a'.repeat(64),
+ sizeBytes: 1,
+ publishedAt: '2026-08-09T00:00:00.000Z',
+ icon: null,
+ },
+ };
+}
+
+/**
+ * Packaged-process black-box fixture for the plugin storage startup boundary.
+ * This function is called only by the explicit `--smoke-plugin-storage` path.
+ */
+export async function runPluginStorageSmoke(ownerId: string): Promise<PluginStorageSmokeResult> {
+ const manager = getGhostManager();
+ const initialSignedOutCount = manager.list().length;
+ const ownerRoot = path.join(
+ app.getPath('userData'),
+ 'owners',
+ dataOwnerStorageKey(ownerId),
+ );
+ const ghostDir = path.join(ownerRoot, 'cindy-brain', GHOST_ID);
+ const marketDir = path.join(ownerRoot, 'plugin-market');
+ const ledgerPath = path.join(marketDir, 'ledger.v1.json');
+ fs.mkdirSync(ghostDir, { recursive: true });
+ fs.mkdirSync(marketDir, { recursive: true });
+ fs.writeFileSync(
+ path.join(ghostDir, 'ghost.json'),
+ `${JSON.stringify({
+ schemaVersion: 2,
+ id: GHOST_ID,
+ name: 'Plugin storage smoke',
+ description: 'Packaged smoke fixture',
+ author: 'Cindy',
+ version: '1.0.0',
+ kind: 'chip',
+ entry: 'main.js',
+ slots: ['notify'],
+ })}\n`,
+ );
+ fs.writeFileSync(path.join(ghostDir, 'main.js'), '// packaged plugin storage smoke\n');
+
+ const ledger = new PluginMarketLedger(ledgerPath);
+ ledger.upsertInstallation({
+ pluginId: PLUGIN_ID,
+ ghostId: GHOST_ID,
+ releaseId: 'release-smoke-1',
+ version: '1.0.0',
+ sha256: 'a'.repeat(64),
+ scope: 'public',
+ organizationId: null,
+ source: 'market',
+ installed: true,
+ updatedAt: '2026-08-09T00:00:00.000Z',
+ });
+
+ commitActiveAppSession('cloud', ownerId);
+ const ownerGhost = manager.list().find((ghost) => ghost.manifest.id === GHOST_ID) ?? null;
+
+ // A passive snapshot must not translate temporary absence into an uninstall.
+ fs.renameSync(ghostDir, path.join(ownerRoot, 'cindy-brain', `.${GHOST_ID}-hidden`));
+ resetClientEndpointsForTest(endpointFixture());
+ const api = {
+ listAll: async () => ({ plugins: [pluginSummary()], removals: [] }),
+ } as unknown as PluginMarketApi;
+ const service = new PluginMarketService(
+ api,
+ ledger,
+ new MarketSourceStore(path.join(marketDir, 'sources.v1.json')),
+ );
+ await service.snapshot();
+ const record = ledger.installationForGhost(GHOST_ID);
+
+ return {
+ initialSignedOutCount,
+ ownerGhostFound: ownerGhost !== null,
+ ownerGhostDir: ownerGhost?.dir ?? null,
+ ledgerInstalledAfterEmptySnapshot: record?.installed === true,
+ optOutAfterEmptySnapshot: ledger.isDefaultInstallSuppressed(ownerId, PLUGIN_ID),
+ };
+}
diff --git a/scripts/restart-desktop-remote.mjs b/scripts/restart-desktop-remote.mjs
index cf9d508ada..f2745a0f91 100644
--- a/scripts/restart-desktop-remote.mjs
+++ b/scripts/restart-desktop-remote.mjs
@@ -534,6 +534,8 @@ export function devEnvPrefix(env = process.env, platform = process.platform) {
['OPEN_DEVTOOLS', env.OPEN_DEVTOOLS],
// --wait-ready 的一次性状态文件:runner 写失败,Electron main ready-to-show 写成功。
['XDT_DESKTOP_DEV_STARTUP_STATUS_FILE', env.XDT_DESKTOP_DEV_STARTUP_STATUS_FILE],
+ // 插件存储启动边界的 dev 黑盒验收:仅显式临时结果路径时启用。
+ ['XDT_PLUGIN_STORAGE_SMOKE_RESULT_FILE', env.XDT_PLUGIN_STORAGE_SMOKE_RESULT_FILE],
].filter(([, value]) => value);
if (envEntries.length === 0) return '';