Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(ios-simulator): check owner recycle journals before borrowing
JiangJiahao87949b5a0267
diff --git a/apps/desktop/src/main/__tests__/managedWorktreeRecycle.test.ts b/apps/desktop/src/main/__tests__/managedWorktreeRecycle.test.tsindex 277d2714e1..8235ff2050 100644--- a/apps/desktop/src/main/__tests__/managedWorktreeRecycle.test.ts+++ b/apps/desktop/src/main/__tests__/managedWorktreeRecycle.test.ts@@ -221,7 +221,13 @@ describe('shared worktree recycling', () => {expect(await recycle()).toBe(false);expect((await readRecycleRecord(meta.path))?.reason).toBe('directory-replaced');});- it('partial EBUSY deletion retains evidence and retries only unchanged surviving bytes', async () => {+ it('partial EBUSY deletion rejects cross-profile borrowing and retries unchanged surviving bytes', async () => {+ const actual = await vi.importActual<typeof import('../worktree/runtimeLeases')>('../worktree/runtimeLeases');+ vi.mocked(readWorktreeRuntimePaths).mockImplementation(actual.readWorktreeRuntimePaths);+ const borrowerProfile = path.join(state.root, 'borrower-profile');+ for (const profile of [state.root, borrowerProfile]) {+ await fs.mkdir(path.join(profile, '.dev-instances'), { recursive: true });+ }const rm = fs.rm;const fail = vi.spyOn(fs, 'rm').mockImplementation(async (target, options) => {if (String(target) === meta.path) throw Object.assign(new Error('locked'), { code: 'EBUSY' });@@ -237,6 +243,19 @@ describe('shared worktree recycling', () => {expect(await recycle()).toBe(false);expect((await readRecycleRecord(meta.path))?.phase).toBe('removing');expect(state.registry.has(meta.sessionId)).toBe(true);+ await expect(fs.stat(path.join(meta.path, '.git'))).rejects.toMatchObject({ code: 'ENOENT' });+ state.userData = borrowerProfile;+ let release: (() => Promise<void>) | null = null;+ try {+ await expect(acquireIOSSimulatorProjectUse('borrower', meta.path, new AbortController()).then((value) => {+ release = value; return value;+ })).rejects.toMatchObject({ code: 'MUTATION_CANCELLED' });+ expect(await readWorktreeRuntimePaths()).toEqual(new Set());+ expect(await fs.readFile(path.join(meta.path, 'draft.txt'), 'utf8')).toBe('uncommitted contents');+ } finally {+ await (release as (() => Promise<void>) | null)?.();+ state.userData = '';+ }fail.mockRestore();expect(await recycle()).toBe(true);expect(snapshot).toHaveBeenCalledTimes(1);diff --git a/apps/desktop/src/main/__tests__/worktreeRecycleJournalFilesystem.test.ts b/apps/desktop/src/main/__tests__/worktreeRecycleJournalFilesystem.test.tsindex 5da40a5f03..4d4d729970 100644--- a/apps/desktop/src/main/__tests__/worktreeRecycleJournalFilesystem.test.ts+++ b/apps/desktop/src/main/__tests__/worktreeRecycleJournalFilesystem.test.ts@@ -3,14 +3,23 @@ import fs from 'node:fs/promises';import os from 'node:os';import path from 'node:path';-const state = vi.hoisted(() => ({ root: '' }));-vi.mock('electron', () => ({ app: { getPath: () => state.root } }));-import { recycleJournalRoot, watchRecycleJournal } from '../worktree/recycleJournal';+const state = vi.hoisted(() => ({ root: '', userData: '' }));+vi.mock('electron', () => ({ app: { getPath: (name: string) => name === 'appData' ? path.join(state.root, 'app-data') : (state.userData || state.root) } }));+import { newRecycleRecord, readRecycleRecordsAcrossProfiles, recycleJournalRoot, watchRecycleJournal, writeRecycleRecord } from '../worktree/recycleJournal';+import { withWorktreeResourceLock } from '../worktree/resourceLock';describe('native worktree journal watcher', () => {let stop: (() => void) | undefined;- beforeEach(async () => { state.root = await fs.mkdtemp(path.join(os.tmpdir(), 'cindy-recycle-watch-')); });- afterEach(async () => { stop?.(); await fs.rm(state.root, { recursive: true, force: true }); });+ beforeEach(async () => {+ state.root = await fs.mkdtemp(path.join(os.tmpdir(), 'cindy-recycle-watch-'));+ state.userData = ''; stop = undefined;+ });+ afterEach(async () => { stop?.(); vi.restoreAllMocks(); await fs.rm(state.root, { recursive: true, force: true }); });++ const recordFor = () => newRecycleRecord({+ sessionId: 'owner', name: 'one', path: path.join(state.root, 'repo', '.cindy-worktrees', 'one'),+ baseRepo: path.join(state.root, 'repo'), branch: 'cindy/one', sourceBranch: 'main', createdAt: new Date().toISOString(),+ });it('detects atomic replacements from an independent file writer', async () => {const changed = vi.fn(); const error = vi.fn();@@ -25,4 +34,55 @@ describe('native worktree journal watcher', () => {await vi.waitFor(() => expect(changed).toHaveBeenCalled());expect(error).not.toHaveBeenCalled();});++ it('publishes pre-upgrade requests on watcher startup and reads later owner progress directly', async () => {+ state.userData = path.join(state.root, 'custom-owner-profile');+ const ownerRoot = recycleJournalRoot();+ const record = await recordFor();+ record.phase = 'removing';+ await fs.mkdir(ownerRoot, { recursive: true });+ const file = path.join(ownerRoot, `${record.id}.json`);+ await fs.writeFile(file, JSON.stringify(record));+ stop = await watchRecycleJournal(vi.fn(), vi.fn());+ state.userData = path.join(state.root, 'borrower-profile');+ expect(await readRecycleRecordsAcrossProfiles(record.meta.path)).toEqual([record]);+ // The owner can finish using the original journal protocol without updating a mirror.+ record.phase = 'restored';+ await fs.writeFile(`${file}.tmp`, JSON.stringify(record));+ await fs.rename(`${file}.tmp`, file);+ expect(await readRecycleRecordsAcrossProfiles(record.meta.path)).toEqual([record]);+ });++ it('keeps different profiles current records independent for the same resource', async () => {+ const record = await recordFor();+ await withWorktreeResourceLock(record.meta.path, () => writeRecycleRecord(record));+ state.userData = path.join(state.root, 'second-owner');+ const other = { ...record, phase: 'restored' as const, generation: 'other-generation' };+ await withWorktreeResourceLock(record.meta.path, () => writeRecycleRecord(other));+ state.userData = path.join(state.root, 'borrower');+ expect(await readRecycleRecordsAcrossProfiles(record.meta.path)).toEqual(expect.arrayContaining([record, other]));+ expect(await readRecycleRecordsAcrossProfiles(record.meta.path)).toHaveLength(2);+ });++ it('preserves and rejects malformed owner evidence without reading unrelated resource records', async () => {+ const record = await recordFor();+ await withWorktreeResourceLock(record.meta.path, () => writeRecycleRecord(record));+ const file = path.join(recycleJournalRoot(), `${record.id}.json`);+ await fs.writeFile(file, '{');+ state.userData = path.join(state.root, 'borrower');+ await expect(readRecycleRecordsAcrossProfiles(record.meta.path)).rejects.toThrow();+ expect(await readRecycleRecordsAcrossProfiles(path.join(state.root, 'different-resource'))).toEqual([]);+ expect(await fs.readFile(file, 'utf8')).toBe('{');+ });++ it('does not commit a recycle intent if publishing its location fails', async () => {+ const record = await recordFor();+ const rename = fs.rename.bind(fs);+ vi.spyOn(fs, 'rename').mockImplementation(async (source, target) => {+ if (String(target).includes('shared-worktree-recycle-journals')) throw Object.assign(new Error('unavailable'), { code: 'EIO' });+ return rename(source, target);+ });+ await expect(withWorktreeResourceLock(record.meta.path, () => writeRecycleRecord(record))).rejects.toMatchObject({ code: 'EIO' });+ await expect(fs.stat(path.join(recycleJournalRoot(), `${record.id}.json`))).rejects.toMatchObject({ code: 'ENOENT' });+ });});diff --git a/apps/desktop/src/main/__tests__/worktreeRecycleJournalWatch.test.ts b/apps/desktop/src/main/__tests__/worktreeRecycleJournalWatch.test.tsindex 7bf4f32eaf..0449011a63 100644--- a/apps/desktop/src/main/__tests__/worktreeRecycleJournalWatch.test.ts+++ b/apps/desktop/src/main/__tests__/worktreeRecycleJournalWatch.test.ts@@ -1,12 +1,12 @@import { beforeEach, describe, expect, it, vi } from 'vitest';import path from 'node:path';-const mocks = vi.hoisted(() => ({ watch: vi.fn(), mkdir: vi.fn(), close: vi.fn(), on: vi.fn() }));+const mocks = vi.hoisted(() => ({ watch: vi.fn(), mkdir: vi.fn(), open: vi.fn(), rename: vi.fn(), rm: vi.fn(), close: vi.fn(), on: vi.fn() }));vi.mock('electron', () => ({ app: { getPath: () => path.resolve('test-user-data') } }));vi.mock('node:fs', async (original) => ({ ...await original<typeof import('node:fs')>(), watch: mocks.watch }));vi.mock('node:fs/promises', async (original) => {const fs = await original<typeof import('node:fs/promises')>();- return { ...fs, default: { ...fs, mkdir: mocks.mkdir } };+ return { ...fs, default: { ...fs, mkdir: mocks.mkdir, open: mocks.open, rename: mocks.rename, rm: mocks.rm } };});import { watchRecycleJournal } from '../worktree/recycleJournal';@@ -14,6 +14,9 @@ describe('worktree journal notifications', () => {beforeEach(() => {vi.clearAllMocks();mocks.mkdir.mockResolvedValue(undefined);+ mocks.open.mockResolvedValue({ writeFile: async () => {}, sync: async () => {}, close: async () => {} });+ mocks.rename.mockResolvedValue(undefined);+ mocks.rm.mockResolvedValue(undefined);mocks.watch.mockReturnValue({ on: mocks.on, close: mocks.close });});it('listens for atomic journal replacements without watching recovery archive writes', async () => {diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.tsindex 7b45e9af36..b9b3ca5373 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.ts@@ -341,7 +341,12 @@ describe('iOS Simulator host', () => {}const sourceApp = path.join(root, 'Demo.app');await mkdir(sourceApp);- const getPath = vi.spyOn(app, 'getPath').mockReturnValue(userData);+ let activeProfile = userData;+ const getPath = vi.spyOn(app, 'getPath').mockImplementation((name) => name === 'appData' ? path.join(root, 'app-data') : activeProfile);+ const useProfile = async (name: string) => {+ activeProfile = path.join(root, name);+ await mkdir(path.join(activeProfile, '.dev-instances'), { recursive: true });+ };const actor = new IOSSimulatorInstanceActor({store: new IOSSimulatorOwnershipStore({ createId: () => crypto.randomUUID() }),lifecycle: {@@ -396,7 +401,7 @@ describe('iOS Simulator host', () => {generation: attachedInstance.generation, leaseId: attachedInstance.lease.id,});const route = { instanceId: instance.instanceId, generation: instance.generation, leaseId: instance.lease.id };- return { root, taskRoot, otherTaskRoot, projectRoot, secondDevice, actor, host, context, route, build, inspect, inspectArtifact, installExact, launchExact, validateLaunch, close };+ return { root, taskRoot, otherTaskRoot, projectRoot, secondDevice, actor, host, context, route, build, inspect, inspectArtifact, installExact, launchExact, validateLaunch, useProfile, close };} catch (error) {await close();throw error;@@ -557,6 +562,68 @@ describe('iOS Simulator host', () => {}});+ it.each([+ ['build_app', 'pending'], ['build_app', 'snapshotted'], ['build_app', 'removing'],+ ['build_app', 'restoring'],+ ['launch_app', 'pending'], ['launch_app', 'snapshotted'], ['launch_app', 'removing'],+ ['launch_app', 'restoring'],+ ] as const)('rejects %s when another profile left the source in %s recycling', async (tool, phase) => {+ const h = await projectSelectionHarness(tool === 'launch_app');+ try {+ let artifactId: string | undefined;+ if (tool === 'launch_app') {+ expect(await h.host.callTool('build_app', { ...h.route, projectDir: h.projectRoot }, h.context)).toMatchObject({ ok: true });+ artifactId = (await h.inspectArtifact.mock.results[0]!.value).artifactId;+ expect(await h.host.callTool('install_app', { ...h.route, artifactId }, h.context)).toMatchObject({ ok: true });+ }+ await h.useProfile('owner-data');+ const record = await newRecycleRecord({+ sessionId: 'session-b', name: 'project-b', path: h.projectRoot, baseRepo: h.root,+ branch: 'codex/project-b', sourceBranch: 'main', createdAt: new Date().toISOString(),+ });+ const identity = await stat(h.projectRoot);+ record.directoryIdentity = phase === 'restoring' ? null : `${identity.dev}:${identity.ino}:${identity.birthtimeMs}`;+ record.phase = phase;+ await withWorktreeResourceLock(h.projectRoot, () => writeRecycleRecord(record));+ const journal = path.join(h.root, 'owner-data', 'worktree-recycle', `${record.id}.json`);+ const evidence = await readFile(journal, 'utf8');+ await h.useProfile('user-data');+ h.build.mockClear(); h.inspect.mockClear();++ expect(await h.host.callTool(tool, { ...h.route, projectDir: h.projectRoot, artifactId, args: [] }, h.context))+ .toMatchObject({ ok: false, errorCode: 'MUTATION_CANCELLED' });+ expect(h.inspect).not.toHaveBeenCalled();+ expect(h.build).not.toHaveBeenCalled();+ expect(h.validateLaunch).not.toHaveBeenCalled();+ expect(h.launchExact).not.toHaveBeenCalled();+ expect(await readWorktreeRuntimePaths()).toEqual(new Set());+ expect(await readFile(journal, 'utf8')).toBe(evidence);+ } finally { await h.close(); }+ });++ it.each(['removed', 'restored', 'replacement'] as const)('allows borrowing after an owner journal is %s', async (phase) => {+ const h = await projectSelectionHarness();+ try {+ await h.useProfile('owner-data');+ const record = await newRecycleRecord({+ sessionId: 'session-b', name: 'project-b', path: h.projectRoot, baseRepo: h.root,+ branch: 'codex/project-b', sourceBranch: 'main', createdAt: new Date().toISOString(),+ });+ const identity = await stat(h.projectRoot);+ record.directoryIdentity = `${identity.dev}:${identity.ino}:${identity.birthtimeMs}`;+ record.phase = phase === 'replacement' ? 'pending' : phase;+ await withWorktreeResourceLock(h.projectRoot, () => writeRecycleRecord(record));+ if (phase === 'replacement') {+ await fsp.rename(h.projectRoot, `${h.projectRoot}-old`);+ await mkdir(path.join(h.projectRoot, 'Demo.xcodeproj'), { recursive: true });+ }+ await h.useProfile('user-data');+ expect(await h.host.callTool('build_app', { ...h.route, projectDir: h.projectRoot }, h.context)).toMatchObject({ ok: true });+ expect(h.build).toHaveBeenCalledOnce();+ expect(await readWorktreeRuntimePaths()).toEqual(new Set());+ } finally { await h.close(); }+ });+it.each(['source-recycle', 'task-cancel'] as const)('keeps B protected until the external build drains after %s', async (reason) => {const h = await projectSelectionHarness();let unblock: () => void = () => undefined;diff --git a/apps/desktop/src/main/mcp-integrations/ios-simulator-project-source.ts b/apps/desktop/src/main/mcp-integrations/ios-simulator-project-source.tsindex 8404467d42..802783cedf 100644--- a/apps/desktop/src/main/mcp-integrations/ios-simulator-project-source.ts+++ b/apps/desktop/src/main/mcp-integrations/ios-simulator-project-source.ts@@ -5,7 +5,7 @@ import { IOSSimulatorInstanceError } from '@cindy/ios-simulator-runtime';import { createLogger } from '../logger';import { subscribeWorktreeRecycleEvents } from '../worktree/recycleEvents';-import { readRecycleRecord } from '../worktree/recycleJournal';+import { readRecycleRecordsAcrossProfiles } from '../worktree/recycleJournal';import { withWorktreeResourceLock, worktreeResourceId } from '../worktree/resourceLock';import {acquireWorktreeRuntimeLease,@@ -41,6 +41,17 @@ export async function acquireIOSSimulatorProjectUse(if (!available) {throw new IOSSimulatorInstanceError('INVALID_ARGUMENT', 'The selected project directory is unavailable.');}+ // Check the owner's authoritative intent before publishing a lease that could+ // otherwise obstruct recovery of a partially removed directory.+ const records = await readRecycleRecordsAcrossProfiles(managedRoot);+ const identity = await stat(managedRoot);+ if (records.some((record) => !['removed', 'restored'].includes(record.phase)+ && (record.directoryIdentity === `${identity.dev}:${identity.ino}:${identity.birthtimeMs}`+ || (record.phase === 'restoring' && record.directoryIdentity == null)))) {+ controller.abort();+ throw new IOSSimulatorInstanceError('MUTATION_CANCELLED', 'The selected project worktree is being recycled or restored.', true);+ }+ signal.throwIfAborted();const lease = await acquireWorktreeRuntimeLease(`ios-simulator:${sessionId}`, projectRoot, { crossProfile: true });if (!lease) return null;const resourceId = worktreeResourceId(lease.physicalPath);@@ -57,19 +68,7 @@ export async function acquireIOSSimulatorProjectUse(log.warn('project worktree lease release deferred');}};- try {- const record = await readRecycleRecord(managedRoot);- if (record && !['removed', 'restored'].includes(record.phase)) {- const identity = await stat(managedRoot);- if (record.directoryIdentity === `${identity.dev}:${identity.ino}:${identity.birthtimeMs}`) {- controller.abort();- }- }- return release;- } catch (error) {- await release();- throw error;- }+ return release;}, signal).catch((error) => {if (signal.aborted) {throw new IOSSimulatorInstanceError('MUTATION_CANCELLED', 'The app operation was cancelled while acquiring its project worktree.', true);diff --git a/apps/desktop/src/main/worktree/recycleJournal.ts b/apps/desktop/src/main/worktree/recycleJournal.tsindex 780890fc3a..23451b0d65 100644--- a/apps/desktop/src/main/worktree/recycleJournal.ts+++ b/apps/desktop/src/main/worktree/recycleJournal.ts@@ -36,6 +36,18 @@ export function recycleJournalRoot(): string {return path.join(app.getPath('userData'), 'worktree-recycle');}+function sharedJournalLocationsRoot(): string {+ return path.join(app.getPath('appData'), 'Cindy', 'shared-worktree-recycle-journals');+}++/** Publish a locator, not a second copy of mutable recovery state. */+async function publishJournalLocation(root: string): Promise<void> {+ const directory = sharedJournalLocationsRoot();+ const id = createHash('sha256').update(root).digest('hex');+ await fs.mkdir(directory, { recursive: true });+ await writeRecordFile(path.join(directory, `${id}.json`), { version: 1, root });+}+export function worktreeGeneration(meta: WorktreeMeta): string {return meta.generation ?? `${meta.sessionId}:${meta.createdAt}`;}@@ -81,11 +93,43 @@ export async function readRecycleRecord(value: string, sessionId?: string): Prom}}+/** Borrowing reads each profile's authoritative current record; it never owns their recovery. */+export async function readRecycleRecordsAcrossProfiles(value: string): Promise<WorktreeRecycleRecord[]> {+ const id = worktreeResourceId(await physicalWorktreeKey(value));+ const roots = new Set([recycleJournalRoot()]);+ const directory = sharedJournalLocationsRoot();+ let names: string[];+ try { names = await fs.readdir(directory); } catch (error) {+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;+ names = [];+ }+ for (const name of names.filter((name) => /^[a-f0-9]{64}\.json$/.test(name))) {+ const location = JSON.parse(await fs.readFile(path.join(directory, name), 'utf8')) as { version?: number; root?: string };+ if (location.version !== 1 || typeof location.root !== 'string' || !path.isAbsolute(location.root)+ || path.basename(location.root) !== 'worktree-recycle'+ || createHash('sha256').update(location.root).digest('hex') !== name.slice(0, -5)) {+ throw new Error('invalid worktree recycle journal location');+ }+ roots.add(location.root);+ }+ const records: WorktreeRecycleRecord[] = [];+ for (const root of roots) {+ try {+ records.push(parseRecord(await fs.readFile(path.join(root, `${id}.json`), 'utf8'), id));+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;+ }+ }+ return records;+}+/** Caller holds the physical resource lock. Atomic per-resource files cannot lose another resource's update. */export async function writeRecycleRecord(record: WorktreeRecycleRecord): Promise<void> {if (!/^[a-f0-9]{64}$/.test(record.id)) throw new Error('invalid worktree resource id');const root = recycleJournalRoot();await fs.mkdir(root, { recursive: true });+ // Must be discoverable before committing an intent that permits destructive I/O.+ await publishJournalLocation(root);if (record.archive && record.snapshot && record.phase === 'removed') {const history = path.join(root, 'history');await fs.mkdir(history, { recursive: true });@@ -100,6 +144,8 @@ export async function writeRecycleRecord(record: WorktreeRecycleRecord): Promiseexport async function watchRecycleJournal(onChange: () => void, onError: (error: unknown) => void): Promise<() => void> {const root = recycleJournalRoot();await fs.mkdir(root, { recursive: true });+ // Expose pre-upgrade requests too, even when their retry deadline is in the future.+ await publishJournalLocation(root);const watcher = watch(root, { persistent: false }, (_event, filename) => {if (filename === null || /^[a-f0-9]{64}\.json$/.test(filename.toString())) onChange();});@@ -107,7 +153,7 @@ export async function watchRecycleJournal(onChange: () => void, onError: (error:return () => watcher.close();}-async function writeRecordFile(target: string, record: WorktreeRecycleRecord): Promise<void> {+async function writeRecordFile(target: string, record: WorktreeRecycleRecord | { version: 1; root: string }): Promise<void> {const temp = `${target}.${randomUUID()}.tmp`;try {const handle = await fs.open(temp, 'wx', 0o600);diff --git a/docs/dev-rules/credentials-and-local-storage.md b/docs/dev-rules/credentials-and-local-storage.mdindex 2e1413e324..45189ca82c 100644--- a/docs/dev-rules/credentials-and-local-storage.md+++ b/docs/dev-rules/credentials-and-local-storage.md@@ -71,6 +71,7 @@| Skill 卸载清理回执 | `app.getPath('userData')/skillhub/uninstall-cleanups/<token>.json`,记录操作 owner、旧文件/注册/偏好身份与完成阶段;跨窗口和重启保留,当前 owner 重试完成后删除,不作为授权凭据 || 跨 profile 的共享 Skill 文件互斥 | `app.getPath('appData')/Cindy/shared-skill-mutation-locks`,仅存文件锁及未完成操作的 token/名称哈希,保证正式版/dev/isolated 共用;短期锁复用既有崩溃回收,持久屏障必须等对应清理完成后删除,读取损坏只阻止相关名称 || 跨 profile 的 worktree 借用租约 | `app.getPath('appData')/Cindy/shared-worktree-runtime-leases`,模拟器工程借用时在原 profile 租约之外发布共享副本;回收器同时读取两处,源目录 I/O 结束后显式释放,释放失败由现有 `.release` 回执重试;不能因进程退出就移除保护 |+| 跨 profile 的 worktree 回收日志位置 | `app.getPath('appData')/Cindy/shared-worktree-recycle-journals`,按日志目录哈希登记原 profile 日志位置,启动日志监听和写入回收记录前原子发布;借用方只读目标资源的原始日志,不复制恢复状态、不代替 owner 执行恢复。索引跨重启保留,原日志不存在时不产生回收意图 || 用户明确导出的文件 | 用户选择或任务明确指定的目标路径 |- 禁止把 `process.cwd()`、仓库根或源码目录作为 userData、凭证目录或临时目录的默认回退。diff --git a/docs/ios-simulator-integration-plan.md b/docs/ios-simulator-integration-plan.mdindex e9d1191584..a57f2ba784 100644--- a/docs/ios-simulator-integration-plan.md+++ b/docs/ios-simulator-integration-plan.md@@ -1029,7 +1029,12 @@ fingerprint 和相对 container 路径;该 fingerprint 不代表 Git revision模拟器借用会同时发布 profile 内租约和 `appData/Cindy/shared-worktree-runtime-leases`中的共享副本,回收器合并读取两处,避免隔离 profile 之间看不到对方的借用;释放失败沿用 `.release` 回执重试,进程退出本身不能证明 Xcode 或 Metro 已停止读取。-跨 profile 借用要求回收方也运行包含共享租约读取支持的版本;profile 内副本保留原读取协议。+借用前还在同一资源锁内,经 `appData/Cindy/shared-worktree-recycle-journals` 登记的日志位置+读取各 profile 对该目录的原始回收记录;当前目录处于待回收、快照、删除或恢复阶段时,+在发布租约前拒绝构建/启动,避免使用残缺目录或阻挡 owner 恢复。完成的记录或旧目录身份+不阻止新目录使用。日志监听启动时登记既有日志,写入新意图前也必须完成登记;共享索引+只保存日志位置,不复制状态、不改变原 profile 的日志格式和恢复归属。+跨 profile 借用要求回收方也运行包含共享租约读取及日志登记支持的版本;profile 内副本保留原读取协议。任务 A 结束时排空自己的操作,不因其构建了 B 就把 B 加入 A 的目录删除范围。这仍是工程选择与目录边界校验,不是对 Xcode build scripts 的文件系统沙箱。