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(desktop): ignore reserved-only recovery whitelist

Yuewei-LLc632f842dbae
diff --git a/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts b/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
index 1b36e08154..e46db193c9 100644
--- a/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
+++ b/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
@@ -1880,6 +1880,36 @@ describe('legacy Ghost plugin recovery', () => {
).resolves.toMatchObject({ moved: 1, recoveredIds: ['later-plugin'] });
});
+ it('does not freeze fresh legacy recovery behind a marker containing only reserved ids', async () => {
+ const root = await tempRoot();
+ const ownerId = 'cloud-a';
+ const ownerKey = dataOwnerStorageKey(ownerId);
+ const markerPath = path.join(
+ root,
+ 'owners',
+ ownerKey,
+ __testing.LEGACY_GHOST_RECOVERY_MARKER,
+ );
+ await fs.mkdir(path.dirname(markerPath), { recursive: true });
+ await fs.writeFile(markerPath, JSON.stringify({
+ version: 2,
+ ownerKey,
+ pendingIds: ['cindy-reserved'],
+ failedIds: ['cindy-reserved'],
+ approvalProjectionSha256ById: { 'cindy-reserved': 'a'.repeat(64) },
+ }));
+ await writeGhostDir(root, 'brain', 'later-plugin');
+
+ await expect(
+ getLegacyGhostRecoveryStatus(
+ { mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
+ root,
+ false,
+ { rejectReservedIds: true },
+ ),
+ ).toEqual({ state: 'partial', legacyPluginCount: 1, canRetry: true });
+ });
+
it('moves builtin provisioning state with plugins before reconciliation', async () => {
const root = await tempRoot();
const ownerId = 'cloud-a';
diff --git a/apps/desktop/src/main/ownerNamespaceMigration.ts b/apps/desktop/src/main/ownerNamespaceMigration.ts
index 0ec3a61b8d..cca9cfb20d 100644
--- a/apps/desktop/src/main/ownerNamespaceMigration.ts
+++ b/apps/desktop/src/main/ownerNamespaceMigration.ts
@@ -1235,6 +1235,9 @@ export function getLegacyGhostRecoveryStatus(
const visiblePendingIds = options.rejectReservedIds
? (recoveryMarker?.pendingIds ?? []).filter((id) => !isOfficialGhostId(id))
: (recoveryMarker?.pendingIds ?? []);
+ // A marker containing only reserved ids has no applicable recovery
+ // whitelist in packaged builds; treat it as empty for fresh legacy sources.
+ const hasVisibleFrozenWhitelist = recoveryMarker !== null && visiblePendingIds.length > 0;
const targetInvalidIds = new Set(
targetDiscovery.invalidIds.filter((id) => visiblePendingIds.includes(id)),
);
@@ -1295,7 +1298,9 @@ export function getLegacyGhostRecoveryStatus(
(!options.rejectReservedIds || !isOfficialGhostId(id)),
);
const unexpectedFrozenIds = recoveryMarker
- ? legacyGhosts.map((ghost) => ghost.id).filter((id) => !recoveryMarker.pendingIds.includes(id))
+ ? (hasVisibleFrozenWhitelist
+ ? legacyGhosts.map((ghost) => ghost.id).filter((id) => !visiblePendingIds.includes(id))
+ : [])
: [];
const legacyPluginCount = new Set([
...legacyGhosts.map((ghost) => ghost.id),
@@ -1344,7 +1349,7 @@ export function getLegacyGhostRecoveryStatus(
}
const eligibleLegacyGhosts = (sharedRecoveryBlocked ? scopedLegacyGhosts : legacyGhosts)
- .filter((ghost) => !recoveryMarker || recoveryMarker.pendingIds.includes(ghost.id));
+ .filter((ghost) => !hasVisibleFrozenWhitelist || visiblePendingIds.includes(ghost.id));
if (!hasSafeRecoveryTargetChainSync(root, targetRoot)) {
return { state: 'partial', legacyPluginCount, canRetry: false };
}