@bastani/atomic 0.9.89-alpha.1 → 0.9.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +289 -0
- package/dist/builtin/intercom/CHANGELOG.md +31 -0
- package/dist/builtin/intercom/broker/broker-instance.ts +15 -1
- package/dist/builtin/intercom/broker/broker.ts +25 -8
- package/dist/builtin/intercom/broker/client.ts +29 -14
- package/dist/builtin/intercom/broker/multinode-router.ts +193 -52
- package/dist/builtin/intercom/broker/multinode-state-store.ts +6 -2
- package/dist/builtin/intercom/broker/restoring-recipients.ts +5 -0
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +3 -2
- package/dist/builtin/intercom/index.bundle.mjs +19 -12
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/types.ts +6 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +45 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +17 -6
- package/dist/builtin/web-access/CHANGELOG.md +11 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +106 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +310 -344
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +99 -17
- package/dist/builtin/workflows/src/index.js +99 -17
- package/dist/builtin/workflows/src/local-worker-entry.mjs +99 -17
- package/dist/cli/storage-command.js +8 -0
- package/dist/cli/storage-command.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts.map +1 -1
- package/dist/core/auth-storage-backends.js +1 -0
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/keybindings.d.ts +8 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/process-start-token.d.ts.map +1 -1
- package/dist/core/process-start-token.js +8 -1
- package/dist/core/process-start-token.js.map +1 -1
- package/dist/core/resume/blueprint/build-lock.d.ts.map +1 -1
- package/dist/core/resume/blueprint/build-lock.js +2 -1
- package/dist/core/resume/blueprint/build-lock.js.map +1 -1
- package/dist/core/storage/errors.d.ts +4 -2
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js +6 -1
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +5 -0
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +13 -0
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +1 -2
- package/dist/core/tools/shell-task-render.d.ts.map +1 -1
- package/dist/core/tools/shell-task-render.js +3 -7
- package/dist/core/tools/shell-task-render.js.map +1 -1
- package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
- package/dist/core/tools/windows-directory-security.js +3 -11
- package/dist/core/tools/windows-directory-security.js.map +1 -1
- package/dist/core/worktree-snapshot/capture.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/capture.js +25 -1
- package/dist/core/worktree-snapshot/capture.js.map +1 -1
- package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/restore.js +38 -9
- package/dist/core/worktree-snapshot/restore.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +5 -0
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +13 -0
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +5 -2
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/heartbeat-block.d.ts +34 -0
- package/dist/modes/interactive/components/heartbeat-block.d.ts.map +1 -0
- package/dist/modes/interactive/components/heartbeat-block.js +50 -0
- package/dist/modes/interactive/components/heartbeat-block.js.map +1 -0
- package/dist/modes/interactive/components/input-label.d.ts.map +1 -1
- package/dist/modes/interactive/components/input-label.js +8 -3
- package/dist/modes/interactive/components/input-label.js.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.js +3 -7
- package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +13 -7
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +10 -2
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +13 -3
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -1
- package/dist/modes/interactive/components/provider-brand.js +3 -0
- package/dist/modes/interactive/components/provider-brand.js.map +1 -1
- package/dist/modes/interactive/components/task-heartbeat-message.d.ts +9 -4
- package/dist/modes/interactive/components/task-heartbeat-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-heartbeat-message.js +33 -27
- package/dist/modes/interactive/components/task-heartbeat-message.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts +16 -0
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +95 -4
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-list.d.ts +5 -1
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-list.js +20 -3
- package/dist/modes/interactive/components/task-list.js.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +10 -7
- package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -2
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/color-utils.d.ts +29 -1
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
- package/dist/modes/interactive/theme/color-utils.js +81 -7
- package/dist/modes/interactive/theme/color-utils.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +3 -0
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +22 -2
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +64 -18
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -0
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +2 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +6 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +170 -15
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/windows-powershell.d.ts +9 -0
- package/dist/utils/windows-powershell.d.ts.map +1 -0
- package/dist/utils/windows-powershell.js +16 -0
- package/dist/utils/windows-powershell.js.map +1 -0
- package/docs/background-tasks.md +6 -6
- package/docs/getting-started/installation.md +4 -2
- package/docs/keybindings.md +3 -0
- package/docs/storage.md +24 -5
- package/docs/subagents.md +1 -1
- package/docs/themes/reference.md +7 -0
- package/docs/tui/reference.md +1 -1
- package/docs/windows.md +1 -1
- package/docs/workflows/api-reference.md +9 -1
- package/docs/workflows/operations.md +1 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
- package/schemas/keybindings.schema.json +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/restore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAc,MAAM,SAAS,CAAC;AACjD,OAAO,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,KAAK,EACL,IAAI,EACJ,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,E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AM,IAAI,mBAAmB,CAAC;YAC7B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,YAAY,EAAE,OAAO,CAAC,IAAI;YAC1B,UAAU,EAAE,QAAQ,CAAC,IAAI;YACzB,YAAY,EAAE,OAAO,CAAC,IAAI;YAC1B,UAAU,EAAE,KAAK,CAAC,IAAI;YACtB,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;SACnD,CAAC,CAAC;IACJ,CAAC;IACD,OAAO;QACN,OAAO,EAAE,CAAC,MAAM,oBAAoB,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QAC5E,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,MAAM,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC;KACpD,CAAC;AACH,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { existsSync, type Stats } from \"node:fs\";\nimport {\n\tlstat,\n\tmkdir,\n\topen,\n\treaddir,\n\treadFile,\n\treadlink,\n\trealpath,\n\trm,\n\trmdir,\n\tstat,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { devNull } from \"node:os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { setTimeout as sleep } from \"node:timers/promises\";\nimport { pathToFileURL } from \"node:url\";\nimport { pathExists } from \"../../utils/path-exists.ts\";\nimport { releaseLock } from \"../lock-release.ts\";\nimport { takeTakeoverMutexAsync } from \"../lock-takeover.js\";\nimport { renameWithRetry } from \"../rename-retry.ts\";\nimport { deferRestorePhase, noteRestoreFetch, timeRestorePhase } from \"../resume/timings.ts\";\nimport {\n\tlocateCheckout,\n\tRESTORED_TREE_FILE,\n\treadRepositoryConfig,\n\trecordRestoredTree,\n\twithScratchDirectory,\n\twriteSnapshotCommit,\n\twriteWorkingTree,\n} from \"./capture.ts\";\nimport { computeEnvironmentHash, sha256Hex } from \"./env-hash.ts\";\nimport {\n\tisWorkspaceGitError,\n\tisWorkspaceRestoreError,\n\tunreadablePathError,\n\tunwritablePathError,\n\tWorkspaceConfigError,\n\tWorkspaceDriftError,\n\tWorkspaceGitError,\n\tWorkspaceRestoreError,\n\ttype WorkspaceRestoreErrorFields,\n} from \"./errors.ts\";\nimport {\n\ttype GitExecutable,\n\ttype GitRunOptions,\n\ttype GitRunResult,\n\tgitText,\n\tnulFields,\n\trunGit,\n\twithWorktreeSnapshotGit,\n} from \"./git.ts\";\nimport {\n\tassertRestorePathBudget,\n\tcanonicalizeWorktreePathAsync,\n\tdefaultWorktreeSnapshotStoreDir,\n\tstagingWorktreeName,\n} from \"./paths.ts\";\nimport { loadSnapshotPathPolicy } from \"./policy.ts\";\nimport { HOST, holderRuns, type ProcessHolder, thisProcess } from \"./process-holder.js\";\nimport { assertUsableBundlePrerequisites, assertUsableSnapshotRecord, isAllowedRemote } from \"./records.ts\";\nimport { checkoutStoreIdOf, sameRemote, sharedRepositoryIdsOf } from \"./repository-identity.ts\";\nimport {\n\tDEFAULT_WORKTREE_SNAPSHOT_SETTINGS,\n\tresolveWorktreeSnapshotSettings,\n\ttype WorktreeSnapshotSettingsInput,\n} from \"./settings.ts\";\nimport { lockShared } from \"./shared-clock.ts\";\nimport type {\n\tSnapshotBlobStore,\n\tWorkspaceBinding,\n\tWorktreeDegradedRestore,\n\tWorktreeDegradedRestoreBasis,\n\tWorktreeRestoreWarning,\n\tWorktreeSnapshot,\n} from \"./types.ts\";\n\nexport interface RestoreWorktreeSnapshotOptions {\n\t/** New or empty directory for the restored worktree. Default: a new directory under `storeDir`/worktrees. */\n\treadonly into?: string;\n\t/** Blob storage holding the snapshot's patches and bundle. Required when the snapshot has any. */\n\treadonly blobs?: SnapshotBlobStore;\n\t/** Recorded snapshots to search when restoring a binding. */\n\treadonly snapshots?: readonly WorktreeSnapshot[];\n\t/** Host directory for the shared per-repository object stores and default worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\treadonly onWarning?: (warning: WorktreeRestoreWarning) => void;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Takes the Git LFS download of an exact restore off the restore (#5099): the restore verifies and publishes the\n\t * worktree with its LFS files still holding pointers, then hands `pull` to this callback instead of downloading.\n\t * `pull` downloads the objects into `worktree` as the restore would have, and resolves to the files that still hold\n\t * pointers, for which the restore would have warned `lfs-objects-unavailable`. A degraded restore still downloads\n\t * before it records the tree it holds.\n\t */\n\treadonly deferLfs?: (worktree: string, pull: () => Promise<readonly string[]>) => void;\n\t/**\n\t * The Git this restore runs, with the environment it needs. Default: the Git every snapshot operation resolves,\n\t * provisioned when this machine has none.\n\t */\n\treadonly git?: GitExecutable;\n}\n\nexport interface RestoredWorktree {\n\treadonly path: string;\n\treadonly snapshot: WorktreeSnapshot | null;\n\treadonly binding: WorkspaceBinding;\n\treadonly warnings: readonly WorktreeRestoreWarning[];\n}\n\n/** The warnings a restore of `snapshot` reports from its record: omitted content and source conversion settings. */\nexport function snapshotRestoreWarnings(snapshot: WorktreeSnapshot): WorktreeRestoreWarning[] {\n\treturn [\n\t\t...(snapshot.omitted.length > 0 ? [{ code: \"omitted-content\" as const, omitted: snapshot.omitted }] : []),\n\t\t...(snapshot.filters ? [{ code: \"filters\" as const, filters: snapshot.filters }] : []),\n\t];\n}\n\nexport { defaultWorktreeSnapshotStoreDir };\n\nfunction isBinding(value: unknown): value is WorkspaceBinding {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as Partial<WorkspaceBinding>;\n\treturn (\n\t\tArray.isArray(candidate.remotes) &&\n\t\tcandidate.remotes.every((remote) => typeof remote === \"string\") &&\n\t\ttypeof candidate.head === \"string\" &&\n\t\ttypeof candidate.tree === \"string\" &&\n\t\ttypeof candidate.envHash === \"string\"\n\t);\n}\n\nfunction isSnapshot(value: unknown): value is WorktreeSnapshot {\n\treturn (\n\t\tisBinding(value) &&\n\t\t(value as Partial<WorktreeSnapshot>).version === 1 &&\n\t\tArray.isArray((value as Partial<WorktreeSnapshot>).chain) &&\n\t\ttypeof (value as Partial<WorktreeSnapshot>).id === \"string\"\n\t);\n}\n\n/** Lowercase hex digest of a blob, compared with its recorded hash before Git sees its bytes. */\nasync function loadBlob(\n\tstore: SnapshotBlobStore | undefined,\n\thash: string,\n\tfields: Pick<WorkspaceRestoreErrorFields, \"snapshotId\" | \"role\" | \"deltaIndex\">,\n): Promise<Uint8Array> {\n\tconst data = await store?.getBlob(hash);\n\tif (data === undefined) throw new WorkspaceRestoreError(\"blob-missing\", { ...fields, blob: hash });\n\tif (sha256Hex(data) !== hash) throw new WorkspaceRestoreError(\"blob-corrupt\", { ...fields, blob: hash });\n\treturn data;\n}\n\nasync function checkTarget(target: string, snapshotId: string | null): Promise<void> {\n\tlet empty: boolean;\n\ttry {\n\t\tempty = (await stat(target)).isDirectory() && (await readdir(target)).length === 0;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw unreadablePathError(target, error);\n\t\tif (await belowRegularFile(target)) throw unreadablePathError(target, error);\n\t\treturn;\n\t}\n\tif (!empty) throw new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target, reason: \"not-empty\" });\n}\n\n/**\n * Whether the deepest existing ancestor of a missing `path` is not a directory. Linux reports such a path as\n * `ENOTDIR`, Windows as missing (`ENOENT`), so only its ancestors tell a path that could be created from one that cannot.\n */\nasync function belowRegularFile(path: string): Promise<boolean> {\n\tfor (let current = dirname(path); current !== dirname(current); current = dirname(current)) {\n\t\tconst entry = await statIfPresent(current);\n\t\tif (entry) return !entry.isDirectory();\n\t}\n\treturn false;\n}\n\n/** Which of `trees` the object store already holds, asked of Git in one process. */\nasync function storedTrees(git: GitRunOptions, trees: readonly string[]): Promise<Set<string>> {\n\tconst { stdout } = await runGit([\"cat-file\", \"--batch-check=%(objectname) %(objecttype)\"], {\n\t\t...git,\n\t\tinput: trees.map((tree) => `${tree}\\n`).join(\"\"),\n\t});\n\tconst stored = new Set<string>();\n\tfor (const line of stdout.toString(\"utf8\").split(\"\\n\")) {\n\t\tconst [name, type] = line.split(\" \");\n\t\tif (type === \"tree\" && name) stored.add(name);\n\t}\n\treturn stored;\n}\n\nasync function hasObject(git: GitRunOptions, object: string): Promise<boolean> {\n\tconst { exitCode } = await runGit([\"cat-file\", \"-e\", object], { ...git, allowExitCodes: [1, 128] });\n\treturn exitCode === 0;\n}\n\n/** Runs a filesystem write of `target`, reporting a filesystem failure as `unwritable-path`. */\nasync function writing<T>(target: string, snapshotId: string | null, write: () => Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await write();\n\t} catch (error) {\n\t\tthrow unwritablePathError(target, snapshotId, error);\n\t}\n}\n\nconst repositoryLocks = new Map<string, Promise<void>>();\n\n/** Serializes work on one shared object store within this process, ahead of its cross-process lock. */\nasync function withProcessRepositoryLock<T>(store: string, action: () => Promise<T>): Promise<T> {\n\tconst previous = repositoryLocks.get(store) ?? Promise.resolve();\n\tlet release!: () => void;\n\tconst current = new Promise<void>((resolveLock) => {\n\t\trelease = resolveLock;\n\t});\n\tconst chained = previous.then(() => current);\n\trepositoryLocks.set(store, chained);\n\tawait previous;\n\ttry {\n\t\treturn await action();\n\t} finally {\n\t\trelease();\n\t\tif (repositoryLocks.get(store) === chained) repositoryLocks.delete(store);\n\t}\n}\n\n/** The repository lock's constants: a stopped process loses it after 30 seconds; a held one is checked every 50 ms. */\nconst REPOSITORY_LOCK_STALE_MS = 30_000;\nconst REPOSITORY_LOCK_UPDATE_MS = 10_000;\nconst REPOSITORY_LOCK_POLL_MS = 50;\n/** How long, on Windows, the repository lock is tried again while its directory is refused with EPERM. */\nexport const REPOSITORY_LOCK_REFUSED_MS = 10_000;\n\n/**\n * Whether creating the lock directory failed only for a moment: Windows refuses with EPERM to create a directory\n * another process has just removed while a third still has it open, as other waiters' checks of the lock do.\n */\nfunction refusedForAMoment(error: unknown): boolean {\n\treturn (error as NodeJS.ErrnoException).code === \"EPERM\" && process.platform === \"win32\";\n}\n\n/**\n * Serializes work on one shared object store, in this process and across processes (#4951): creating the store,\n * configuring its remotes, fetching into it and updating its refs. Git's own locks fail rather than wait, so two\n * processes doing either at once would fail one of them. Waiters in this process queue behind each other; across\n * processes, the store's lock file `<store>.lock` is polled until it is free or its holder stopped refreshing it. On\n * Windows a lock directory refused with EPERM is polled too, for up to {@link REPOSITORY_LOCK_REFUSED_MS} on end.\n */\nfunction withRepositoryLock<T>(\n\tstore: string,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n\taction: () => Promise<T>,\n): Promise<T> {\n\treturn withProcessRepositoryLock(store, async () => {\n\t\tconst unlock = await lockRepository(store, snapshotId, signal);\n\t\ttry {\n\t\t\treturn await action();\n\t\t} finally {\n\t\t\t// A release that fails leaves a lock file nothing refreshes, which the next waiter takes once it is stale.\n\t\t\tawait releaseLock(unlock, store);\n\t\t}\n\t});\n}\n\n/** Takes the cross-process lock of `store`, waiting while another live process holds it. */\nasync function lockRepository(\n\tstore: string,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n): Promise<() => Promise<void>> {\n\tconst repositories = dirname(store);\n\tawait writing(repositories, snapshotId, () => mkdir(repositories, { recursive: true }));\n\tlet refusedSince: number | undefined;\n\tfor (;;) {\n\t\tsignal?.throwIfAborted();\n\t\ttry {\n\t\t\treturn await lockShared(store, {\n\t\t\t\trealpath: false,\n\t\t\t\tstale: REPOSITORY_LOCK_STALE_MS,\n\t\t\t\tupdate: REPOSITORY_LOCK_UPDATE_MS,\n\t\t\t\tretries: 0,\n\t\t\t\t// A lost lock only lets another process into the store early, where Git's own locks still guard each write.\n\t\t\t\tonCompromised: () => {},\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (refusedForAMoment(error)) {\n\t\t\t\trefusedSince ??= Date.now();\n\t\t\t\t// A refusal that lasts is a directory this process may not write to.\n\t\t\t\tif (Date.now() - refusedSince >= REPOSITORY_LOCK_REFUSED_MS)\n\t\t\t\t\tthrow unwritablePathError(`${store}.lock`, snapshotId, error);\n\t\t\t} else if ((error as NodeJS.ErrnoException).code === \"ELOCKED\") {\n\t\t\t\trefusedSince = undefined;\n\t\t\t} else {\n\t\t\t\tthrow unwritablePathError(`${store}.lock`, snapshotId, error);\n\t\t\t}\n\t\t}\n\t\tawait sleep(REPOSITORY_LOCK_POLL_MS);\n\t}\n}\n\n/** A stopped process loses its restore lock after 30 seconds; active processes refresh it every 10 seconds. */\nconst RESTORE_LOCK_STALE_MS = 30_000;\nconst RESTORE_LOCK_UPDATE_MS = 10_000;\n\ninterface RestoreRecord {\n\treadonly staging: string;\n\treadonly target: string;\n\treadonly store: string;\n\treadonly createdTarget: boolean;\n\t/** The tree this restore checks out into its staging worktree. Records of earlier versions have none. */\n\treadonly tree?: string;\n\t/**\n\t * The identity of the staging directory as `git worktree add` created it, recorded right after, under the store lock.\n\t * A directory is set aside or deleted as this restore's only while it is that same directory: copying or moving\n\t * other files to its path never makes another directory look like it. Missing until it was recorded.\n\t */\n\treadonly identity?: DirectoryIdentity;\n}\n\n/** A directory's device, inode (a Windows file ID) and birth time, as decimal strings: what no other directory shares. */\ninterface DirectoryIdentity {\n\treadonly dev: string;\n\treadonly ino: string;\n\treadonly birthtime: string;\n}\n\nfunction isDirectoryIdentity(value: unknown): value is DirectoryIdentity {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst identity = value as Partial<DirectoryIdentity>;\n\treturn [identity.dev, identity.ino, identity.birthtime].every(\n\t\t(field) => typeof field === \"string\" && /^\\d+$/.test(field),\n\t);\n}\n\n/** Validate crash records before using their paths. Only Atomic's staging name and per-repository store are valid. */\nfunction isRestoreRecord(value: unknown, storeDir: string, id: string): value is RestoreRecord {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst record = value as Partial<RestoreRecord>;\n\tif (\n\t\ttypeof record.staging !== \"string\" ||\n\t\ttypeof record.target !== \"string\" ||\n\t\ttypeof record.store !== \"string\" ||\n\t\ttypeof record.createdTarget !== \"boolean\" ||\n\t\t(record.tree !== undefined &&\n\t\t\t(typeof record.tree !== \"string\" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(record.tree))) ||\n\t\t(record.identity !== undefined && !isDirectoryIdentity(record.identity)) ||\n\t\tresolve(record.target) !== record.target ||\n\t\tresolve(record.staging) !== record.staging ||\n\t\tresolve(record.store) !== record.store ||\n\t\tdirname(record.store) !== join(storeDir, \"repositories\") ||\n\t\t!/^[0-9a-f]{24}\\.git$/.test(basename(record.store))\n\t)\n\t\treturn false;\n\t// Earlier versions named staging worktrees `.staging-<id>` and `.<target>.atomic-restore-<id>` (#5139).\n\tconst defaultStaging = [stagingWorktreeName(id), `.staging-${id}`].map((name) => join(storeDir, \"worktrees\", name));\n\tconst { staging, target } = record;\n\tconst siblingStaging = [stagingWorktreeName(id), `.atomic-restore-${id}`].map((suffix) =>\n\t\tjoin(dirname(target), `.${basename(target)}${suffix}`),\n\t);\n\treturn (\n\t\tsiblingStaging.includes(staging) ||\n\t\t(defaultStaging.includes(staging) && dirname(target) === join(storeDir, \"worktrees\"))\n\t);\n}\n\n/** Git's registered worktree paths, without shell quoting or newline ambiguity. */\nasync function registeredWorktrees(git: GitRunOptions): Promise<string[]> {\n\treturn nulFields((await runGit([\"worktree\", \"list\", \"--porcelain\", \"-z\"], git)).stdout)\n\t\t.filter((field) => field.startsWith(\"worktree \"))\n\t\t.map((field) => field.slice(\"worktree \".length));\n}\n\nfunction includesPath(paths: readonly string[], target: string): boolean {\n\tconst normalized = resolve(target);\n\treturn paths.some((path) => {\n\t\tconst candidate = resolve(path);\n\t\treturn process.platform === \"win32\"\n\t\t\t? candidate.toLowerCase() === normalized.toLowerCase()\n\t\t\t: candidate === normalized;\n\t});\n}\n\nasync function physicalPath(path: string): Promise<string> {\n\ttry {\n\t\treturn await realpath(path);\n\t} catch (error) {\n\t\tthrow unreadablePathError(path, error);\n\t}\n}\n\n/** The administrative directory the `.git` file of the directory at `path` names, or undefined when there is none. */\nasync function worktreeAdminDir(path: string): Promise<string | undefined> {\n\ttry {\n\t\tif (!(await lstat(path)).isDirectory()) return undefined;\n\t\tconst link = join(path, \".git\");\n\t\tif (!(await lstat(link)).isFile()) return undefined;\n\t\tconst named = /^gitdir: (.+)$/m.exec(await readFile(link, \"utf8\"));\n\t\treturn named === null ? undefined : await realpath(resolve(path, named[1]!.trim()));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The administrative directory of `store` that holds a worktree's own Git files, read through any symlink. */\nasync function storeAdminDirs(store: string): Promise<string | undefined> {\n\ttry {\n\t\treturn await realpath(join(store, \"worktrees\"));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The identity of the directory at `path` itself, never what a link there points to; undefined for anything else. */\nasync function directoryIdentity(path: string): Promise<DirectoryIdentity | undefined> {\n\tconst entry = await lstat(path, { bigint: true }).catch(() => undefined);\n\tif (!entry?.isDirectory()) return undefined;\n\treturn { dev: String(entry.dev), ino: String(entry.ino), birthtime: String(entry.birthtimeNs) };\n}\n\nfunction sameIdentity(a: DirectoryIdentity, b: DirectoryIdentity): boolean {\n\treturn a.dev === b.dev && a.ino === b.ino && a.birthtime === b.birthtime;\n}\n\n/**\n * How many files whose bytes differ from their blob, as a conversion at checkout leaves them, cleanup compares with what\n * the checkout writes before it keeps the worktree, set aside, instead: each takes a Git process.\n */\nconst MAX_CONVERTED_FILES_CHECKED = 1000;\n\n/** What a file a restore checked out holds, checked again right before the file is deleted. */\ntype RestoredEntry =\n\t| { readonly kind: \"file\"; readonly algorithm: \"sha1\" | \"sha256\"; readonly digest: string; readonly blob: boolean }\n\t| { readonly kind: \"link\"; readonly target: string }\n\t| { readonly kind: \"text\"; readonly content: string };\n\n/** The digest of the file at `path` under `algorithm`, as a Git blob of `size` bytes when `blob`, else of its bytes. */\nasync function digestOf(\n\tpath: string,\n\talgorithm: \"sha1\" | \"sha256\",\n\tblob: boolean,\n\tsize: bigint | number,\n): Promise<string> {\n\tconst hash = createHash(algorithm);\n\tif (blob) hash.update(`blob ${size}\\0`);\n\tconst handle = await open(path, \"r\");\n\ttry {\n\t\tfor await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk as Buffer);\n\t} finally {\n\t\tawait handle.close();\n\t}\n\treturn hash.digest(\"hex\");\n}\n\n/** The blobs `oids` of `store`, by id; an id the store does not hold as a blob is left out. */\nasync function storeBlobs(store: string, oids: readonly string[]): Promise<Map<string, Buffer>> {\n\tconst blobs = new Map<string, Buffer>();\n\tif (oids.length === 0) return blobs;\n\tconst output = (\n\t\tawait runGit([\"cat-file\", \"--batch\"], {\n\t\t\tcwd: dirname(store),\n\t\t\tenv: { GIT_DIR: store },\n\t\t\tinput: `${oids.join(\"\\n\")}\\n`,\n\t\t})\n\t).stdout;\n\tlet at = 0;\n\twhile (at < output.length) {\n\t\tconst end = output.indexOf(10, at);\n\t\tif (end < 0) break;\n\t\tconst [oid, type, size] = output.subarray(at, end).toString(\"utf8\").split(\" \");\n\t\tat = end + 1;\n\t\tif (type !== \"blob\" || oid === undefined) continue;\n\t\tconst length = Number(size);\n\t\tblobs.set(oid, output.subarray(at, at + length));\n\t\tat += length + 1;\n\t}\n\treturn blobs;\n}\n\n/** The Git LFS object a pointer blob names, or undefined when the blob is not a pointer. */\nfunction lfsObject(pointer: Buffer): { readonly oid: string; readonly size: number } | undefined {\n\tif (pointer.length > 1024) return undefined;\n\tconst text = pointer.toString(\"utf8\");\n\tif (!text.startsWith(\"version https://git-lfs.github.com/spec/v1\\n\")) return undefined;\n\tconst oid = /^oid sha256:([0-9a-f]{64})$/m.exec(text)?.[1];\n\tconst size = /^size (\\d+)$/m.exec(text)?.[1];\n\treturn oid === undefined || size === undefined ? undefined : { oid, size: Number(size) };\n}\n\n/**\n * The files of every tree a restore may have checked out into the worktree whose administrative directory is `admin`:\n * the record's `tree`, the tree the restore recorded there and the tree of its `HEAD`. All are in `store`, so a file\n * with one of their contents at its path is never lost when it is deleted.\n */\nasync function restoredTreeEntries(\n\tstore: string,\n\ttree: string | undefined,\n\tadmin: string | undefined,\n): Promise<Map<string, { readonly mode: string; readonly oid: string }[]>> {\n\tconst git: GitRunOptions = { cwd: dirname(store), env: { GIT_DIR: store } };\n\tconst trees = new Set<string>(tree === undefined ? [] : [tree]);\n\tif (admin !== undefined) {\n\t\tconst recorded = (await readFile(join(admin, RESTORED_TREE_FILE), \"utf8\").catch(() => \"\")).trim();\n\t\tif (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(recorded)) trees.add(recorded);\n\t\tconst head = await runGit([\"rev-parse\", \"--verify\", \"--quiet\", \"HEAD^{tree}\"], {\n\t\t\t...git,\n\t\t\tenv: { GIT_DIR: admin },\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\tconst headTree = head.exitCode === 0 ? head.stdout.toString(\"utf8\").trim() : \"\";\n\t\tif (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(headTree)) trees.add(headTree);\n\t}\n\tconst entries = new Map<string, { readonly mode: string; readonly oid: string }[]>();\n\tfor (const listed of trees) {\n\t\tconst listing = await runGit([\"ls-tree\", \"-r\", \"-z\", \"--full-tree\", listed], { ...git, allowExitCodes: [128] });\n\t\tif (listing.exitCode !== 0) continue;\n\t\tfor (const field of nulFields(listing.stdout)) {\n\t\t\tconst tab = field.indexOf(\"\\t\");\n\t\t\tconst [mode, , oid] = field.slice(0, tab).split(\" \");\n\t\t\tif (mode === undefined || oid === undefined) continue;\n\t\t\tconst path = field.slice(tab + 1);\n\t\t\tentries.set(path, [...(entries.get(path) ?? []), { mode, oid }]);\n\t\t}\n\t}\n\treturn entries;\n}\n\n/**\n * What deleting the directory at `path` would delete, when that is only what a restore put there (#4748): each file has,\n * at its path, the content of a tree the restore may have checked out, as a Git blob or as the Git LFS object its\n * pointer names; each symlink that tree's target; and a root `.git` file names an administrative directory of `store`.\n * Undefined when anything else is there, or when `path` is not a directory itself.\n */\nasync function inspectRestoredContent(\n\tpath: string,\n\tstore: string,\n\ttree: string | undefined,\n\town = false,\n): Promise<Map<string, RestoredEntry> | undefined> {\n\ttry {\n\t\tif (!(await lstat(path)).isDirectory()) return undefined;\n\t\tconst admin = await worktreeAdminDir(path);\n\t\tconst admins = await storeAdminDirs(store);\n\t\tconst inStore = admin !== undefined && admins !== undefined && isWithin(admins, admin);\n\t\tconst entries = await restoredTreeEntries(store, tree, inStore ? admin : undefined);\n\t\tconst found = new Map<string, RestoredEntry>();\n\t\tconst unmatched: {\n\t\t\treadonly path: string;\n\t\t\treadonly name: string;\n\t\t\treadonly size: bigint;\n\t\t\treadonly link: boolean;\n\t\t}[] = [];\n\t\tconst visit = async (dir: string, prefix: string): Promise<boolean> => {\n\t\t\tfor (const name of await readdir(dir)) {\n\t\t\t\tconst absolute = join(dir, name);\n\t\t\t\tconst relativeName = prefix === \"\" ? name : `${prefix}/${name}`;\n\t\t\t\tconst entry = await lstat(absolute, { bigint: true });\n\t\t\t\tif (entry.isDirectory()) {\n\t\t\t\t\tif (!(await visit(absolute, relativeName))) return false;\n\t\t\t\t} else if (relativeName === \".git\" && entry.isFile()) {\n\t\t\t\t\tif (!inStore) return false;\n\t\t\t\t\tfound.set(relativeName, { kind: \"text\", content: await readFile(absolute, \"utf8\") });\n\t\t\t\t} else if (entry.isSymbolicLink()) {\n\t\t\t\t\tunmatched.push({ path: absolute, name: relativeName, size: entry.size, link: true });\n\t\t\t\t} else if (entry.isFile()) {\n\t\t\t\t\tconst candidates = entries.get(relativeName) ?? [];\n\t\t\t\t\tconst algorithm = candidates[0]?.oid.length === 64 ? \"sha256\" : \"sha1\";\n\t\t\t\t\tconst digest = candidates.length === 0 ? \"\" : await digestOf(absolute, algorithm, true, entry.size);\n\t\t\t\t\tif (candidates.some((candidate) => candidate.oid === digest && candidate.mode !== \"160000\"))\n\t\t\t\t\t\tfound.set(relativeName, { kind: \"file\", algorithm, digest, blob: true });\n\t\t\t\t\telse if (candidates.length === 0) return false;\n\t\t\t\t\telse unmatched.push({ path: absolute, name: relativeName, size: entry.size, link: false });\n\t\t\t\t} else return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\tif (!(await visit(path, \"\"))) return undefined;\n\t\tconst converted: { readonly name: string; readonly path: string; readonly digest: string }[] = [];\n\t\tconst blobs = await storeBlobs(\n\t\t\tstore,\n\t\t\tunmatched.flatMap((file) => (entries.get(file.name) ?? []).map((candidate) => candidate.oid)),\n\t\t);\n\t\tfor (const file of unmatched) {\n\t\t\tconst candidates = (entries.get(file.name) ?? []).flatMap((candidate) => {\n\t\t\t\tconst blob = blobs.get(candidate.oid);\n\t\t\t\treturn blob === undefined ? [] : [{ mode: candidate.mode, blob }];\n\t\t\t});\n\t\t\tif (file.link) {\n\t\t\t\tconst target = await readlink(file.path);\n\t\t\t\tif (\n\t\t\t\t\t!candidates.some(\n\t\t\t\t\t\t(candidate) => candidate.mode === \"120000\" && candidate.blob.toString(\"utf8\") === target,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn undefined;\n\t\t\t\tfound.set(file.name, { kind: \"link\", target });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst object = candidates\n\t\t\t\t.map((candidate) => lfsObject(candidate.blob))\n\t\t\t\t.find((pointer) => pointer !== undefined && BigInt(pointer.size) === file.size);\n\t\t\tconst digest = await digestOf(file.path, \"sha256\", false, file.size);\n\t\t\tif (object !== undefined && digest === object.oid) {\n\t\t\t\tfound.set(file.name, { kind: \"file\", algorithm: \"sha256\", digest, blob: false });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\town &&\n\t\t\t\t(await beginsAny(\n\t\t\t\t\tfile.path,\n\t\t\t\t\tfile.size,\n\t\t\t\t\tcandidates.map((candidate) => candidate.blob),\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\tfound.set(file.name, { kind: \"file\", algorithm: \"sha256\", digest, blob: false });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconverted.push({ name: file.name, path: file.path, digest });\n\t\t}\n\t\t// A file the checkout converted, as for an end-of-line rule or a smudge filter, is the snapshot's only when its bytes\n\t\t// are exactly what the checkout writes for that path: never because a clean filter, which may drop an edit, maps it\n\t\t// back to a blob.\n\t\tif (converted.length > MAX_CONVERTED_FILES_CHECKED || (converted.length > 0 && !inStore)) return undefined;\n\t\tfor (const file of converted) {\n\t\t\tlet written = false;\n\t\t\tfor (const candidate of entries.get(file.name) ?? []) {\n\t\t\t\tconst checkout = await runGit(\n\t\t\t\t\t[\"-c\", `core.attributesFile=${devNull}`, \"cat-file\", \"--filters\", `--path=${file.name}`, candidate.oid],\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: path,\n\t\t\t\t\t\tenv: { GIT_DIR: admin!, GIT_WORK_TREE: path, GIT_LFS_SKIP_SMUDGE: \"1\" },\n\t\t\t\t\t\tneutral: true,\n\t\t\t\t\t\tallowExitCodes: [128],\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tcheckout.exitCode === 0 &&\n\t\t\t\t\t(createHash(\"sha256\").update(checkout.stdout).digest(\"hex\") === file.digest ||\n\t\t\t\t\t\t(own && (await beginsAny(file.path, undefined, [checkout.stdout]))))\n\t\t\t\t) {\n\t\t\t\t\twritten = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!written) return undefined;\n\t\t\tfound.set(file.name, { kind: \"file\", algorithm: \"sha256\", digest: file.digest, blob: false });\n\t\t}\n\t\treturn found;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Whether the bytes of the file at `path` are a beginning of one of `contents`, as a checkout stopped while it wrote the\n * file leaves it: its whole content is then still in the store, so deleting it loses nothing.\n */\nasync function beginsAny(path: string, size: bigint | undefined, contents: readonly Buffer[]): Promise<boolean> {\n\tconst length = size === undefined ? (await lstat(path)).size : Number(size);\n\tconst longer = contents.filter((content) => content.length >= length);\n\tif (longer.length === 0) return false;\n\tconst bytes = await readFile(path);\n\treturn longer.some((content) => bytes.length <= content.length && content.subarray(0, bytes.length).equals(bytes));\n}\n\n/** Whether the entry at `path` still holds what an inspection found there. */\nasync function stillRestored(path: string, expected: RestoredEntry): Promise<boolean> {\n\tconst entry = await lstat(path, { bigint: true });\n\tif (expected.kind === \"link\") return entry.isSymbolicLink() && (await readlink(path)) === expected.target;\n\tif (!entry.isFile()) return false;\n\tif (expected.kind === \"text\") return (await readFile(path, \"utf8\")) === expected.content;\n\treturn (await digestOf(path, expected.algorithm, expected.blob, entry.size)) === expected.digest;\n}\n\n/**\n * Deletes, bottom up, what an inspection found in the directory at `path` that this process set aside: each file or link\n * only while it still holds what was found, each directory only once empty, never following a link. Anything else is\n * kept, and so is every directory above it. Resolves to whether nothing is left.\n */\nasync function deleteRestoredContent(path: string, found: ReadonlyMap<string, RestoredEntry>): Promise<boolean> {\n\tconst visit = async (dir: string, prefix: string): Promise<boolean> => {\n\t\tlet emptied = true;\n\t\tfor (const name of await readdir(dir)) {\n\t\t\tconst absolute = join(dir, name);\n\t\t\tconst relativeName = prefix === \"\" ? name : `${prefix}/${name}`;\n\t\t\tconst entry = await lstat(absolute);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (!(await visit(absolute, relativeName))) emptied = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst expected = found.get(relativeName);\n\t\t\tif (expected === undefined || !(await stillRestored(absolute, expected))) {\n\t\t\t\temptied = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait writing(absolute, null, () => rm(absolute));\n\t\t}\n\t\tif (!emptied) return false;\n\t\tawait writing(dir, null, () => rmdir(dir));\n\t\treturn true;\n\t};\n\treturn visit(path, \"\");\n}\n\n/** Where a restore sets its worktree aside to delete it: beside its staging path, `.d-` in place of `.s-`. */\nfunction asidePath(record: RestoreRecord): string {\n\tconst name = basename(record.staging);\n\tconst aside = name.replace(/\\.s-([0-9a-f]{12})$/, \".d-$1\");\n\treturn join(dirname(record.staging), aside === name ? `${name}.d` : aside);\n}\n\n/** A directory a restore moved aside under the store lock, with what an inspection found in it. */\ninterface SetAside {\n\treadonly path: string;\n\treadonly found: ReadonlyMap<string, RestoredEntry> | undefined;\n}\n\n/**\n * Under the store lock, moves this restore's worktree at `path` to its aside path (#4748). Only the directory the\n * restore created moves: one with the identity recorded when Git added it, or, for a record without one, one that holds\n * only what the restore put there. What it holds is inspected first; `found` is undefined when anything else is there,\n * so the directory is kept, aside, for the user. Resolves to undefined, moving nothing, when `path` holds no such\n * directory or something already is at the aside path.\n */\nasync function setRestoredAside(path: string, record: RestoreRecord): Promise<SetAside | undefined> {\n\tconst identity = await directoryIdentity(path);\n\tif (identity === undefined) return undefined;\n\tconst created = record.identity !== undefined && sameIdentity(identity, record.identity);\n\t// Only in the restore's own directory may a file be a checkout stopped while it wrote it.\n\tconst found = await inspectRestoredContent(path, record.store, record.tree, created);\n\tif (!created && (record.identity !== undefined || found === undefined)) return undefined;\n\tconst aside = asidePath(record);\n\tif ((await lstatIfPresent(aside)) !== undefined) return undefined;\n\tawait writing(path, null, () => renameWithRetry(path, aside));\n\treturn { path: aside, found };\n}\n\n/**\n * Deletes what this restore set aside, outside the store lock: the directory must still be the one set aside, and each\n * file still what was found in it. Throws, keeping it all, when it holds anything else.\n */\nasync function deleteSetAside(record: RestoreRecord, aside: SetAside): Promise<void> {\n\tconst identity = await directoryIdentity(aside.path);\n\tconst same = identity !== undefined && (record.identity === undefined || sameIdentity(identity, record.identity));\n\tif (!same || aside.found === undefined || !(await deleteRestoredContent(aside.path, aside.found))) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", {\n\t\t\tsnapshotId: null,\n\t\t\ttarget: aside.path,\n\t\t\treason: \"not-restored\",\n\t\t});\n\t}\n}\n\n/**\n * Under the store lock: sets the restore's staging directory aside (see {@link setRestoredAside}), restores a previously\n * empty target if needed, and has Git forget the worktree. Resolves to what to delete once the lock is released: the\n * staging directory just set aside, or one an earlier cleanup set aside and did not finish deleting. A staging\n * directory this restore did not create is kept where it is and reported.\n */\nasync function cleanRestoreRecord(record: RestoreRecord, signal?: AbortSignal): Promise<SetAside[]> {\n\tconst git: GitRunOptions = { cwd: dirname(record.store), env: { GIT_DIR: record.store }, signal };\n\tconst pending: SetAside[] = [];\n\tconst aside = asidePath(record);\n\tif ((await lstatIfPresent(aside)) !== undefined) {\n\t\tconst identity = await directoryIdentity(aside);\n\t\tconst own = identity !== undefined && record.identity !== undefined && sameIdentity(identity, record.identity);\n\t\tpending.push({ path: aside, found: await inspectRestoredContent(aside, record.store, record.tree, own) });\n\t}\n\tlet entry: Stats | undefined;\n\tlet registeredPath = record.staging;\n\ttry {\n\t\tentry = await lstat(record.staging);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw unreadablePathError(record.staging, error);\n\t}\n\tif (entry) {\n\t\tif (entry.isDirectory()) registeredPath = await physicalPath(record.staging);\n\t\tconst setAside = pending.length === 0 ? await setRestoredAside(record.staging, record) : undefined;\n\t\tif (setAside === undefined) {\n\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", {\n\t\t\t\tsnapshotId: null,\n\t\t\t\ttarget: record.staging,\n\t\t\t\treason: \"not-restored\",\n\t\t\t});\n\t\t}\n\t\tpending.push(setAside);\n\t}\n\tif (!record.createdTarget && (await statIfPresent(record.target)) === undefined) {\n\t\tawait writing(record.target, null, () => mkdir(record.target, { recursive: true }));\n\t}\n\t// Git never prunes a locked worktree, as a killed `git worktree add` leaves one; unlocking touches no files.\n\tawait runGit([\"worktree\", \"unlock\", record.staging], { ...git, allowExitCodes: [128] });\n\tawait runGit([\"worktree\", \"prune\"], git);\n\tif (includesPath(await registeredWorktrees(git), registeredPath)) {\n\t\tthrow new WorkspaceGitError({\n\t\t\toperation: \"worktree prune\",\n\t\t\tcwd: git.cwd,\n\t\t\texitCode: null,\n\t\t\tdetail: \"the staging worktree is still registered\",\n\t\t});\n\t}\n\treturn pending;\n}\n\n/**\n * Cleans up after the restore of `record`: {@link cleanRestoreRecord} under the store lock, then the deletion of what it\n * set aside outside the lock. Throws, naming where the files are kept, when anything is kept.\n */\nasync function cleanUpRestore(\n\trecord: RestoreRecord,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n\tunderLock: () => Promise<SetAside[]> = () => cleanRestoreRecord(record, signal),\n): Promise<void> {\n\tconst pending = await withRepositoryLock(record.store, snapshotId, signal, underLock);\n\tfor (const aside of pending) {\n\t\tawait deleteSetAside(record, aside).catch((error: unknown) => {\n\t\t\tif (error instanceof Error) Object.defineProperty(error, \"keptAt\", { value: aside.path, configurable: true });\n\t\t\tthrow error;\n\t\t});\n\t}\n}\n\n/** Where a failed cleanup kept the restore's files: the directory its refusal names, else where they were. */\nfunction keptPath(cause: unknown, record: RestoreRecord, moved: boolean): string {\n\tconst keptAt = (cause as { keptAt?: unknown } | undefined)?.keptAt;\n\tif (typeof keptAt === \"string\") return keptAt;\n\tif (isWorkspaceRestoreError(cause) && cause.code === \"unsafe-target\" && cause.target !== undefined)\n\t\treturn cause.target;\n\treturn moved ? record.target : record.staging;\n}\n\nfunction leftoverKind(path: string, recordPath: string): \"worktree\" | \"record\" {\n\treturn path === recordPath ? \"record\" : \"worktree\";\n}\n\n/** Sweep only unlocked or stale records, leaving active processes' staging worktrees alone. */\nasync function sweepRestoreRecords(\n\tstoreDir: string,\n\twarn: (warning: WorktreeRestoreWarning) => void,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tsignal?.throwIfAborted();\n\tconst recordsDir = join(storeDir, \"restores\");\n\tlet names: string[];\n\ttry {\n\t\tnames = await readdir(recordsDir);\n\t} catch (error) {\n\t\tsignal?.throwIfAborted();\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n\t\twarn({ code: \"stale-restore-retained\", path: recordsDir, kind: \"records-directory\" });\n\t\treturn;\n\t}\n\tfor (const name of names) {\n\t\tsignal?.throwIfAborted();\n\t\tconst match = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\\.json$/.exec(name);\n\t\tif (!match) continue;\n\t\tconst recordPath = join(recordsDir, name);\n\t\tlet release: (() => Promise<void>) | undefined;\n\t\tlet compromised: Error | undefined;\n\t\tlet warningPath = recordPath;\n\t\ttry {\n\t\t\trelease = await lockShared(recordPath, {\n\t\t\t\trealpath: false,\n\t\t\t\tstale: RESTORE_LOCK_STALE_MS,\n\t\t\t\tupdate: RESTORE_LOCK_UPDATE_MS,\n\t\t\t\tretries: 0,\n\t\t\t\tonCompromised: (error) => {\n\t\t\t\t\tcompromised = error;\n\t\t\t\t},\n\t\t\t});\n\t\t\tconst record: unknown = JSON.parse(await readFile(recordPath, \"utf8\"));\n\t\t\tif (!isRestoreRecord(record, storeDir, match[1]!)) throw new Error(\"Invalid restore crash record\");\n\t\t\twarningPath = record.staging;\n\t\t\tawait cleanUpRestore(record, null, signal).catch((cause: unknown) => {\n\t\t\t\twarningPath = keptPath(cause, record, false);\n\t\t\t\tthrow cause;\n\t\t\t});\n\t\t\tif (compromised) throw compromised;\n\t\t\tawait rm(recordPath);\n\t\t} catch (error) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\tif (!(release === undefined && code === \"ELOCKED\") && !(warningPath === recordPath && code === \"ENOENT\")) {\n\t\t\t\twarn({ code: \"stale-restore-retained\", path: warningPath, kind: leftoverKind(warningPath, recordPath) });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\ttry {\n\t\t\t\t\tawait release();\n\t\t\t\t} catch {\n\t\t\t\t\tif (!compromised) {\n\t\t\t\t\t\twarn({\n\t\t\t\t\t\t\tcode: \"stale-restore-retained\",\n\t\t\t\t\t\t\tpath: warningPath,\n\t\t\t\t\t\t\tkind: leftoverKind(warningPath, recordPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Where the restore's worktree may be once it asked Git to move it to its target: `unchecked` until the check after the\n * move found it there (`published`), or found it nested in a directory that appeared at the target and dealt with that.\n */\ntype MoveState = \"none\" | \"unchecked\" | \"published\" | \"nested\" | \"checked\";\n\n/**\n * Under the store lock, cleanup after a restore that failed or was stopped once it asked Git to move its worktree toward\n * the target (#4748): the worktree, at the target or nested in a directory that appeared there, is set aside like its\n * staging directory (see {@link setRestoredAside}), then {@link cleanRestoreRecord} runs. Only the restore that moved it\n * does this; the crash sweep never does, so a record that a successful restore could not remove never costs the\n * worktree it published.\n */\nasync function cleanMovedRestore(record: RestoreRecord, state: MoveState): Promise<SetAside[]> {\n\tconst git: GitRunOptions = { cwd: dirname(record.store), env: { GIT_DIR: record.store } };\n\tconst pending: SetAside[] = [];\n\tconst nested = join(record.target, basename(record.staging));\n\tconst candidates = state === \"unchecked\" ? [record.target, nested] : state === \"nested\" ? [nested] : [record.target];\n\tfor (const candidate of candidates) {\n\t\tif (pending.length > 0) break;\n\t\tconst setAside = await setRestoredAside(candidate, record);\n\t\tif (setAside !== undefined) pending.push(setAside);\n\t}\n\tif (pending.length === 0) {\n\t\t// A worktree of this restore, or one Git registered where it moved it, that could not be set aside is kept and\n\t\t// reported, with its crash record, never left behind silently.\n\t\tconst registered = await registeredWorktrees(git);\n\t\tfor (const candidate of candidates) {\n\t\t\tconst identity = await directoryIdentity(candidate);\n\t\t\tif (identity === undefined) continue;\n\t\t\tconst own = record.identity !== undefined && sameIdentity(identity, record.identity);\n\t\t\tif (own || includesPath(registered, await physicalPath(candidate))) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", {\n\t\t\t\t\tsnapshotId: null,\n\t\t\t\t\ttarget: candidate,\n\t\t\t\t\treason: \"not-restored\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tconst staged = await cleanRestoreRecord(record);\n\treturn [...pending, ...staged.filter((aside) => !pending.some((moved) => moved.path === aside.path))];\n}\n\n/**\n * Hold a crash record lock throughout staging and publication; preserve the primary failure if cleanup fails. The\n * action calls `published` once it has moved its worktree to the target, so a failure after that removes it too.\n */\nasync function withRestoreRecord(\n\tstoreDir: string,\n\tid: string,\n\trecord: RestoreRecord,\n\tsnapshotId: string | null,\n\twarn: (warning: WorktreeRestoreWarning) => void,\n\tsignal: AbortSignal | undefined,\n\taction: (\n\t\tassertActive: () => void,\n\t\tmoving: (state: MoveState) => void,\n\t\tcreated: (identity: DirectoryIdentity) => Promise<void>,\n\t) => Promise<void>,\n): Promise<void> {\n\tconst recordsDir = join(storeDir, \"restores\");\n\tconst recordPath = join(recordsDir, `${id}.json`);\n\tawait writing(recordsDir, snapshotId, () => mkdir(recordsDir, { recursive: true }));\n\tlet compromised: Error | undefined;\n\tconst release = await writing(recordPath, snapshotId, () =>\n\t\tlockShared(recordPath, {\n\t\t\trealpath: false,\n\t\t\tstale: RESTORE_LOCK_STALE_MS,\n\t\t\tupdate: RESTORE_LOCK_UPDATE_MS,\n\t\t\tretries: 0,\n\t\t\tonCompromised: (error) => {\n\t\t\t\tcompromised = error;\n\t\t\t},\n\t\t}),\n\t);\n\tlet recorded = false;\n\tlet moveState = \"none\" as MoveState;\n\tlet primary: unknown;\n\tconst assertActive = () => {\n\t\tsignal?.throwIfAborted();\n\t\tif (compromised) {\n\t\t\tthrow new WorkspaceGitError(\n\t\t\t\t{\n\t\t\t\t\toperation: \"worktree restore\",\n\t\t\t\t\tcwd: record.staging,\n\t\t\t\t\texitCode: null,\n\t\t\t\t\tdetail: \"the staging lock was lost\",\n\t\t\t\t},\n\t\t\t\tcompromised,\n\t\t\t);\n\t\t}\n\t};\n\ttry {\n\t\tawait writing(recordPath, snapshotId, () =>\n\t\t\twriteFile(recordPath, JSON.stringify(record), { flag: \"wx\", mode: 0o600 }),\n\t\t);\n\t\trecorded = true;\n\t\tassertActive();\n\t\tawait action(\n\t\t\tassertActive,\n\t\t\t(state) => {\n\t\t\t\tmoveState = state;\n\t\t\t},\n\t\t\tasync (identity) => {\n\t\t\t\trecord = { ...record, identity };\n\t\t\t\tconst written = `${recordPath}.${process.pid}.tmp`;\n\t\t\t\tawait writing(recordPath, snapshotId, async () => {\n\t\t\t\t\tawait writeFile(written, JSON.stringify(record), { mode: 0o600 });\n\t\t\t\t\tawait renameWithRetry(written, recordPath);\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\tassertActive();\n\t\ttry {\n\t\t\tawait rm(recordPath);\n\t\t} catch {\n\t\t\twarn({ code: \"stale-restore-retained\", path: record.staging, kind: \"worktree\" });\n\t\t}\n\t} catch (error) {\n\t\tprimary = error;\n\t\tif (recorded) {\n\t\t\tconst moved = moveState === \"unchecked\" || moveState === \"published\" || moveState === \"nested\";\n\t\t\ttry {\n\t\t\t\tawait cleanUpRestore(record, snapshotId, undefined, () =>\n\t\t\t\t\tmoved ? cleanMovedRestore(record, moveState) : cleanRestoreRecord(record),\n\t\t\t\t);\n\t\t\t\tawait rm(recordPath);\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tif (error instanceof Error)\n\t\t\t\t\tObject.defineProperty(error, \"cleanupCause\", { value: cleanupCause, configurable: true });\n\t\t\t\twarn({ code: \"stale-restore-retained\", path: keptPath(cleanupCause, record, moved), kind: \"worktree\" });\n\t\t\t}\n\t\t}\n\t\tthrow error;\n\t} finally {\n\t\ttry {\n\t\t\tawait release();\n\t\t} catch (error) {\n\t\t\tif (primary instanceof Error && !Object.hasOwn(primary, \"cleanupCause\")) {\n\t\t\t\tObject.defineProperty(primary, \"cleanupCause\", { value: error, configurable: true });\n\t\t\t} else if (primary === undefined) {\n\t\t\t\twarn({ code: \"stale-restore-retained\", path: record.staging, kind: \"worktree\" });\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * The object store, under `storeDir`, of the checkout at `root` whose remotes are `remotes`. Checkouts of one\n * repository share it: it is named after the normalized remotes (#4748), relative paths resolved against `root`, so\n * SSH and HTTPS checkouts of one repository share it, or after the remotes as spelled when only a store an earlier\n * version created that way exists. A checkout whose remotes name no one repository, as one without remotes, has a\n * store of its own (#4989). Undefined when that checkout's `root` is unknown: its store cannot be told apart from\n * another repository's.\n */\nexport function objectStorePath(storeDir: string, remotes: readonly string[], root?: string): string | undefined {\n\tconst [current, legacy] = sharedRepositoryIdsOf(remotes, root);\n\tconst named = (repository: string) => join(storeDir, \"repositories\", `${repository}.git`);\n\tif (current === undefined) {\n\t\treturn root === undefined || !isAbsolute(root) ? undefined : named(checkoutStoreIdOf(root));\n\t}\n\tif (legacy === undefined) return named(current);\n\treturn existsSync(named(current)) || !existsSync(named(legacy)) ? named(current) : named(legacy);\n}\n\nasync function objectStorePathAsync(\n\tstoreDir: string,\n\tremotes: readonly string[],\n\troot?: string,\n): Promise<string | undefined> {\n\tconst [current, legacy] = sharedRepositoryIdsOf(remotes, root);\n\tconst named = (repository: string) => join(storeDir, \"repositories\", `${repository}.git`);\n\tif (current === undefined) {\n\t\treturn root === undefined || !isAbsolute(root) ? undefined : named(checkoutStoreIdOf(root));\n\t}\n\tif (legacy === undefined) return named(current);\n\treturn (await pathExists(named(current))) || !(await pathExists(named(legacy))) ? named(current) : named(legacy);\n}\n\n/**\n * {@link objectStorePath} of the checkout a restore of `target` restores, its snapshot's when known; rejects with\n * `commits-unavailable` when it has none, as for a binding of a checkout without remotes and no snapshot: no store can\n * be its repository's (#4989).\n */\nasync function restoreStorePath(\n\tstoreDir: string,\n\ttarget: { readonly remotes: readonly string[]; readonly head: string },\n\tcheckout: { readonly id: string | null; readonly root: string | undefined },\n): Promise<string> {\n\tconst store = await objectStorePathAsync(storeDir, target.remotes, checkout.root);\n\tif (store !== undefined) return store;\n\tthrow new WorkspaceRestoreError(\"commits-unavailable\", {\n\t\tsnapshotId: checkout.id,\n\t\thead: target.head,\n\t\tcommits: [target.head],\n\t\tremotes: [...target.remotes],\n\t\treason: \"not-fetched\",\n\t});\n}\n\n/**\n * Puts the commit `head` of the local checkout at `checkout` into the shared object store of the repository `remotes`\n * name (#4748), so a restore of it fetches nothing from a remote: a CI job's checkout keeps its credentials to itself.\n * A shallow checkout leaves the store shallow, as a depth-1 restore fetch does.\n */\nexport async function storeCheckoutHead(\n\tstoreDir: string,\n\tremotes: readonly string[],\n\tcheckout: string,\n\thead: string,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tconst store = await restoreStorePath(resolve(storeDir), { remotes, head }, { id: null, root: checkout });\n\tconst git: GitRunOptions = { cwd: checkout, signal, env: { GIT_DIR: store } };\n\tawait withRepositoryLock(store, null, signal, async () => {\n\t\tawait ensureObjectStore(store, signal);\n\t\tif (!(await hasObject(git, `${head}^{commit}`))) await runFetch(git, checkout, [head], [\"--update-shallow\"]);\n\t});\n}\n\nasync function initializedStore(store: string): Promise<boolean> {\n\ttry {\n\t\tawait stat(join(store, \"config\"));\n\t\tawait stat(join(store, \"HEAD\"));\n\t\treturn true;\n\t} catch (error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\tif (code === \"ENOENT\" || code === \"ENOTDIR\") return false;\n\t\tthrow unreadablePathError(store, error);\n\t}\n}\n\n/**\n * Creates `store` unless it already has its configuration and HEAD. Callers hold its repository lock, so no two\n * restores, in this process or others, initialize one store at once (#4951), and an existing store is left alone:\n * re-initializing rewrites its configuration, which on Windows fails the other restores' Git processes that are\n * reading it. The store is initialized beside its place and renamed into it, so a process stopped midway leaves no\n * half-made store; a directory already there that is not one, as an older build may have left, is initialized in place.\n */\nasync function ensureObjectStore(store: string, signal?: AbortSignal): Promise<void> {\n\tif (await initializedStore(store)) return enableLongPaths(store, signal);\n\tconst repositories = dirname(store);\n\tconst fresh = join(repositories, `.${basename(store)}.${process.pid}.init`);\n\ttry {\n\t\tawait runGit([\"init\", \"-q\", \"--bare\", fresh], { cwd: repositories, signal });\n\t\tawait enableLongPaths(fresh, signal);\n\t\ttry {\n\t\t\tawait renameWithRetry(fresh, store, { signal });\n\t\t} catch {\n\t\t\tawait runGit([\"init\", \"-q\", \"--bare\", store], { cwd: repositories, signal });\n\t\t}\n\t} finally {\n\t\tawait rm(fresh, { recursive: true, force: true });\n\t}\n}\n\n/**\n * On Windows, turns on `core.longpaths` in `store`'s configuration, which its worktrees share, so Git run in a restored\n * worktree by the user or an agent handles that worktree's files past 260 characters as Atomic's own Git does (#5139).\n * A store that has it is left alone, so its configuration is rewritten at most once; a failure to write it costs only\n * that, since Atomic's own Git commands set it on their command lines. Run only under the store's repository lock.\n */\nasync function enableLongPaths(store: string, signal?: AbortSignal): Promise<void> {\n\tif (process.platform !== \"win32\") return;\n\tconst config = join(store, \"config\");\n\tconst git: GitRunOptions = { cwd: store, signal, allowExitCodes: [1] };\n\tconst current = await runGit([\"config\", \"--file\", config, \"--type=bool\", \"--get\", \"core.longpaths\"], git);\n\tif (current.stdout.toString(\"utf8\").trim() === \"true\") return;\n\tawait runGit([\"config\", \"--file\", config, \"core.longpaths\", \"true\"], git).catch(() => signal?.throwIfAborted());\n}\n\nfunction bundlePrerequisites(bundle: Uint8Array): string[] {\n\tconst end = Buffer.from(bundle).indexOf(\"\\n\\n\");\n\tconst header = Buffer.from(bundle.subarray(0, end < 0 ? Math.min(bundle.length, 65536) : end)).toString(\"utf8\");\n\treturn header\n\t\t.split(\"\\n\")\n\t\t.filter((line) => line.startsWith(\"-\"))\n\t\t.map((line) => line.slice(1).split(\" \", 1)[0]!);\n}\n\n/**\n * Transports a restore may fetch over. Recorded remotes come from storage, so Git's remote helpers (`ext::`, `fd::`,\n * custom `<name>::`) are refused; local paths stay allowed for path remotes and mirrors.\n */\nconst FETCH_TRANSPORTS = [\n\t\"-c\",\n\t\"protocol.allow=never\",\n\t...[\"https\", \"http\", \"ssh\", \"git\", \"file\"].flatMap((protocol) => [\"-c\", `protocol.${protocol}.allow=always`]),\n];\n\n/**\n * `git fetch` of `refspecs` from `repository`, with `options` such as `--depth=1`; the `--` keeps a recorded value from\n * ever being read as an option.\n */\nfunction fetchArgs(repository: string, refspecs: readonly string[], options: readonly string[]): string[] {\n\treturn [\n\t\t...FETCH_TRANSPORTS,\n\t\t\"fetch\",\n\t\t\"-q\",\n\t\t\"--no-tags\",\n\t\t\"--no-write-fetch-head\",\n\t\t...options,\n\t\t\"--\",\n\t\trepository,\n\t\t...refspecs,\n\t];\n}\n\n/** Runs {@link fetchArgs} through the runner without a way to prompt, so an unreachable or unknown host fails at once. */\nfunction runFetch(\n\tgit: GitRunOptions,\n\trepository: string,\n\trefspecs: readonly string[],\n\toptions: readonly string[] = [],\n): Promise<GitRunResult> {\n\treturn runGit(fetchArgs(repository, refspecs, options), { ...git, nonInteractive: true });\n}\n\n/** The options of a fetch that brings whole history: `--unshallow` once a depth-1 fetch left the store shallow. */\nasync function historyFetchOptions(git: GitRunOptions): Promise<string[]> {\n\treturn (await gitText([\"rev-parse\", \"--is-shallow-repository\"], git)) === \"true\" ? [\"--unshallow\"] : [];\n}\n\n/** Fetch failures that do not depend on the depth: the remote cannot be reached, or does not have the commits. */\nconst FULL_FETCH_FAILS_TOO =\n\t/could not read from remote repository|unable to access|could not resolve|does not appear to be a git repository|^ssh:|not our ref|couldn't find remote ref|unadvertised object/i;\n\ninterface RemoteFetch {\n\t/** The last fetch failure, when a remote could not supply what was still missing. */\n\treadonly failure: Error | undefined;\n\t/** Whether a recorded remote's fetch of the missing commits succeeded, so that remote has every one of them. */\n\treadonly supplied: boolean;\n}\n\n/**\n * Fetches the `commits` the store lacks from the first of `remotes` that has them, with their history; with\n * `depthFirst`, each remote is first asked for the commits alone (`--depth=1`, #4748), and asked again for their\n * history only when that fails for a reason other than an unreachable remote or missing commits.\n */\nasync function fetchCommits(\n\tgit: GitRunOptions,\n\tremotes: readonly string[],\n\tcommits: readonly string[],\n\tdepthFirst = false,\n): Promise<RemoteFetch> {\n\tlet failure: Error | undefined;\n\tlet supplied = false;\n\tfor (const remote of remotes) {\n\t\tconst missing = [];\n\t\tfor (const commit of commits) if (!(await hasObject(git, `${commit}^{commit}`))) missing.push(commit);\n\t\tif (missing.length === 0) return { failure: undefined, supplied };\n\t\tif (depthFirst) {\n\t\t\ttry {\n\t\t\t\tawait runFetch(git, remote, missing, [\"--depth=1\"]);\n\t\t\t\tsupplied = true;\n\t\t\t\tnoteRestoreFetch(\"shallow\");\n\t\t\t\tcontinue;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\t\t// A remote or Git that refuses a depth-1 fetch gets today's full fetch; one that is unreachable or lacks the\n\t\t\t\t// commits would fail it the same way, so it is not asked twice.\n\t\t\t\tif (FULL_FETCH_FAILS_TOO.test(error.detail)) {\n\t\t\t\t\tfailure = error;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tawait runFetch(git, remote, missing, await historyFetchOptions(git));\n\t\t\tsupplied = true;\n\t\t\tnoteRestoreFetch(\"full\");\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\tfailure = error;\n\t\t}\n\t}\n\treturn { failure, supplied };\n}\n\n/**\n * Fetches the whole history of a store a depth-1 fetch left shallow, with `commits`, from the first of `remotes` that\n * supplies it, so an ancestry check across the boundary is answered (#4748). Resolves whether one did; Git refuses at\n * once, without contacting a remote, for a store that holds its whole history.\n */\nasync function unshallowStore(\n\tgit: GitRunOptions,\n\tremotes: readonly string[],\n\tcommits: readonly string[],\n): Promise<boolean> {\n\tfor (const remote of remotes) {\n\t\ttry {\n\t\t\tawait runFetch(git, remote, commits, [\"--unshallow\"]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t}\n\t}\n\treturn false;\n}\n\n/** The shared object store a restored worktree's Git directory names: Atomic's own, never a user's repository. */\nconst SHARED_STORE = /[\\\\/]repositories[\\\\/][0-9a-f]{24}\\.git$/;\n\n/**\n * Fetches the whole history of the shared object store behind the restored worktree at `root` from its recorded\n * remotes, when a depth-1 restore left that store shallow, so ancestry across the boundary is answered (#4748).\n * Resolves whether it did; a checkout that is not a restored worktree, or a failed fetch, is left as it is.\n */\nexport async function unshallowRestoredWorktree(\n\troot: string,\n\tcommits: readonly string[],\n\tsignal?: AbortSignal,\n): Promise<boolean> {\n\tconst common = await runGit([\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], {\n\t\tcwd: root,\n\t\tsignal,\n\t\tallowExitCodes: [128],\n\t});\n\tconst store = common.stdout.toString(\"utf8\").trim();\n\tif (common.exitCode !== 0 || !SHARED_STORE.test(store)) return false;\n\tconst git: GitRunOptions = { cwd: dirname(store), signal, env: { GIT_DIR: store } };\n\t// Sibling worktrees of one store are compared at once: one fetches its history, the others find it complete.\n\treturn withRepositoryLock(store, null, signal, async () =>\n\t\t(await historyFetchOptions(git)).length === 0\n\t\t\t? true\n\t\t\t: unshallowStore(git, await configuredRemoteUrls(git), commits),\n\t);\n}\n\n/**\n * Makes `snapshot.head` available in the store, from the recorded remotes or else its bundle, and resolves whether\n * it came from a recorded remote. A remote's fetch of `head` alone is tried first, at depth 1 (#4748); a bundle's\n * prerequisites are fetched with their history, as its import needs.\n */\nasync function ensureHead(\n\tgit: GitRunOptions,\n\tsnapshot: Pick<WorktreeSnapshot, \"head\" | \"remotes\" | \"bundle\" | \"omitted\"> & { readonly id: string | null },\n\tblobs: SnapshotBlobStore | undefined,\n\tscratch: string,\n): Promise<boolean> {\n\tconst { head } = snapshot;\n\tlet fetched = false;\n\tif (!(await hasObject(git, `${head}^{commit}`))) {\n\t\t// Only a fetch that succeeded proves a remote has `head`: another process may import it from a bundle meanwhile.\n\t\tconst fromRemotes = await fetchCommits(git, snapshot.remotes, [head], true);\n\t\tlet failure = fromRemotes.failure;\n\t\tfetched = fromRemotes.supplied;\n\t\tif (!(await hasObject(git, `${head}^{commit}`)) && snapshot.bundle) {\n\t\t\tconst data = await loadBlob(blobs, snapshot.bundle.blob, { snapshotId: snapshot.id, role: \"bundle\" });\n\t\t\tconst prerequisites = bundlePrerequisites(data);\n\t\t\tassertUsableBundlePrerequisites(prerequisites, snapshot.id);\n\t\t\tfailure = (await fetchCommits(git, snapshot.remotes, prerequisites)).failure ?? failure;\n\t\t\tconst file = join(scratch, \"history.bundle\");\n\t\t\tawait writing(file, snapshot.id, () => writeFile(file, data));\n\t\t\ttry {\n\t\t\t\tawait runFetch(git, file, [\"HEAD\"]);\n\t\t\t\tnoteRestoreFetch(\"bundle\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\t\tfailure = error;\n\t\t\t}\n\t\t}\n\t\tif (!(await hasObject(git, `${head}^{commit}`))) {\n\t\t\tconst denied = snapshot.omitted.find((entry) => entry.reason === \"unpushed-history-denied\");\n\t\t\tconst overCap = snapshot.omitted.find((entry) => entry.reason === \"bundle-over-cap\");\n\t\t\tthrow new WorkspaceRestoreError(\n\t\t\t\t\"commits-unavailable\",\n\t\t\t\tdenied\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\tcommits: denied.commits,\n\t\t\t\t\t\t\tpaths: denied.paths,\n\t\t\t\t\t\t\tremotes: snapshot.remotes,\n\t\t\t\t\t\t\treason: \"denied-history\",\n\t\t\t\t\t\t}\n\t\t\t\t\t: overCap\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\t\tcommits: overCap.commits,\n\t\t\t\t\t\t\t\tremotes: snapshot.remotes,\n\t\t\t\t\t\t\t\treason: \"bundle-over-cap\",\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\t\tcommits: [head],\n\t\t\t\t\t\t\t\tremotes: snapshot.remotes,\n\t\t\t\t\t\t\t\treason: \"not-fetched\",\n\t\t\t\t\t\t\t},\n\t\t\t\tfailure,\n\t\t\t);\n\t\t}\n\t}\n\treturn fetched;\n}\n\nasync function configuredRemoteUrls(git: GitRunOptions): Promise<string[]> {\n\tconst { stdout } = await runGit([\"config\", \"-z\", \"--get-regexp\", \"^remote\\\\..+\\\\.url$\"], {\n\t\t...git,\n\t\tallowExitCodes: [1],\n\t});\n\treturn nulFields(stdout).map((field) => field.slice(field.indexOf(\"\\n\") + 1));\n}\n\n/**\n * Gives a shared object store the remotes its snapshots record, in their recorded order (the first as `origin`, then\n * `origin-2`, …), so a capture in one of its worktrees records them too. Resolves whether the store's remotes are the\n * recorded ones, however each is spelled. A store without recorded remotes, or with a remote that is not credential-free or not of a scheme a\n * restore fetches over, is left without any, as before.\n */\nasync function configureRecordedRemotes(git: GitRunOptions, remotes: readonly string[]): Promise<boolean> {\n\tif (remotes.length === 0 || !remotes.every(isAllowedRemote)) return false;\n\tlet configured = await configuredRemoteUrls(git);\n\t// A store holding the start of the recorded list was set up by a restore that stopped partway; finish it.\n\tif (configured.length < remotes.length && configured.every((remote, index) => sameRemote(remote, remotes[index]!))) {\n\t\ttry {\n\t\t\tfor (let index = configured.length; index < remotes.length; index++) {\n\t\t\t\tawait runGit([\"remote\", \"add\", \"--\", index === 0 ? \"origin\" : `origin-${index + 1}`, remotes[index]!], git);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\t// Another process configured the store at the same moment; what it wrote is compared below.\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t}\n\t\tconfigured = await configuredRemoteUrls(git);\n\t}\n\treturn (\n\t\tconfigured.length === remotes.length && configured.every((remote, index) => sameRemote(remote, remotes[index]!))\n\t);\n}\n\n/** Where a restore records commits a recorded remote has, as remote-tracking refs no remote's fetch ever prunes. */\nconst PUSHED_REFS = \"refs/remotes/atomic/pushed/\";\n\n/**\n * The commits a restore knows a recorded remote has, to record as remote-tracking refs: the snapshot's `head` when the\n * restore fetched it from one or the snapshot recorded nothing unpushed, else the parents of its bundled commits that\n * the bundle does not hold, its pushed boundary. Later captures in the store's worktrees then bundle only commits that\n * are really unpushed, and never count a commit that only a bundle carried as pushed.\n */\nasync function pushedCommits(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot | null,\n\thead: string,\n\tfetched: boolean,\n): Promise<Set<string>> {\n\tconst pushed = new Set<string>();\n\tconst historyOmitted = snapshot?.omitted.some(\n\t\t(omission) => omission.reason === \"unpushed-history-denied\" || omission.reason === \"bundle-over-cap\",\n\t);\n\tif (fetched || (snapshot !== null && snapshot.bundle === null && !historyOmitted)) pushed.add(head);\n\telse if (snapshot?.bundle) {\n\t\tconst bundled = new Set(snapshot.bundle.commits);\n\t\tconst parents = await runGit([\"rev-list\", \"--no-walk=unsorted\", \"--parents\", \"--stdin\"], {\n\t\t\t...git,\n\t\t\tinput: `${snapshot.bundle.commits.join(\"\\n\")}\\n`,\n\t\t\tallowExitCodes: [128],\n\t\t});\n\t\tif (parents.exitCode === 0) {\n\t\t\tfor (const line of parents.stdout.toString(\"utf8\").split(\"\\n\")) {\n\t\t\t\tfor (const parent of line.split(\" \").slice(1)) if (!bundled.has(parent)) pushed.add(parent);\n\t\t\t}\n\t\t}\n\t}\n\treturn pushed;\n}\n\nasync function reconstructTree(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot,\n\tpatches: readonly (Uint8Array | null)[],\n\tscratch: string,\n): Promise<void> {\n\tconst indexed: GitRunOptions = { ...git, env: { ...git.env, GIT_INDEX_FILE: join(scratch, \"restore-index\") } };\n\tconst stored = await storedTrees(\n\t\tgit,\n\t\tsnapshot.chain.map((link) => link.tree),\n\t);\n\tlet resumeAt = snapshot.chain.length;\n\twhile (resumeAt > 0 && !stored.has(snapshot.chain[resumeAt - 1]!.tree)) resumeAt--;\n\tawait runGit([\"read-tree\", resumeAt === 0 ? snapshot.head : snapshot.chain[resumeAt - 1]!.tree], indexed);\n\tfor (const [deltaIndex, link] of snapshot.chain.entries()) {\n\t\tif (deltaIndex < resumeAt) continue;\n\t\tconst patch = patches[deltaIndex];\n\t\tlet applyFailure: Error | undefined;\n\t\tif (patch) {\n\t\t\tconst file = join(scratch, `delta-${deltaIndex}.patch`);\n\t\t\tawait writing(file, snapshot.id, () => writeFile(file, patch));\n\t\t\ttry {\n\t\t\t\tawait runGit(\n\t\t\t\t\t[\"apply\", \"--cached\", \"--binary\", \"--whitespace=nowarn\", \"--no-ignore-whitespace\", \"--no-3way\", file],\n\t\t\t\t\tindexed,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\t\tapplyFailure = error;\n\t\t\t}\n\t\t}\n\t\tconst actualTree = applyFailure ? null : await gitText([\"write-tree\"], indexed);\n\t\tif (actualTree !== link.tree) {\n\t\t\tthrow new WorkspaceRestoreError(\n\t\t\t\t\"delta-failed\",\n\t\t\t\t{\n\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\tdeltaIndex,\n\t\t\t\t\t...(link.patch ? { blob: link.patch } : {}),\n\t\t\t\t\texpectedTree: link.tree,\n\t\t\t\t\tactualTree,\n\t\t\t\t},\n\t\t\t\tapplyFailure,\n\t\t\t);\n\t\t}\n\t}\n}\n\nasync function lfsPaths(worktree: GitRunOptions): Promise<string[]> {\n\tconst files = (await runGit([\"ls-files\", \"-z\"], worktree)).stdout;\n\tconst fields = nulFields(\n\t\t(await runGit([\"check-attr\", \"--stdin\", \"-z\", \"filter\"], { ...worktree, input: files })).stdout,\n\t);\n\tconst paths: string[] = [];\n\tfor (let index = 0; index + 2 < fields.length; index += 3) {\n\t\tif (fields[index + 2] === \"lfs\") paths.push(fields[index]!);\n\t}\n\treturn paths;\n}\n\n/** The form of a recorded remote that Git LFS can find its server from: a local path needs to be a `file://` URL. */\nfunction lfsRemote(remote: string): string {\n\treturn isAbsolute(remote) ? pathToFileURL(remote).href : remote;\n}\n\nconst LFS_POINTER_PREFIX = Buffer.from(\"version https://git-lfs.github.com/spec/v1\");\nconst LFS_POINTER_MAX_BYTES = 1024;\n\nasync function isLfsPointer(file: string): Promise<boolean> {\n\ttry {\n\t\tif (!(await lstat(file)).isFile()) return false;\n\t\tconst handle = await open(file, \"r\");\n\t\ttry {\n\t\t\tconst buffer = Buffer.alloc(LFS_POINTER_MAX_BYTES);\n\t\t\tconst { bytesRead } = await handle.read(buffer, 0, LFS_POINTER_MAX_BYTES, 0);\n\t\t\treturn (\n\t\t\t\tbytesRead < LFS_POINTER_MAX_BYTES &&\n\t\t\t\tbuffer.subarray(0, LFS_POINTER_PREFIX.length).equals(LFS_POINTER_PREFIX)\n\t\t\t);\n\t\t} finally {\n\t\t\tawait handle.close();\n\t\t}\n\t} catch (error) {\n\t\tthrow unreadablePathError(file, error);\n\t}\n}\n\nasync function remainingPointers(root: string, paths: readonly string[]): Promise<string[]> {\n\tconst pointers: string[] = [];\n\tfor (const path of paths) if (await isLfsPointer(join(root, path))) pointers.push(path);\n\treturn pointers;\n}\n\n/**\n * Downloads the Git LFS objects of the snapshot's tree into the staged worktree from each recorded remote in turn,\n * while any LFS file still holds a pointer, and returns the files that still do. `git lfs pull` fetches only the\n * objects of HEAD's tree and its exit status does not say which files arrived, so the staged HEAD and index name the\n * snapshot's commit during the pulls, and the files themselves are inspected after each one. The staging worktree\n * belongs to a per-repository store that is created without remotes, so each recorded remote is named explicitly,\n * after `--` so that a value can never be read as an option, and the download can never wait for a person.\n */\nasync function pullLfsObjects(\n\tworktree: GitRunOptions,\n\thead: string,\n\ttree: string,\n\tremotes: readonly string[],\n): Promise<string[]> {\n\tconst snapshotCommit = await writeSnapshotCommit(worktree, head, tree);\n\tawait runGit([\"update-ref\", \"--no-deref\", \"HEAD\", snapshotCommit], worktree);\n\tawait runGit([\"read-tree\", snapshotCommit], worktree);\n\tlet pointers = await remainingPointers(worktree.cwd, await lfsPaths(worktree));\n\tfor (const remote of remotes) {\n\t\tif (pointers.length === 0) break;\n\t\ttry {\n\t\t\tawait runGit([\"lfs\", \"pull\", \"--\", lfsRemote(remote)], { ...worktree, nonInteractive: true });\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\tworktree.signal?.throwIfAborted();\n\t\t}\n\t\tpointers = await remainingPointers(worktree.cwd, pointers);\n\t}\n\tawait runGit([\"update-ref\", \"--no-deref\", \"HEAD\", head], worktree);\n\tawait runGit([\"read-tree\", head], worktree);\n\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...worktree, neutral: true, allowExitCodes: [1] });\n\treturn pointers;\n}\n\n/**\n * The file in a restored worktree's own Git directory that says its LFS download has not completed (#5099): written\n * before a worktree whose download is deferred is published, removed once every LFS file has its content, so a resume\n * interrupted during the download leaves the next one a way to finish it.\n */\nconst LFS_PENDING_FILE = \"atomic-lfs-pending.json\";\n\ninterface PendingLfs {\n\treadonly head: string;\n\treadonly tree: string;\n\treadonly remotes: readonly string[];\n\t/** The process downloading, while one is: its Git steps may leave locks behind if it is killed. */\n\treadonly holder?: ProcessHolder;\n}\n\n/**\n * How long a download whose process cannot be told from a later one given its id, where its start cannot be read,\n * counts as running: past this its locks are its leftovers.\n */\nconst UNSTARTED_LFS_HOLDER_LIMIT_MS = 24 * 60 * 60_000;\n\n/** The marks of the worktrees this process is downloading into now. */\nconst pullingHere = new Set<string>();\n\n/** `name` in the worktree's own Git directory. */\nasync function worktreeGitPath(worktree: GitRunOptions, name: string): Promise<string> {\n\treturn resolve(worktree.cwd, await gitText([\"rev-parse\", \"--path-format=absolute\", \"--git-path\", name], worktree));\n}\n\nfunction pendingLfsPath(worktree: GitRunOptions): Promise<string> {\n\treturn worktreeGitPath(worktree, LFS_PENDING_FILE);\n}\n\nasync function markLfsPending(worktree: GitRunOptions, pending: PendingLfs, snapshotId: string | null): Promise<void> {\n\tconst marker = await pendingLfsPath(worktree);\n\tawait writing(marker, snapshotId, () => writeFile(marker, JSON.stringify(pending)));\n}\n\n/**\n * Replaces the mark of a worktree that other processes may read at once: written beside it and renamed over it, so a\n * reader finds the old mark or the new one, never one a write has truncated, which reads as unusable and is removed.\n */\nasync function rewritePendingMark(marker: string, pending: PendingLfs): Promise<void> {\n\tconst partial = `${marker}.${randomUUID()}.partial`;\n\ttry {\n\t\tawait writeFile(partial, JSON.stringify(pending));\n\t\tawait renameWithRetry(partial, marker);\n\t} catch (error) {\n\t\tawait rm(partial, { force: true });\n\t\tthrow error;\n\t}\n}\n\n/** {@link pullLfsObjects} into a worktree marked pending, clearing the mark once no LFS file holds a pointer. */\nasync function pullPendingLfs(worktree: GitRunOptions, pending: PendingLfs): Promise<string[]> {\n\tconst marker = await pendingLfsPath(worktree);\n\tconst waiting: PendingLfs = { head: pending.head, tree: pending.tree, remotes: pending.remotes };\n\tpullingHere.add(marker);\n\ttry {\n\t\tawait rewritePendingMark(marker, { ...waiting, holder: await thisProcess() });\n\t\tconst pointers = await pullLfsObjects(worktree, pending.head, pending.tree, pending.remotes);\n\t\tif (pointers.length === 0) await rm(marker, { force: true });\n\t\telse await rewritePendingMark(marker, waiting);\n\t\treturn pointers;\n\t} finally {\n\t\tpullingHere.delete(marker);\n\t}\n}\n\n/**\n * Whether the download that `pending` names is still running, in this process or another, so nothing of it may be\n * touched. A download whose process is gone may have left `HEAD.lock` or `index.lock` behind.\n */\nasync function lfsHolderRuns(marker: string, pending: PendingLfs): Promise<boolean> {\n\tif (pullingHere.has(marker)) return true;\n\tconst holder = pending.holder;\n\tif (holder === undefined) return false;\n\t// This process, when it is not downloading into the worktree, stopped the download that names it.\n\tif (holder.host === HOST && holder.pid === process.pid) return false;\n\ttry {\n\t\tconst age = Date.now() - (await stat(marker)).mtimeMs;\n\t\treturn await holderRuns(holder, age, UNSTARTED_LFS_HOLDER_LIMIT_MS);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return true;\n\t\tthrow error;\n\t}\n}\n\nfunction isPendingLfs(value: unknown): value is PendingLfs {\n\tconst pending = value as Partial<PendingLfs> | null;\n\treturn (\n\t\ttypeof pending?.head === \"string\" &&\n\t\t/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(pending.head) &&\n\t\ttypeof pending.tree === \"string\" &&\n\t\t/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(pending.tree) &&\n\t\tArray.isArray(pending.remotes) &&\n\t\tpending.remotes.every((remote) => typeof remote === \"string\" && isAllowedRemote(remote)) &&\n\t\t(pending.holder === undefined ||\n\t\t\t(typeof pending.holder?.host === \"string\" &&\n\t\t\t\tNumber.isSafeInteger(pending.holder.pid) &&\n\t\t\t\t(pending.holder.start === undefined || typeof pending.holder.start === \"string\")))\n\t);\n}\n\n/** How long a resume waits for another running process to finish a download it holds before it warns (#5099). */\nexport const LFS_HOLDER_WAIT_MS = 10 * 60_000;\n/** How often a resume waiting for another process's download checks on it. */\nconst LFS_HOLDER_POLL_MS = 250;\n\n/**\n * The Git LFS download left unfinished in the restored worktree at `worktree` (#5099), by a resume that was interrupted\n * or by another Atomic process still running it, or undefined when none is pending. The returned function finishes it\n * and resolves to the files that still hold pointers, as a restore's download does: it waits for a running process to\n * end its download, at most {@link LFS_HOLDER_WAIT_MS}, and takes over from one that stopped. A worktree whose `HEAD`\n * moved since its restore, or whose mark cannot be read, is not changed: the function then rejects, saying to run\n * `git lfs pull` there, and the mark is removed so this is said once.\n */\nexport async function pendingLfsDownload(\n\tworktree: string,\n\toptions: { readonly signal?: AbortSignal } = {},\n): Promise<(() => Promise<readonly string[]>) | undefined> {\n\tconst git: GitRunOptions = { cwd: worktree, signal: options.signal };\n\tconst marker = await pendingLfsPath(git);\n\tif ((await readPendingMark(marker)) === undefined) return undefined;\n\treturn () => finishPendingLfs(git, marker);\n}\n\nasync function readPendingMark(marker: string): Promise<string | undefined> {\n\ttry {\n\t\treturn await readFile(marker, \"utf8\");\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\tthrow error;\n\t}\n}\n\nasync function finishPendingLfs(git: GitRunOptions, marker: string): Promise<string[]> {\n\tconst waitingSince = Date.now();\n\tfor (;;) {\n\t\tconst text = await readPendingMark(marker);\n\t\t// Its process finished the download: every LFS file has its content.\n\t\tif (text === undefined) return [];\n\t\tconst pending = parsePendingLfs(text);\n\t\tif (pending === undefined || !(await lfsHolderRuns(marker, pending))) {\n\t\t\tconst claim = await claimPendingLfs(git, marker);\n\t\t\tif (claim.kind === \"finished\") return [];\n\t\t\tif (claim.kind === \"claimed\") {\n\t\t\t\ttry {\n\t\t\t\t\treturn await takeOverPendingLfs(git, marker, claim.pending);\n\t\t\t\t} finally {\n\t\t\t\t\tpullingHere.delete(marker);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Date.now() - waitingSince >= LFS_HOLDER_WAIT_MS) return remainingPointers(git.cwd, await lfsPaths(git));\n\t\tawait sleep(LFS_HOLDER_POLL_MS, undefined, { signal: git.signal });\n\t}\n}\n\n/** How a {@link claimPendingLfs} went: the download is done, another process runs it, or this process now holds it. */\ntype LfsClaim =\n\t| { readonly kind: \"finished\" }\n\t| { readonly kind: \"running\" }\n\t| { readonly kind: \"claimed\"; readonly pending: PendingLfs | undefined };\n\n/**\n * Makes this process the holder of the download pending in the worktree, when its process stopped or it names none,\n * one process at a time: under the takeover mutex of its mark, an advisory lock the kernel releases when its holder\n * dies (#5193), the mark is read again, the locks a stopped download's Git steps left are removed, and the mark names\n * this process before the mutex is released. Another process that judged the same download stopped then finds this\n * one running it and waits, rather than removing the locks this one's Git holds, or downloading beside it.\n */\nasync function claimPendingLfs(git: GitRunOptions, marker: string): Promise<LfsClaim> {\n\tconst locks = await Promise.all([\"HEAD.lock\", \"index.lock\"].map((name) => worktreeGitPath(git, name)));\n\tconst mutex = await takeTakeoverMutexAsync(marker, 0);\n\tif (mutex === undefined) return { kind: \"running\" };\n\ttry {\n\t\tconst text = await readPendingMark(marker);\n\t\tif (text === undefined) return { kind: \"finished\" };\n\t\tconst pending = parsePendingLfs(text);\n\t\tif ((pending !== undefined && (await lfsHolderRuns(marker, pending))) || !(await mutex.owned()))\n\t\t\treturn { kind: \"running\" };\n\t\t// A download killed during its Git steps leaves their locks; nothing else takes them in a worktree with a mark.\n\t\tif (pending?.holder !== undefined) for (const lock of locks) await rm(lock, { force: true });\n\t\tif (pending !== undefined) {\n\t\t\tconst { head, tree, remotes } = pending;\n\t\t\tawait rewritePendingMark(marker, { head, tree, remotes, holder: await thisProcess() });\n\t\t\tpullingHere.add(marker);\n\t\t}\n\t\treturn { kind: \"claimed\", pending };\n\t} finally {\n\t\tawait mutex.release();\n\t}\n}\n\n/** Finishes the download pending in the worktree once this process holds it ({@link claimPendingLfs}). */\nasync function takeOverPendingLfs(\n\tgit: GitRunOptions,\n\tmarker: string,\n\tpending: PendingLfs | undefined,\n): Promise<string[]> {\n\tconst head = await gitText([\"rev-parse\", \"-q\", \"--verify\", \"HEAD^{commit}\"], { ...git, allowExitCodes: [1] });\n\t// A download cut off mid-pull leaves HEAD at the snapshot's commit, which it names while it runs.\n\tif (\n\t\tpending !== undefined &&\n\t\t(head === pending.head || head === (await writeSnapshotCommit(git, pending.head, pending.tree)))\n\t) {\n\t\treturn pullPendingLfs(git, pending);\n\t}\n\tawait rm(marker, { force: true });\n\tthrow new Error(\n\t\t\"its LFS download was interrupted and the worktree changed since, so it was not repeated; run `git lfs pull` in it\",\n\t);\n}\n\nfunction parsePendingLfs(text: string): PendingLfs | undefined {\n\ttry {\n\t\tconst pending: unknown = JSON.parse(text);\n\t\treturn isPendingLfs(pending) ? pending : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function materialize(\n\tgit: GitRunOptions,\n\tstore: string,\n\ttarget: string,\n\thead: string,\n\ttree: string,\n\tscratch: string,\n\tsnapshotId: string | null,\n\tcreated: (identity: DirectoryIdentity) => Promise<void>,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tawait withRepositoryLock(store, snapshotId, signal, async () => {\n\t\t// Git adds a worktree into an empty directory too: only one it creates itself is the restore's.\n\t\tif ((await lstatIfPresent(target)) !== undefined) {\n\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target, reason: \"not-empty\" });\n\t\t}\n\t\tawait runGit([\"worktree\", \"add\", \"-q\", \"--detach\", \"--no-checkout\", target, head], git);\n\t\tconst identity = await directoryIdentity(target);\n\t\tif (identity !== undefined) await created(identity);\n\t});\n\tconst attributes = join(scratch, \"empty-attributes\");\n\tawait writing(attributes, snapshotId, () => writeFile(attributes, \"\"));\n\tconst neutral: GitRunOptions = { cwd: target, signal, neutral: true, env: { GIT_LFS_SKIP_SMUDGE: \"1\" } };\n\tawait runGit([\"-c\", `core.attributesFile=${attributes}`, \"read-tree\", \"--reset\", \"-u\", tree], neutral);\n\tawait runGit([\"read-tree\", head], neutral);\n\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...neutral, allowExitCodes: [1] });\n\tawait recordRestoredTree(neutral, tree);\n}\n\n/** Removes the restored worktree at `target` from the store `git` points at, then prunes what its removal left. */\nasync function removeWorktree(git: GitRunOptions, target: string): Promise<void> {\n\tawait runGit([\"worktree\", \"remove\", \"--force\", target], { ...git, signal: undefined, allowExitCodes: [128] });\n\tawait writing(target, null, () => rm(target, { recursive: true, force: true }));\n\tawait runGit([\"worktree\", \"prune\"], { ...git, signal: undefined });\n}\n\nfunction resolveSnapshot(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\tsnapshots: readonly WorktreeSnapshot[] | undefined,\n): WorktreeSnapshot | null {\n\tif (isSnapshot(target)) return target;\n\tconst candidates = (snapshots ?? []).filter(\n\t\t(snapshot) => isSnapshot(snapshot) && snapshot.tree === target.tree && snapshot.head === target.head,\n\t);\n\treturn candidates.at(-1) ?? null;\n}\n\n/**\n * Restores a snapshot, or the snapshot a binding names, into a new worktree over the host's shared object store for\n * its repository, and returns the worktree only after its HEAD and recomputed tree match. Checks the target and every\n * blob before writing to the target; on failure removes what it created and throws a typed error. With `git`, every Git\n * command of the restore runs that executable.\n */\nexport async function restoreWorktree(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\toptions: RestoreWorktreeSnapshotOptions = {},\n): Promise<RestoredWorktree> {\n\tif (!isBinding(target)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"target\", \"a WorkspaceBinding or a WorktreeSnapshot\");\n\t}\n\tif (options.into !== undefined && (typeof options.into !== \"string\" || options.into.length === 0)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"into\", \"a directory path\");\n\t}\n\tif (options.git !== undefined && (typeof options.git?.path !== \"string\" || options.git.path.length === 0)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"git\", \"a Git executable with a non-empty path\");\n\t}\n\treturn withWorktreeSnapshotGit(options.git, () => restoreValidated(target, options, undefined));\n}\n\n/**\n * {@link restoreWorktree} into `slot`, a pooled slot path under `storeDir`/worktrees that does not exist yet (#4748),\n * staged like a restore into a new default path. Session resumes use it; `into` stays the SDK's way to choose a path.\n */\nexport async function restoreWorktreeAt(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\tslot: string,\n\toptions: Omit<RestoreWorktreeSnapshotOptions, \"into\"> & {\n\t\t/** The root of the checkout a binding was recorded in, which its relative-path remotes are relative to (#4989). */\n\t\treadonly root?: string;\n\t} = {},\n): Promise<RestoredWorktree> {\n\tif (!isBinding(target)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"target\", \"a WorkspaceBinding or a WorktreeSnapshot\");\n\t}\n\treturn withWorktreeSnapshotGit(options.git, () => restoreValidated(target, options, slot, options.root));\n}\n\nasync function restoreValidated(\n\ttarget: WorkspaceBinding,\n\toptions: RestoreWorktreeSnapshotOptions,\n\tslot: string | undefined,\n\troot?: string,\n): Promise<RestoredWorktree> {\n\tconst { signal } = options;\n\tconst snapshot = resolveSnapshot(target, options.snapshots);\n\tassertUsableSnapshotRecord(target, snapshot);\n\tconst snapshotId = snapshot?.id ?? null;\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst path = resolve(\n\t\toptions.into ??\n\t\t\tslot ??\n\t\t\tjoin(storeDir, \"worktrees\", `${(snapshot?.id ?? target.tree).slice(0, 12)}-${randomUUID().slice(0, 8)}`),\n\t);\n\tawait checkTarget(path, snapshotId);\n\tconst patches = await snapshotPatches(snapshot, options.blobs);\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst retained = new Set<string>();\n\tconst warn = (warning: WorktreeRestoreWarning) => {\n\t\tif (warning.code === \"stale-restore-retained\") {\n\t\t\tif (retained.has(warning.path)) return;\n\t\t\tretained.add(warning.path);\n\t\t}\n\t\twarnings.push(warning);\n\t\toptions.onWarning?.(warning);\n\t};\n\tawait checkPathBudget(\n\t\tstoreDir,\n\t\t() => restoreStorePath(storeDir, target, snapshot ?? { id: null, root }),\n\t\tpath,\n\t\toptions.into,\n\t\tsnapshotId,\n\t);\n\tawait sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = await restoreStorePath(storeDir, target, snapshot ?? { id: null, root });\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tawait storeSnapshotObjects(git, store, target, snapshot, patches, options.blobs, scratch);\n\t\tawait publishWorktree({\n\t\t\tgit,\n\t\t\tstore,\n\t\t\tstoreDir,\n\t\t\tpath,\n\t\t\tinto: options.into,\n\t\t\thead: target.head,\n\t\t\ttree: target.tree,\n\t\t\tsnapshot,\n\t\t\tscratch,\n\t\t\twarn,\n\t\t\tsignal,\n\t\t\tverify: \"tree\",\n\t\t\t// The download runs later, with the Git this restore runs.\n\t\t\tdeferLfs:\n\t\t\t\toptions.deferLfs &&\n\t\t\t\t((worktree, pull) => options.deferLfs!(worktree, () => withWorktreeSnapshotGit(options.git, pull))),\n\t\t});\n\t\tif (snapshot) for (const warning of snapshotRestoreWarnings(snapshot)) warn(warning);\n\t\treturn {\n\t\t\tpath,\n\t\t\tsnapshot,\n\t\t\tbinding: { remotes: [...target.remotes], head: target.head, tree: target.tree, envHash: target.envHash },\n\t\t\twarnings,\n\t\t};\n\t});\n}\n\n/**\n * Makes `target`'s commit and tree objects of the shared store `store`, which `git` points at: fetches or unbundles the\n * commit when the store lacks it, keeps it and the commits known to be pushed referenced, and rebuilds the tree from\n * the snapshot's change sets when the store lacks it too.\n */\nasync function storeSnapshotObjects(\n\tgit: GitRunOptions,\n\tstore: string,\n\ttarget: WorkspaceBinding,\n\tsnapshot: WorktreeSnapshot | null,\n\tpatches: readonly (Uint8Array | null)[],\n\tblobs: SnapshotBlobStore | undefined,\n\tscratch: string,\n): Promise<void> {\n\tawait withRepositoryLock(store, snapshot?.id ?? null, git.signal, async () => {\n\t\tawait ensureObjectStore(store, git.signal);\n\t\tconst fetched = await timeRestorePhase(\"fetch\", () =>\n\t\t\tensureHead(\n\t\t\t\tgit,\n\t\t\t\tsnapshot ?? { id: null, head: target.head, remotes: target.remotes, bundle: null, omitted: [] },\n\t\t\t\tblobs,\n\t\t\t\tscratch,\n\t\t\t),\n\t\t);\n\t\t// What a snapshot of other remotes, such as a fork at the same commit, says is pushed is not this store's.\n\t\tconst sameRemotes =\n\t\t\tsnapshot === null ||\n\t\t\t(snapshot.remotes.length === target.remotes.length &&\n\t\t\t\tsnapshot.remotes.every((remote, index) => sameRemote(remote, target.remotes[index]!)));\n\t\tconst pushed =\n\t\t\t(await configureRecordedRemotes(git, target.remotes)) && sameRemotes\n\t\t\t\t? await pushedCommits(git, snapshot, target.head, fetched)\n\t\t\t\t: new Set<string>();\n\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t...git,\n\t\t\tinput: [\n\t\t\t\t`update refs/atomic/heads/${target.head} ${target.head}\\n`,\n\t\t\t\t...[...pushed].map((commit) => `update ${PUSHED_REFS}${commit} ${commit}\\n`),\n\t\t\t].join(\"\"),\n\t\t});\n\t\tif (!(await hasObject(git, `${target.tree}^{tree}`))) {\n\t\t\tif (!snapshot) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"snapshot-not-found\", {\n\t\t\t\t\tsnapshotId: null,\n\t\t\t\t\thead: target.head,\n\t\t\t\t\ttree: target.tree,\n\t\t\t\t});\n\t\t\t}\n\t\t\tawait timeRestorePhase(\"reconstruct\", () => reconstructTree(git, snapshot, patches, scratch));\n\t\t}\n\t});\n}\n\n/** The change sets of `snapshot`'s chain, each checked against its recorded hash; null for a link without one. */\nfunction snapshotPatches(\n\tsnapshot: WorktreeSnapshot | null,\n\tblobs: SnapshotBlobStore | undefined,\n): Promise<(Uint8Array | null)[]> {\n\tif (!snapshot) return Promise.resolve([]);\n\treturn Promise.all(\n\t\tsnapshot.chain.map((link, deltaIndex) =>\n\t\t\tlink.patch === null\n\t\t\t\t? null\n\t\t\t\t: loadBlob(blobs, link.patch, { snapshotId: snapshot.id, role: \"patch\", deltaIndex }),\n\t\t),\n\t);\n}\n\n/**\n * Makes `snapshot`'s commit and tree objects of this host's shared object store for its repository, as a restore does,\n * without writing a worktree, and resolves with the store's path (#4922). Rejects with the restore's typed failures,\n * such as `blob-missing` or `commits-unavailable`, and `invalid-snapshot` for a record that fails the security checks.\n */\nexport async function storeSnapshotTree(\n\tsnapshot: WorktreeSnapshot,\n\toptions: Pick<RestoreWorktreeSnapshotOptions, \"blobs\" | \"storeDir\" | \"signal\">,\n): Promise<string> {\n\tconst binding: WorkspaceBinding = { ...snapshot, remotes: [...snapshot.remotes] };\n\tassertUsableSnapshotRecord(binding, snapshot);\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst patches = await snapshotPatches(snapshot, options.blobs);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = await restoreStorePath(storeDir, snapshot, snapshot);\n\t\tconst git: GitRunOptions = { cwd: scratch, signal: options.signal, env: { GIT_DIR: store } };\n\t\tawait storeSnapshotObjects(git, store, binding, snapshot, patches, options.blobs, scratch);\n\t\treturn store;\n\t});\n}\n\nexport interface ResetPooledWorktreeOptions {\n\treadonly storeDir: string;\n\treadonly blobs?: SnapshotBlobStore;\n\treadonly signal?: AbortSignal;\n\t/** Runs once the snapshot's objects are in the store, right before the first write to the worktree. */\n\treadonly beforeReset: () => Promise<void>;\n}\n\n/**\n * Resets the existing pooled worktree at `slot`, whose files are exactly the recorded tree `from`, to `snapshot`\n * (#4748): files `from` holds and the snapshot does not are removed, the snapshot's are written where they differ, and\n * HEAD and the index name the snapshot's commit. Files Git ignores, such as dependencies and build output, stay;\n * unchanged files keep their timestamps. Resolves to the restore's warnings once HEAD and the recomputed tree match\n * the snapshot; rejects with `tree-mismatch` when they do not. A failure before `beforeReset` ran left the worktree\n * untouched. Only the pool's claim calls this: it is the one way an existing worktree is rewritten.\n */\nexport async function resetPooledWorktree(\n\tsnapshot: WorktreeSnapshot,\n\tslot: string,\n\tfrom: { readonly tree: string },\n\toptions: ResetPooledWorktreeOptions,\n): Promise<WorktreeRestoreWarning[]> {\n\tconst { signal } = options;\n\tconst binding: WorkspaceBinding = {\n\t\tremotes: [...snapshot.remotes],\n\t\thead: snapshot.head,\n\t\ttree: snapshot.tree,\n\t\tenvHash: snapshot.envHash,\n\t};\n\tassertUsableSnapshotRecord(binding, snapshot);\n\tconst patches = await snapshotPatches(snapshot, options.blobs);\n\t// The slot's own store: one an earlier version named after the remotes as spelled stays the slot's (#4748).\n\tconst store = await pooledWorktreeStore(options.storeDir, slot, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tawait storeSnapshotObjects(git, store, binding, snapshot, patches, options.blobs, scratch);\n\t\tawait options.beforeReset();\n\t\t// A download an interrupted resume left pending is the reset's to finish, or to leave pending again.\n\t\tawait rm(await pendingLfsPath({ cwd: slot, signal }), { force: true });\n\t\tawait timeRestorePhase(\"materialize\", async () => {\n\t\t\tconst attributes = join(scratch, \"empty-attributes\");\n\t\t\tawait writing(attributes, snapshot.id, () => writeFile(attributes, \"\"));\n\t\t\tconst neutral: GitRunOptions = { cwd: slot, signal, neutral: true, env: { GIT_LFS_SKIP_SMUDGE: \"1\" } };\n\t\t\t// The index takes `from` first, keeping the timestamps of the entries it already had, so the reset below\n\t\t\t// removes the files `from` holds beyond HEAD as well, and writes only what differs.\n\t\t\tawait runGit([\"read-tree\", \"--reset\", from.tree], neutral);\n\t\t\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...neutral, allowExitCodes: [1] });\n\t\t\tawait runGit(\n\t\t\t\t[\"-c\", `core.attributesFile=${attributes}`, \"read-tree\", \"--reset\", \"-u\", snapshot.tree],\n\t\t\t\tneutral,\n\t\t\t);\n\t\t\tawait runGit([\"update-ref\", \"--no-deref\", \"HEAD\", snapshot.head], neutral);\n\t\t\tawait runGit([\"read-tree\", \"--reset\", snapshot.head], neutral);\n\t\t\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...neutral, allowExitCodes: [1] });\n\t\t\tawait recordRestoredTree(neutral, snapshot.tree);\n\t\t});\n\t\tconst warnings = snapshotRestoreWarnings(snapshot);\n\t\tif (snapshot.filters?.drivers.includes(\"lfs\")) {\n\t\t\tconst worktree: GitRunOptions = { cwd: slot, signal };\n\t\t\tconst pending: PendingLfs = { head: snapshot.head, tree: snapshot.tree, remotes: snapshot.remotes };\n\t\t\tconst pointers = await timeRestorePhase(\"lfs\", () => pullPendingLfs(worktree, pending));\n\t\t\tif (pointers.length > 0) warnings.unshift({ code: \"lfs-objects-unavailable\", paths: pointers });\n\t\t}\n\t\tawait timeRestorePhase(\"verify\", () =>\n\t\t\tverifyRestoredTree(slot, slot, snapshot.head, snapshot.tree, \"tree\", scratch, snapshot.id, signal),\n\t\t);\n\t\treturn warnings;\n\t});\n}\n\n/**\n * The shared object store under `storeDir` that the restored worktree at `worktree` belongs to; rejects with\n * `unsafe-target` when it belongs to none.\n */\nexport async function pooledWorktreeStore(\n\tstoreDir: string,\n\tworktree: string,\n\tsignal: AbortSignal | undefined,\n): Promise<string> {\n\tconst store = resolve(\n\t\tawait gitText([\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], { cwd: worktree, signal }),\n\t);\n\tif (\n\t\t(await canonicalizeWorktreePathAsync(dirname(store))) !==\n\t\t(await canonicalizeWorktreePathAsync(join(storeDir, \"repositories\")))\n\t) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId: null, target: worktree, reason: \"not-restored\" });\n\t}\n\treturn store;\n}\n\n/** Restore errors after which a degraded restore can still give the session part of its snapshot (#4733). */\nconst DEGRADABLE_RESTORE_CODES: ReadonlySet<string> = new Set([\n\t\"blob-missing\",\n\t\"blob-corrupt\",\n\t\"commits-unavailable\",\n\t\"delta-failed\",\n\t\"tree-mismatch\",\n]);\n\n/** Whether a degraded restore can follow `error`, the failure of an exact restore. */\nexport function isDegradableRestoreFailure(error: unknown): error is WorkspaceRestoreError {\n\treturn isWorkspaceRestoreError(error) && DEGRADABLE_RESTORE_CODES.has(error.code);\n}\n\nexport interface RestoreDegradedWorktreeOptions extends Omit<RestoreWorktreeSnapshotOptions, \"into\" | \"snapshots\"> {\n\t/**\n\t * Commits close to the snapshot's `HEAD` to try, nearest first, after its pushed base and before its branch tip:\n\t * the `HEAD`s of the checkout's earlier snapshots, for example.\n\t */\n\treadonly candidates?: readonly string[];\n}\n\nexport interface DegradedWorktree {\n\treadonly path: string;\n\treadonly degraded: WorktreeDegradedRestore;\n\treadonly warnings: readonly WorktreeRestoreWarning[];\n}\n\n/**\n * Restores the best state of `snapshot` that this host can reach after an exact restore failed with `failure` (#4733),\n * into a new worktree: the recorded `HEAD` with the change sets of the patch chain that apply, each whole or not at\n * all, up to the first that cannot; else the closest commit it can fetch from the recorded remotes, trying the\n * snapshot's pushed base, then `candidates`, then the recorded branch's tip. Rejects with `failure` when no commit is\n * reachable, and with `invalid-snapshot` for a record that fails the security checks, before any Git work.\n */\nexport async function restoreDegradedWorktree(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\toptions: RestoreDegradedWorktreeOptions = {},\n): Promise<DegradedWorktree> {\n\treturn withWorktreeSnapshotGit(options.git, () => restoreDegradedValidated(snapshot, failure, options, undefined));\n}\n\n/** {@link restoreDegradedWorktree} into `slot`, a pooled slot path as for {@link restoreWorktreeAt} (#4748). */\nexport async function restoreDegradedWorktreeAt(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\tslot: string,\n\toptions: RestoreDegradedWorktreeOptions = {},\n): Promise<DegradedWorktree> {\n\treturn withWorktreeSnapshotGit(options.git, () => restoreDegradedValidated(snapshot, failure, options, slot));\n}\n\nasync function restoreDegradedValidated(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\toptions: RestoreDegradedWorktreeOptions,\n\tslot: string | undefined,\n): Promise<DegradedWorktree> {\n\tconst { signal } = options;\n\tassertUsableSnapshotRecord(\n\t\t{ remotes: [...snapshot.remotes], head: snapshot.head, tree: snapshot.tree, envHash: snapshot.envHash },\n\t\tsnapshot,\n\t);\n\tconst candidates = options.candidates ?? [];\n\tconst unusable = candidates.findIndex((commit) => !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(commit));\n\tif (unusable >= 0) throw new WorkspaceConfigError(\"sdk\", `candidates[${unusable}]`, \"a Git commit id\");\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst path =\n\t\tslot === undefined\n\t\t\t? join(storeDir, \"worktrees\", `${snapshot.id.slice(0, 12)}-${randomUUID().slice(0, 8)}`)\n\t\t\t: resolve(slot);\n\tawait checkTarget(path, snapshot.id);\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst warn = (warning: WorktreeRestoreWarning) => {\n\t\twarnings.push(warning);\n\t\toptions.onWarning?.(warning);\n\t};\n\tawait checkPathBudget(storeDir, () => restoreStorePath(storeDir, snapshot, snapshot), path, undefined, snapshot.id);\n\tawait sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = await restoreStorePath(storeDir, snapshot, snapshot);\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tconst cause = {\n\t\t\tcause: failure.code,\n\t\t\t...(failure.reason ? { causeReason: failure.reason } : {}),\n\t\t\thint: failure.hint,\n\t\t};\n\t\tconst degraded = await withRepositoryLock(\n\t\t\tstore,\n\t\t\tsnapshot.id,\n\t\t\tsignal,\n\t\t\tasync (): Promise<WorktreeDegradedRestore> => {\n\t\t\t\tawait ensureObjectStore(store, signal);\n\t\t\t\tconst configured = await configureRecordedRemotes(git, snapshot.remotes);\n\t\t\t\t// The exact restore may have stopped before it reached the recorded commit: fetch it, or take it from the bundle.\n\t\t\t\tconst reached = await timeRestorePhase(\"fetch\", () =>\n\t\t\t\t\tensureHead(git, snapshot, options.blobs, scratch),\n\t\t\t\t).then(\n\t\t\t\t\t(fetched) => ({ fetched }),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tif (isWorkspaceRestoreError(error)) return undefined;\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (reached !== undefined) {\n\t\t\t\t\tconst partial = await timeRestorePhase(\"reconstruct\", () =>\n\t\t\t\t\t\tapplicableChanges(git, snapshot, options.blobs, scratch),\n\t\t\t\t\t);\n\t\t\t\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t\t\t\t...git,\n\t\t\t\t\t\tinput: [\n\t\t\t\t\t\t\t`update refs/atomic/heads/${snapshot.head} ${snapshot.head}\\n`,\n\t\t\t\t\t\t\t...(configured && reached.fetched\n\t\t\t\t\t\t\t\t? [`update ${PUSHED_REFS}${snapshot.head} ${snapshot.head}\\n`]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t].join(\"\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstage: \"partial-changes\",\n\t\t\t\t\t\thead: snapshot.head,\n\t\t\t\t\t\ttree: partial.tree,\n\t\t\t\t\t\tmissingLinks: partial.missingLinks,\n\t\t\t\t\t\tmissingPaths: partial.missingPaths,\n\t\t\t\t\t\tmissingCommits: [],\n\t\t\t\t\t\t...cause,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst closest = await timeRestorePhase(\"fetch\", () =>\n\t\t\t\t\tclosestCommit(git, snapshot, candidates, options.blobs),\n\t\t\t\t);\n\t\t\t\tif (closest === undefined) throw failure;\n\t\t\t\t// Which unpushed commits the closest commit's history lacks is an ancestry question a shallow store cannot answer.\n\t\t\t\tawait unshallowStore(git, snapshot.remotes, [closest.commit]);\n\t\t\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t\t\t...git,\n\t\t\t\t\tinput: [\n\t\t\t\t\t\t`update refs/atomic/heads/${closest.commit} ${closest.commit}\\n`,\n\t\t\t\t\t\t...(configured && closest.fromRemote\n\t\t\t\t\t\t\t? [`update ${PUSHED_REFS}${closest.commit} ${closest.commit}\\n`]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t].join(\"\"),\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstage: \"closest-commit\",\n\t\t\t\t\thead: closest.commit,\n\t\t\t\t\ttree: await gitText([\"rev-parse\", `${closest.commit}^{tree}`], git),\n\t\t\t\t\tbasis: closest.basis,\n\t\t\t\t\tmissingLinks: snapshot.chain.flatMap((link, index) => (link.patch === null ? [] : [index])),\n\t\t\t\t\tmissingPaths: [],\n\t\t\t\t\tmissingCommits: await notInHistory(git, unpushedCommits(snapshot), closest.commit),\n\t\t\t\t\t...cause,\n\t\t\t\t};\n\t\t\t},\n\t\t);\n\t\tconst measured = await publishWorktree({\n\t\t\tgit,\n\t\t\tstore,\n\t\t\tstoreDir,\n\t\t\tpath,\n\t\t\tinto: undefined,\n\t\t\thead: degraded.head,\n\t\t\ttree: degraded.tree,\n\t\t\tsnapshot,\n\t\t\tscratch,\n\t\t\twarn,\n\t\t\tsignal,\n\t\t\t// Whatever started the degraded restore, this host's checkout filters may change the files it writes (#4744):\n\t\t\t// check its HEAD and keep the checkout, recording the tree it holds.\n\t\t\tverify: \"head\",\n\t\t});\n\t\t// This host's checkout filters may have changed files, and a case-insensitive file system may hold one file for\n\t\t// paths that differ only in case: record what the worktree holds, and which files differ.\n\t\tconst differing = nulFields(\n\t\t\t(await runGit([\"diff-tree\", \"-r\", \"-z\", \"--name-only\", \"--no-renames\", degraded.tree, measured], git)).stdout,\n\t\t);\n\t\tconst folded = await caseFoldedPaths(git, degraded.tree, path);\n\t\tconst missingPaths = [...new Set([...degraded.missingPaths, ...differing, ...folded])].sort();\n\t\treturn { path, degraded: { ...degraded, tree: measured, missingPaths }, warnings };\n\t});\n}\n\n/**\n * The paths of `tree` that differ from another only in case (`dir/b.txt` and `Dir/b.txt`) where the worktree at `root`\n * lacks one of them under its own spelling: a case-insensitive file system holds one file for them all, so none can be\n * relied on (#4932).\n */\nasync function caseFoldedPaths(git: GitRunOptions, tree: string, root: string): Promise<string[]> {\n\tconst groups = new Map<string, string[]>();\n\tfor (const path of nulFields((await runGit([\"ls-tree\", \"-r\", \"-z\", \"--name-only\", tree], git)).stdout)) {\n\t\tconst key = path.toLowerCase();\n\t\tgroups.set(key, [...(groups.get(key) ?? []), path]);\n\t}\n\tconst spelledAsRecorded = async (path: string) => {\n\t\tconst parts = path.split(\"/\");\n\t\tfor (let index = 0; index < parts.length; index++) {\n\t\t\tconst names: string[] = await readdir(join(root, ...parts.slice(0, index))).catch(() => []);\n\t\t\tif (!names.includes(parts[index]!)) return false;\n\t\t}\n\t\treturn true;\n\t};\n\tconst folded: string[] = [];\n\tfor (const group of groups.values()) {\n\t\tif (group.length < 2) continue;\n\t\tfor (const path of group) {\n\t\t\tif (await spelledAsRecorded(path)) continue;\n\t\t\tfolded.push(...group);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn folded;\n}\n\n/** The commits `snapshot` recorded as not pushed: its bundle's, else those its omissions name, else its `HEAD`. */\nfunction unpushedCommits(snapshot: WorktreeSnapshot): string[] {\n\tif (snapshot.bundle) return [...snapshot.bundle.commits];\n\tconst named = snapshot.omitted.flatMap((omission) => (\"commits\" in omission ? omission.commits : []));\n\treturn named.length > 0 ? [...new Set(named)] : [snapshot.head];\n}\n\n/** `commits` without those `head`'s history holds: the restored history already has them (#4744). */\nasync function notInHistory(git: GitRunOptions, commits: readonly string[], head: string): Promise<string[]> {\n\tconst missing: string[] = [];\n\tfor (const commit of commits) {\n\t\t// Exit 1: not an ancestor; 128: not in the store, so not in the restored history either.\n\t\tconst { exitCode } = await runGit([\"merge-base\", \"--is-ancestor\", commit, head], {\n\t\t\t...git,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\tif (exitCode !== 0) missing.push(commit);\n\t}\n\treturn missing;\n}\n\n/**\n * The tree of `snapshot`'s `HEAD` with its patch chain applied in the store, link by link, up to the first link whose\n * patch is missing, corrupt or does not give the link's tree; that link and every later one are left out whole. Lists\n * the paths the left-out links touch where their patches are readable.\n */\nasync function applicableChanges(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot,\n\tblobs: SnapshotBlobStore | undefined,\n\tscratch: string,\n): Promise<{ tree: string; missingLinks: number[]; missingPaths: string[] }> {\n\tconst indexed: GitRunOptions = { ...git, env: { ...git.env, GIT_INDEX_FILE: join(scratch, \"degraded-index\") } };\n\tlet tree = await gitText([\"rev-parse\", `${snapshot.head}^{tree}`], git);\n\tawait runGit([\"read-tree\", tree], indexed);\n\tlet stop = snapshot.chain.length;\n\tconst patches: (Uint8Array | undefined)[] = [];\n\tfor (const [deltaIndex, link] of snapshot.chain.entries()) {\n\t\tconst patch =\n\t\t\tlink.patch === null\n\t\t\t\t? null\n\t\t\t\t: await loadBlob(blobs, link.patch, { snapshotId: snapshot.id, role: \"patch\", deltaIndex }).catch(\n\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\tif (isWorkspaceRestoreError(error)) return undefined;\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\tpatches.push(patch ?? undefined);\n\t\tif (stop < snapshot.chain.length) continue;\n\t\tif (patch === undefined) {\n\t\t\tstop = deltaIndex;\n\t\t\tcontinue;\n\t\t}\n\t\tif (patch !== null) {\n\t\t\tconst file = join(scratch, `degraded-${deltaIndex}.patch`);\n\t\t\tawait writing(file, snapshot.id, () => writeFile(file, patch));\n\t\t\t// `git apply` changes nothing when any hunk does not apply, so a link is applied whole or not at all.\n\t\t\tconst applied = await runGit(\n\t\t\t\t[\"apply\", \"--cached\", \"--binary\", \"--whitespace=nowarn\", \"--no-ignore-whitespace\", \"--no-3way\", file],\n\t\t\t\t{ ...indexed, allowExitCodes: [1, 128] },\n\t\t\t);\n\t\t\tif (applied.exitCode !== 0) {\n\t\t\t\tstop = deltaIndex;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tconst written = await gitText([\"write-tree\"], indexed);\n\t\tif (written !== link.tree) {\n\t\t\tawait runGit([\"read-tree\", tree], indexed);\n\t\t\tstop = deltaIndex;\n\t\t\tcontinue;\n\t\t}\n\t\ttree = written;\n\t}\n\tconst missingLinks = snapshot.chain.flatMap((_link, index) => (index >= stop ? [index] : []));\n\tconst missingPaths = new Set<string>();\n\tfor (const index of missingLinks) {\n\t\tconst patch = patches[index];\n\t\tif (!patch) continue;\n\t\tconst file = join(scratch, `degraded-${index}.patch`);\n\t\tawait writing(file, snapshot.id, () => writeFile(file, patch));\n\t\tconst listed = await runGit([\"apply\", \"--numstat\", \"-z\", file], { ...git, allowExitCodes: [1, 128] });\n\t\tif (listed.exitCode !== 0) continue;\n\t\tfor (const field of nulFields(listed.stdout)) {\n\t\t\tconst path = field.split(\"\\t\").at(-1);\n\t\t\tif (path) missingPaths.add(path);\n\t\t}\n\t}\n\treturn { tree, missingLinks, missingPaths: [...missingPaths].sort() };\n}\n\n/** Whether Git accepts `name`, a branch name from a snapshot record, as a branch name (`git check-ref-format --branch`). */\nasync function isBranchName(git: GitRunOptions, name: string): Promise<boolean> {\n\tif (name.startsWith(\"-\") || name.includes(\"@{\") || /[\\u0000-\\u001f\\u007f]/.test(name)) return false;\n\tconst { exitCode } = await runGit([\"check-ref-format\", \"--branch\", name], { ...git, allowExitCodes: [1, 128] });\n\treturn exitCode === 0;\n}\n\n/**\n * The commit nearest `snapshot`'s `HEAD` that the store holds or a recorded remote supplies: the pushed base of its\n * bundle, when the bundle is readable, then each of `candidates`, then the tip of the recorded branch (the remote's\n * default branch for a detached `HEAD`).\n */\nasync function closestCommit(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot,\n\tcandidates: readonly string[],\n\tblobs: SnapshotBlobStore | undefined,\n): Promise<{ commit: string; basis: WorktreeDegradedRestoreBasis; fromRemote: boolean } | undefined> {\n\tconst tried = new Set<string>([snapshot.head]);\n\tconst reachable = async (commit: string): Promise<{ commit: string; fromRemote: boolean } | undefined> => {\n\t\tif (tried.has(commit)) return undefined;\n\t\ttried.add(commit);\n\t\tif (await hasObject(git, `${commit}^{commit}`)) return { commit, fromRemote: false };\n\t\tconst fetched = await fetchCommits(git, snapshot.remotes, [commit]);\n\t\treturn fetched.supplied && (await hasObject(git, `${commit}^{commit}`))\n\t\t\t? { commit, fromRemote: true }\n\t\t\t: undefined;\n\t};\n\tif (snapshot.bundle) {\n\t\tconst data = await blobs?.getBlob(snapshot.bundle.blob).catch(() => undefined);\n\t\tif (data !== undefined && sha256Hex(data) === snapshot.bundle.blob) {\n\t\t\tconst prerequisites = bundlePrerequisites(data);\n\t\t\tassertUsableBundlePrerequisites(prerequisites, snapshot.id);\n\t\t\tfor (const commit of prerequisites) {\n\t\t\t\tconst found = await reachable(commit);\n\t\t\t\tif (found) return { ...found, basis: \"pushed-base\" };\n\t\t\t}\n\t\t}\n\t}\n\tfor (const commit of candidates) {\n\t\tconst found = await reachable(commit);\n\t\tif (found) return { ...found, basis: \"earlier-snapshot\" };\n\t}\n\t// The recorded branch's tip, when Git accepts its name as a branch; the remote's default branch only for a\n\t// detached HEAD, never in place of a branch that has a name.\n\tif (snapshot.branch !== null && !(await isBranchName(git, snapshot.branch))) return undefined;\n\tconst source = snapshot.branch === null ? \"HEAD\" : `refs/heads/${snapshot.branch}`;\n\tconst ref = `refs/atomic/tips/${snapshot.id}`;\n\tfor (const remote of snapshot.remotes) {\n\t\ttry {\n\t\t\tawait runFetch(git, remote, [`+${source}:${ref}`]);\n\t\t\tnoteRestoreFetch(\"full\");\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\tcontinue;\n\t\t}\n\t\tconst tip = await runGit([\"rev-parse\", \"-q\", \"--verify\", `${ref}^{commit}`], {\n\t\t\t...git,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\tawait runGit([\"update-ref\", \"-d\", ref], git);\n\t\tif (tip.exitCode === 0)\n\t\t\treturn { commit: tip.stdout.toString(\"utf8\").trim(), basis: \"branch-tip\", fromRemote: true };\n\t}\n\treturn undefined;\n}\n\ninterface PublishWorktree {\n\treadonly git: GitRunOptions;\n\treadonly store: string;\n\treadonly storeDir: string;\n\treadonly path: string;\n\treadonly into: string | undefined;\n\treadonly head: string;\n\treadonly tree: string;\n\treadonly snapshot: WorktreeSnapshot | null;\n\treadonly scratch: string;\n\treadonly warn: (warning: WorktreeRestoreWarning) => void;\n\treadonly signal: AbortSignal | undefined;\n\t/** Where an exact restore hands its LFS download instead of running it (#5099). */\n\treadonly deferLfs?: RestoreWorktreeSnapshotOptions[\"deferLfs\"];\n\t/**\n\t * What the staged worktree is checked against before it is moved to `path`: its HEAD and recomputed tree (`tree`),\n\t * or its HEAD alone (`head`), for a degraded restore whose content this host's filters may change.\n\t */\n\treadonly verify: \"tree\" | \"head\";\n}\n\n/** The staging worktree of the restore `id` into `path`: under `storeDir`, or beside `path` when the caller chose it. */\nfunction stagingPath(storeDir: string, path: string, into: string | undefined, id: string): string {\n\treturn into === undefined\n\t\t? join(storeDir, \"worktrees\", stagingWorktreeName(id))\n\t\t: join(dirname(path), `.${basename(path)}${stagingWorktreeName(id)}`);\n}\n\n/**\n * On Windows, fails a restore into `path` over the object store `store` names before it writes anything when a path it\n * would create is longer than Git for Windows accepts (#5139). Staging names have one length, whatever the id.\n */\nasync function checkPathBudget(\n\tstoreDir: string,\n\tstore: () => Promise<string>,\n\tpath: string,\n\tinto: string | undefined,\n\tsnapshotId: string | null,\n): Promise<void> {\n\tif (process.platform !== \"win32\") return;\n\tconst named = await store().then(\n\t\t(value) => ({ value }),\n\t\t() => undefined,\n\t);\n\tif (named === undefined) return;\n\tconst staging = stagingPath(storeDir, path, into, \"0\".repeat(12));\n\tassertRestorePathBudget({ storeDir, store: () => named.value, staging, target: path, snapshotId });\n}\n\n/**\n * Checks `head` and `tree` out of `store` into a staging worktree, verifies it, and moves it to `path`, under a crash\n * record, so a final path never holds an unverified worktree.\n */\nasync function publishWorktree(publish: PublishWorktree): Promise<string> {\n\tconst { git, store, storeDir, path, head, tree, snapshot, scratch, warn, signal } = publish;\n\t// Only an exact restore defers its download: a degraded one records the tree it holds after it (#5099).\n\tconst deferred = publish.verify === \"tree\" ? publish.deferLfs : undefined;\n\tlet measured = tree;\n\tconst snapshotId = snapshot?.id ?? null;\n\tawait checkTarget(path, snapshotId);\n\tconst createdTarget = (await statIfPresent(path)) === undefined;\n\tconst id = randomUUID();\n\tconst staging = stagingPath(storeDir, path, publish.into, id);\n\tconst record: RestoreRecord = { staging, target: path, store, createdTarget, tree };\n\tawait withRestoreRecord(storeDir, id, record, snapshotId, warn, signal, async (assertActive, moving, created) => {\n\t\tawait timeRestorePhase(\"materialize\", () =>\n\t\t\tmaterialize(git, store, staging, head, tree, scratch, snapshotId, created, signal),\n\t\t);\n\t\tassertActive();\n\t\tconst lfs = snapshot?.filters?.drivers.includes(\"lfs\") ? snapshot.remotes : undefined;\n\t\tconst pending: PendingLfs | undefined = lfs === undefined ? undefined : { head, tree, remotes: lfs };\n\t\t// Marked before it is published, so a worktree whose deferred download never completed says so (#5099).\n\t\tif (pending !== undefined && deferred !== undefined)\n\t\t\tawait markLfsPending({ cwd: staging, signal }, pending, snapshotId);\n\t\tif (lfs !== undefined && deferred === undefined) {\n\t\t\tconst worktree: GitRunOptions = { cwd: staging, signal };\n\t\t\tconst pointers = await timeRestorePhase(\"lfs\", () => pullLfsObjects(worktree, head, tree, lfs));\n\t\t\tif (pointers.length > 0) warn({ code: \"lfs-objects-unavailable\", paths: pointers });\n\t\t}\n\t\tmeasured = await timeRestorePhase(\"verify\", () =>\n\t\t\tverifyRestoredTree(staging, path, head, tree, publish.verify, scratch, snapshotId, signal),\n\t\t);\n\t\tassertActive();\n\t\tawait timeRestorePhase(\"publish\", () =>\n\t\t\twithRepositoryLock(store, snapshotId, signal, () => moveIntoPlace(publish, record, snapshotId, moving)),\n\t\t);\n\t\tassertActive();\n\t\tif (pending !== undefined && deferred !== undefined) {\n\t\t\tconst worktree: GitRunOptions = { cwd: path, signal };\n\t\t\t// Taken as any other process takes the download over, so it never runs beside one that took it first.\n\t\t\tdeferred(\n\t\t\t\tpath,\n\t\t\t\tdeferRestorePhase(\"lfs\", async () => finishPendingLfs(worktree, await pendingLfsPath(worktree))),\n\t\t\t);\n\t\t}\n\t});\n\treturn measured;\n}\n\n/**\n * Checks that the worktree at `dir`, restored for `target`, has HEAD `head` and, unless only HEAD is checked, the\n * neutral policy tree `tree`, ignoring conversion filters through the empty attributes file in `scratch`. Resolves to\n * the tree it measured; rejects with `tree-mismatch`.\n */\nasync function verifyRestoredTree(\n\tdir: string,\n\ttarget: string,\n\thead: string,\n\ttree: string,\n\tverify: \"tree\" | \"head\",\n\tscratch: string,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n): Promise<string> {\n\tconst checkout = await locateCheckout(dir, signal);\n\tif (checkout instanceof Error) throw checkout;\n\tconst policy = await loadSnapshotPathPolicy(dir);\n\tconst actual = await withScratchDirectory((verifyScratch) =>\n\t\twriteWorkingTree(checkout, DEFAULT_WORKTREE_SNAPSHOT_SETTINGS, policy, verifyScratch, {\n\t\t\tsignal,\n\t\t\tneutral: true,\n\t\t\tseedTree: tree,\n\t\t\tattributesFile: join(scratch, \"empty-attributes\"),\n\t\t}),\n\t);\n\tif (checkout.head !== head || (verify === \"tree\" && actual.tree !== tree)) {\n\t\tthrow new WorkspaceRestoreError(\"tree-mismatch\", {\n\t\t\tsnapshotId,\n\t\t\ttarget,\n\t\t\texpectedTree: tree,\n\t\t\tactualTree: actual.tree,\n\t\t});\n\t}\n\treturn actual.tree;\n}\n\n/**\n * Moves the verified staging worktree to the restore's final path, never into a directory that appeared there, telling\n * `moving` where the worktree may be: `unchecked` as Git is asked to move it, then `published` once it is registered at\n * that path, or `checked` once a nested move was refused.\n */\nasync function moveIntoPlace(\n\tpublish: PublishWorktree,\n\trecord: RestoreRecord,\n\tsnapshotId: string | null,\n\tmoving: (state: MoveState) => void,\n): Promise<void> {\n\tconst { git, path, signal } = publish;\n\tconst { staging, createdTarget } = record;\n\tif (createdTarget) {\n\t\tif ((await statIfPresent(path)) !== undefined) {\n\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t\t}\n\t} else {\n\t\tawait writing(path, snapshotId, () => rmdir(path));\n\t}\n\t// `-f` replaces only a registration whose directory is gone, as a store restored from a CI cache keeps for the\n\t// worktree its saving job built at this path (#4748); a directory at the path was refused above.\n\t// The move and the check of where it went are never stopped midway (#4748): a Git killed mid-move leaves a worktree\n\t// that neither the staging path nor `published` accounts for. Both are short; a stop is noticed right after them.\n\tsignal?.throwIfAborted();\n\tmoving(\"unchecked\");\n\tawait runGit([\"worktree\", \"move\", \"-f\", staging, path], { ...git, signal: undefined });\n\t// Git moves *inside* an existing directory. If one appeared after our check, never return it as the\n\t// verified worktree: remove only the nested worktree that Git registered and leave the user's files alone,\n\t// even when that directory is itself a worktree of this store.\n\tconst registered = await registeredWorktrees({ ...git, signal: undefined });\n\tconst destination = await physicalPath(path);\n\tconst nested = join(destination, basename(staging));\n\tif (includesPath(registered, destination) && !includesPath(registered, nested)) {\n\t\tmoving(\"published\");\n\t} else {\n\t\t// The cleanup that follows takes a worktree Git nested in the directory that appeared out again.\n\t\tmoving(includesPath(registered, nested) ? \"nested\" : \"checked\");\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t}\n}\n\n/** The entry at `path` itself, a symlink rather than what it points to, or undefined when there is none. */\nasync function lstatIfPresent(path: string): Promise<Stats | undefined> {\n\ttry {\n\t\treturn await lstat(path);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\tthrow unreadablePathError(path, error);\n\t}\n}\n\n/** The entry at `path`, or undefined when there is none. */\nasync function statIfPresent(path: string): Promise<Stats | undefined> {\n\ttry {\n\t\treturn await stat(path);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\tthrow unreadablePathError(path, error);\n\t}\n}\n\n/**\n * Removes a worktree that a restore created, for callers that roll back a multi-checkout restore; a path that no\n * longer exists is already removed. Refuses, with `unsafe-target` (reason `not-restored`), any path that is not a\n * worktree of a shared store under `storeDir`, including a file, so it can never touch a user's checkout.\n */\nexport async function removeRestoredWorktree(\n\tpath: string,\n\toptions: {\n\t\treadonly storeDir?: string;\n\t\treadonly signal?: AbortSignal;\n\t\treadonly onWarning?: (warning: WorktreeRestoreWarning) => void;\n\t} = {},\n): Promise<void> {\n\tconst target = resolve(path);\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst warned = new Set<string>();\n\tawait sweepRestoreRecords(\n\t\tstoreDir,\n\t\t(warning) => {\n\t\t\tif (warning.code !== \"stale-restore-retained\" || warned.has(warning.path)) return;\n\t\t\twarned.add(warning.path);\n\t\t\tif (options.onWarning) options.onWarning(warning);\n\t\t\telse\n\t\t\t\tprocess.emitWarning(\n\t\t\t\t\t`A restore interrupted earlier left ${warning.path}, which may hold your files; check them, then delete the directory yourself.`,\n\t\t\t\t);\n\t\t},\n\t\toptions.signal,\n\t);\n\tconst entry = await statIfPresent(target);\n\tif (entry === undefined) return;\n\t// A staging or set-aside directory is only ever what a cleanup kept, which may hold a user's files (#4748).\n\tif (isRestoreScratchName(basename(target)) || (await namedByRestoreRecord(storeDir, target))) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId: null, target, reason: \"not-restored\" });\n\t}\n\tconst repositories = join(storeDir, \"repositories\");\n\tconst common = entry.isDirectory()\n\t\t? await runGit([\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], {\n\t\t\t\tcwd: target,\n\t\t\t\tsignal: options.signal,\n\t\t\t\tallowExitCodes: [128],\n\t\t\t})\n\t\t: undefined;\n\tconst store = common ? resolve(common.stdout.toString(\"utf8\").trim()) : \"\";\n\tif (\n\t\tcommon?.exitCode !== 0 ||\n\t\t!isWithin(repositories, store) ||\n\t\trelative(store, target) === \"\" ||\n\t\tisWithin(store, target)\n\t) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId: null, target, reason: \"not-restored\" });\n\t}\n\tawait withRepositoryLock(store, null, options.signal, () =>\n\t\tremoveWorktree({ cwd: repositories, env: { GIT_DIR: store }, signal: options.signal }, target),\n\t);\n}\n\n/**\n * Whether `name` is one a restore gives the directory it stages its worktree in, or sets it aside in to delete it: never\n * the name of a worktree a restore returned. Earlier versions named staging `.staging-<id>` and `.<target>.atomic-restore-<id>`.\n */\nfunction isRestoreScratchName(name: string): boolean {\n\treturn (\n\t\t/^(?:\\.[sd]|\\..+\\.[sd])-[0-9a-f]{12}$/.test(name) ||\n\t\t/^\\.staging-[0-9a-f-]{36}$/.test(name) ||\n\t\t/\\.atomic-restore-[0-9a-f-]{36}$/.test(name)\n\t);\n}\n\n/** Whether a crash record under `storeDir` names `path` as its staging directory. */\nasync function namedByRestoreRecord(storeDir: string, path: string): Promise<boolean> {\n\tconst recordsDir = join(storeDir, \"restores\");\n\tconst names = await readdir(recordsDir).catch(() => [] as string[]);\n\tfor (const name of names) {\n\t\tif (!name.endsWith(\".json\")) continue;\n\t\tconst record = await readFile(join(recordsDir, name), \"utf8\")\n\t\t\t.then((text) => JSON.parse(text) as { staging?: unknown })\n\t\t\t.catch(() => undefined);\n\t\tif (typeof record?.staging === \"string\" && includesPath([record.staging], path)) return true;\n\t}\n\treturn false;\n}\n\nfunction isWithin(parent: string, child: string): boolean {\n\tconst path = relative(parent, child);\n\t// A child named like `..x` is inside; only `..` or `../…` leaves.\n\treturn path !== \"\" && path !== \"..\" && !path.startsWith(`..${sep}`) && !isAbsolute(path);\n}\n\n/**\n * Restores `target` into a new worktree and resolves to its path after verifying its HEAD and tree. Restore-time\n * notices (omitted content, conversion filters, unavailable LFS objects) go to `onWarning`.\n */\nexport async function restoreWorktreeSnapshot(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\toptions: RestoreWorktreeSnapshotOptions = {},\n): Promise<string> {\n\treturn (await restoreWorktree(target, options)).path;\n}\n\nexport interface VerifyWorktreeOptions {\n\t/** Snapshot settings that decide whether a file the recorded tree does not hold counts as drift. */\n\treadonly settings?: WorktreeSnapshotSettingsInput;\n\treadonly signal?: AbortSignal;\n}\n\n/**\n * Resolves to the binding of the checkout at `dir` when its HEAD and policy-filtered tree equal `binding`'s; rejects\n * with {@link WorkspaceDriftError} otherwise, and with the typed reason when Git or a repository is missing.\n */\nexport async function verifyWorktree(\n\tbinding: WorkspaceBinding | WorktreeSnapshot,\n\tdir: string,\n\toptions: VerifyWorktreeOptions = {},\n): Promise<WorkspaceBinding> {\n\tif (!isBinding(binding)) throw new WorkspaceConfigError(\"sdk\", \"binding\", \"a WorkspaceBinding\");\n\tif (typeof dir !== \"string\" || dir.length === 0) throw new WorkspaceConfigError(\"sdk\", \"dir\", \"a directory path\");\n\tconst settings = resolveWorktreeSnapshotSettings(options.settings, \"sdk\", \"settings\");\n\tassertUsableSnapshotRecord(binding, isSnapshot(binding) ? binding : null);\n\tconst checkout = await locateCheckout(dir, options.signal);\n\tif (checkout instanceof Error) throw checkout;\n\tif (!(await hasObject({ cwd: checkout.root, signal: options.signal }, `${binding.tree}^{tree}`))) {\n\t\tthrow new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: binding.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: binding.tree,\n\t\t\tactualTree: null,\n\t\t\tsnapshotId: isSnapshot(binding) ? binding.id : null,\n\t\t});\n\t}\n\tconst policy = await loadSnapshotPathPolicy(checkout.root);\n\tconst state = await withScratchDirectory((scratch) =>\n\t\twriteWorkingTree(checkout, settings, policy, scratch, { signal: options.signal, seedTree: binding.tree }),\n\t);\n\tif (checkout.head !== binding.head || state.tree !== binding.tree) {\n\t\tthrow new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: binding.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: binding.tree,\n\t\t\tactualTree: state.tree,\n\t\t\tsnapshotId: isSnapshot(binding) ? binding.id : null,\n\t\t});\n\t}\n\treturn {\n\t\tremotes: (await readRepositoryConfig(checkout.root, options.signal)).remotes,\n\t\thead: checkout.head,\n\t\ttree: state.tree,\n\t\tenvHash: await computeEnvironmentHash(checkout.root),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/restore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAc,MAAM,SAAS,CAAC;AACjD,OAAO,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,KAAK,EACL,IAAI,EACJ,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAA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C","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { existsSync, type Stats } from \"node:fs\";\nimport {\n\tlstat,\n\tmkdir,\n\topen,\n\treaddir,\n\treadFile,\n\treadlink,\n\trealpath,\n\trm,\n\trmdir,\n\tstat,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { devNull } from \"node:os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { setTimeout as sleep } from \"node:timers/promises\";\nimport { pathToFileURL } from \"node:url\";\nimport { pathExists } from \"../../utils/path-exists.ts\";\nimport { releaseLock } from \"../lock-release.ts\";\nimport { takeTakeoverMutexAsync } from \"../lock-takeover.js\";\nimport { renameWithRetry } from \"../rename-retry.ts\";\nimport { deferRestorePhase, noteRestoreFetch, timeRestorePhase } from \"../resume/timings.ts\";\nimport {\n\tlocateCheckout,\n\tRESTORED_TREE_FILE,\n\treadRepositoryConfig,\n\trecordRestoredTree,\n\twithScratchDirectory,\n\twriteSnapshotCommit,\n\twriteWorkingTree,\n} from \"./capture.ts\";\nimport { computeEnvironmentHash, sha256Hex } from \"./env-hash.ts\";\nimport {\n\tisWorkspaceGitError,\n\tisWorkspaceRestoreError,\n\tunreadablePathError,\n\tunwritablePathError,\n\tWorkspaceConfigError,\n\tWorkspaceDriftError,\n\tWorkspaceGitError,\n\tWorkspaceRestoreError,\n\ttype WorkspaceRestoreErrorFields,\n} from \"./errors.ts\";\nimport {\n\ttype GitExecutable,\n\ttype GitRunOptions,\n\ttype GitRunResult,\n\tgitText,\n\tnulFields,\n\trunGit,\n\twithWorktreeSnapshotGit,\n} from \"./git.ts\";\nimport {\n\tassertRestorePathBudget,\n\tcanonicalizeWorktreePathAsync,\n\tdefaultWorktreeSnapshotStoreDir,\n\tstagingWorktreeName,\n} from \"./paths.ts\";\nimport { loadSnapshotPathPolicy } from \"./policy.ts\";\nimport { HOST, holderRuns, type ProcessHolder, thisProcess } from \"./process-holder.js\";\nimport { assertUsableBundlePrerequisites, assertUsableSnapshotRecord, isAllowedRemote } from \"./records.ts\";\nimport { checkoutStoreIdOf, sameRemote, sharedRepositoryIdsOf } from \"./repository-identity.ts\";\nimport {\n\tDEFAULT_WORKTREE_SNAPSHOT_SETTINGS,\n\tresolveWorktreeSnapshotSettings,\n\ttype WorktreeSnapshotSettingsInput,\n} from \"./settings.ts\";\nimport { lockShared } from \"./shared-clock.ts\";\nimport type {\n\tSnapshotBlobStore,\n\tWorkspaceBinding,\n\tWorktreeDegradedRestore,\n\tWorktreeDegradedRestoreBasis,\n\tWorktreeRestoreWarning,\n\tWorktreeSnapshot,\n} from \"./types.ts\";\n\nexport interface RestoreWorktreeSnapshotOptions {\n\t/** New or empty directory for the restored worktree. Default: a new directory under `storeDir`/worktrees. */\n\treadonly into?: string;\n\t/** Blob storage holding the snapshot's patches and bundle. Required when the snapshot has any. */\n\treadonly blobs?: SnapshotBlobStore;\n\t/** Recorded snapshots to search when restoring a binding. */\n\treadonly snapshots?: readonly WorktreeSnapshot[];\n\t/** Host directory for the shared per-repository object stores and default worktrees. Default ~/.atomic/agent/worktree-snapshots. */\n\treadonly storeDir?: string;\n\treadonly onWarning?: (warning: WorktreeRestoreWarning) => void;\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Takes the Git LFS download of an exact restore off the restore (#5099): the restore verifies and publishes the\n\t * worktree with its LFS files still holding pointers, then hands `pull` to this callback instead of downloading.\n\t * `pull` downloads the objects into `worktree` as the restore would have, and resolves to the files that still hold\n\t * pointers, for which the restore would have warned `lfs-objects-unavailable`. A degraded restore still downloads\n\t * before it records the tree it holds.\n\t */\n\treadonly deferLfs?: (worktree: string, pull: () => Promise<readonly string[]>) => void;\n\t/**\n\t * The Git this restore runs, with the environment it needs. Default: the Git every snapshot operation resolves,\n\t * provisioned when this machine has none.\n\t */\n\treadonly git?: GitExecutable;\n}\n\nexport interface RestoredWorktree {\n\treadonly path: string;\n\treadonly snapshot: WorktreeSnapshot | null;\n\treadonly binding: WorkspaceBinding;\n\treadonly warnings: readonly WorktreeRestoreWarning[];\n}\n\n/** The warnings a restore of `snapshot` reports from its record: omitted content and source conversion settings. */\nexport function snapshotRestoreWarnings(snapshot: WorktreeSnapshot): WorktreeRestoreWarning[] {\n\treturn [\n\t\t...(snapshot.omitted.length > 0 ? [{ code: \"omitted-content\" as const, omitted: snapshot.omitted }] : []),\n\t\t...(snapshot.filters ? [{ code: \"filters\" as const, filters: snapshot.filters }] : []),\n\t];\n}\n\nexport { defaultWorktreeSnapshotStoreDir };\n\nfunction isBinding(value: unknown): value is WorkspaceBinding {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as Partial<WorkspaceBinding>;\n\treturn (\n\t\tArray.isArray(candidate.remotes) &&\n\t\tcandidate.remotes.every((remote) => typeof remote === \"string\") &&\n\t\ttypeof candidate.head === \"string\" &&\n\t\ttypeof candidate.tree === \"string\" &&\n\t\ttypeof candidate.envHash === \"string\"\n\t);\n}\n\nfunction isSnapshot(value: unknown): value is WorktreeSnapshot {\n\treturn (\n\t\tisBinding(value) &&\n\t\t(value as Partial<WorktreeSnapshot>).version === 1 &&\n\t\tArray.isArray((value as Partial<WorktreeSnapshot>).chain) &&\n\t\ttypeof (value as Partial<WorktreeSnapshot>).id === \"string\"\n\t);\n}\n\n/** Lowercase hex digest of a blob, compared with its recorded hash before Git sees its bytes. */\nasync function loadBlob(\n\tstore: SnapshotBlobStore | undefined,\n\thash: string,\n\tfields: Pick<WorkspaceRestoreErrorFields, \"snapshotId\" | \"role\" | \"deltaIndex\">,\n): Promise<Uint8Array> {\n\tconst data = await store?.getBlob(hash);\n\tif (data === undefined) throw new WorkspaceRestoreError(\"blob-missing\", { ...fields, blob: hash });\n\tif (sha256Hex(data) !== hash) throw new WorkspaceRestoreError(\"blob-corrupt\", { ...fields, blob: hash });\n\treturn data;\n}\n\nasync function checkTarget(target: string, snapshotId: string | null): Promise<void> {\n\tlet empty: boolean;\n\ttry {\n\t\tempty = (await stat(target)).isDirectory() && (await readdir(target)).length === 0;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw unreadablePathError(target, error);\n\t\tif (await belowRegularFile(target)) throw unreadablePathError(target, error);\n\t\treturn;\n\t}\n\tif (!empty) throw new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target, reason: \"not-empty\" });\n}\n\n/**\n * Whether the deepest existing ancestor of a missing `path` is not a directory. Linux reports such a path as\n * `ENOTDIR`, Windows as missing (`ENOENT`), so only its ancestors tell a path that could be created from one that cannot.\n */\nasync function belowRegularFile(path: string): Promise<boolean> {\n\tfor (let current = dirname(path); current !== dirname(current); current = dirname(current)) {\n\t\tconst entry = await statIfPresent(current);\n\t\tif (entry) return !entry.isDirectory();\n\t}\n\treturn false;\n}\n\n/** Which of `trees` the object store already holds, asked of Git in one process. */\nasync function storedTrees(git: GitRunOptions, trees: readonly string[]): Promise<Set<string>> {\n\tconst { stdout } = await runGit([\"cat-file\", \"--batch-check=%(objectname) %(objecttype)\"], {\n\t\t...git,\n\t\tinput: trees.map((tree) => `${tree}\\n`).join(\"\"),\n\t});\n\tconst stored = new Set<string>();\n\tfor (const line of stdout.toString(\"utf8\").split(\"\\n\")) {\n\t\tconst [name, type] = line.split(\" \");\n\t\tif (type === \"tree\" && name) stored.add(name);\n\t}\n\treturn stored;\n}\n\nasync function hasObject(git: GitRunOptions, object: string): Promise<boolean> {\n\tconst { exitCode } = await runGit([\"cat-file\", \"-e\", object], { ...git, allowExitCodes: [1, 128] });\n\treturn exitCode === 0;\n}\n\n/**\n * The `commits` the store lacks as commits, asked of one Git process rather than one per commit. A store that cannot\n * answer the batch is asked per commit, as {@link hasObject} does.\n */\nasync function missingCommits(git: GitRunOptions, commits: readonly string[]): Promise<string[]> {\n\tif (commits.length <= 1) {\n\t\tconst missing: string[] = [];\n\t\tfor (const commit of commits) if (!(await hasObject(git, `${commit}^{commit}`))) missing.push(commit);\n\t\treturn missing;\n\t}\n\tconst { stdout, exitCode } = await runGit([\"cat-file\", \"--batch-check=%(objecttype)\"], {\n\t\t...git,\n\t\tinput: commits.map((commit) => `${commit}^{commit}\\n`).join(\"\"),\n\t\tallowExitCodes: [128],\n\t});\n\tconst types = stdout.toString(\"utf8\").split(\"\\n\");\n\tif (exitCode !== 0 || types.length <= commits.length) {\n\t\tconst missing: string[] = [];\n\t\tfor (const commit of commits) if (!(await hasObject(git, `${commit}^{commit}`))) missing.push(commit);\n\t\treturn missing;\n\t}\n\treturn commits.filter((_, index) => types[index] !== \"commit\");\n}\n\n/** Runs a filesystem write of `target`, reporting a filesystem failure as `unwritable-path`. */\nasync function writing<T>(target: string, snapshotId: string | null, write: () => Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await write();\n\t} catch (error) {\n\t\tthrow unwritablePathError(target, snapshotId, error);\n\t}\n}\n\nconst repositoryLocks = new Map<string, Promise<void>>();\n\n/** Serializes work on one shared object store within this process, ahead of its cross-process lock. */\nasync function withProcessRepositoryLock<T>(store: string, action: () => Promise<T>): Promise<T> {\n\tconst previous = repositoryLocks.get(store) ?? Promise.resolve();\n\tlet release!: () => void;\n\tconst current = new Promise<void>((resolveLock) => {\n\t\trelease = resolveLock;\n\t});\n\tconst chained = previous.then(() => current);\n\trepositoryLocks.set(store, chained);\n\tawait previous;\n\ttry {\n\t\treturn await action();\n\t} finally {\n\t\trelease();\n\t\tif (repositoryLocks.get(store) === chained) repositoryLocks.delete(store);\n\t}\n}\n\n/** The repository lock's constants: a stopped process loses it after 30 seconds; a held one is checked every 50 ms. */\nconst REPOSITORY_LOCK_STALE_MS = 30_000;\nconst REPOSITORY_LOCK_UPDATE_MS = 10_000;\nconst REPOSITORY_LOCK_POLL_MS = 50;\n/** How long, on Windows, the repository lock is tried again while its directory is refused with EPERM. */\nexport const REPOSITORY_LOCK_REFUSED_MS = 10_000;\n\n/**\n * Whether creating the lock directory failed only for a moment: Windows refuses with EPERM to create a directory\n * another process has just removed while a third still has it open, as other waiters' checks of the lock do.\n */\nfunction refusedForAMoment(error: unknown): boolean {\n\treturn (error as NodeJS.ErrnoException).code === \"EPERM\" && process.platform === \"win32\";\n}\n\n/**\n * Serializes work on one shared object store, in this process and across processes (#4951): creating the store,\n * configuring its remotes, fetching into it and updating its refs. Git's own locks fail rather than wait, so two\n * processes doing either at once would fail one of them. Waiters in this process queue behind each other; across\n * processes, the store's lock file `<store>.lock` is polled until it is free or its holder stopped refreshing it. On\n * Windows a lock directory refused with EPERM is polled too, for up to {@link REPOSITORY_LOCK_REFUSED_MS} on end.\n */\nfunction withRepositoryLock<T>(\n\tstore: string,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n\taction: () => Promise<T>,\n): Promise<T> {\n\treturn withProcessRepositoryLock(store, async () => {\n\t\tconst unlock = await lockRepository(store, snapshotId, signal);\n\t\ttry {\n\t\t\treturn await action();\n\t\t} finally {\n\t\t\t// A release that fails leaves a lock file nothing refreshes, which the next waiter takes once it is stale.\n\t\t\tawait releaseLock(unlock, store);\n\t\t}\n\t});\n}\n\n/** Takes the cross-process lock of `store`, waiting while another live process holds it. */\nasync function lockRepository(\n\tstore: string,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n): Promise<() => Promise<void>> {\n\tconst repositories = dirname(store);\n\tawait writing(repositories, snapshotId, () => mkdir(repositories, { recursive: true }));\n\tlet refusedSince: number | undefined;\n\tfor (;;) {\n\t\tsignal?.throwIfAborted();\n\t\ttry {\n\t\t\treturn await lockShared(store, {\n\t\t\t\trealpath: false,\n\t\t\t\tstale: REPOSITORY_LOCK_STALE_MS,\n\t\t\t\tupdate: REPOSITORY_LOCK_UPDATE_MS,\n\t\t\t\tretries: 0,\n\t\t\t\t// A lost lock only lets another process into the store early, where Git's own locks still guard each write.\n\t\t\t\tonCompromised: () => {},\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (refusedForAMoment(error)) {\n\t\t\t\trefusedSince ??= Date.now();\n\t\t\t\t// A refusal that lasts is a directory this process may not write to.\n\t\t\t\tif (Date.now() - refusedSince >= REPOSITORY_LOCK_REFUSED_MS)\n\t\t\t\t\tthrow unwritablePathError(`${store}.lock`, snapshotId, error);\n\t\t\t} else if ((error as NodeJS.ErrnoException).code === \"ELOCKED\") {\n\t\t\t\trefusedSince = undefined;\n\t\t\t} else {\n\t\t\t\tthrow unwritablePathError(`${store}.lock`, snapshotId, error);\n\t\t\t}\n\t\t}\n\t\tawait sleep(REPOSITORY_LOCK_POLL_MS);\n\t}\n}\n\n/** A stopped process loses its restore lock after 30 seconds; active processes refresh it every 10 seconds. */\nconst RESTORE_LOCK_STALE_MS = 30_000;\nconst RESTORE_LOCK_UPDATE_MS = 10_000;\n\ninterface RestoreRecord {\n\treadonly staging: string;\n\treadonly target: string;\n\treadonly store: string;\n\treadonly createdTarget: boolean;\n\t/** The tree this restore checks out into its staging worktree. Records of earlier versions have none. */\n\treadonly tree?: string;\n\t/**\n\t * The identity of the staging directory as `git worktree add` created it, recorded right after, under the store lock.\n\t * A directory is set aside or deleted as this restore's only while it is that same directory: copying or moving\n\t * other files to its path never makes another directory look like it. Missing until it was recorded.\n\t */\n\treadonly identity?: DirectoryIdentity;\n}\n\n/** A directory's device, inode (a Windows file ID) and birth time, as decimal strings: what no other directory shares. */\ninterface DirectoryIdentity {\n\treadonly dev: string;\n\treadonly ino: string;\n\treadonly birthtime: string;\n}\n\nfunction isDirectoryIdentity(value: unknown): value is DirectoryIdentity {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst identity = value as Partial<DirectoryIdentity>;\n\treturn [identity.dev, identity.ino, identity.birthtime].every(\n\t\t(field) => typeof field === \"string\" && /^\\d+$/.test(field),\n\t);\n}\n\n/** Validate crash records before using their paths. Only Atomic's staging name and per-repository store are valid. */\nfunction isRestoreRecord(value: unknown, storeDir: string, id: string): value is RestoreRecord {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst record = value as Partial<RestoreRecord>;\n\tif (\n\t\ttypeof record.staging !== \"string\" ||\n\t\ttypeof record.target !== \"string\" ||\n\t\ttypeof record.store !== \"string\" ||\n\t\ttypeof record.createdTarget !== \"boolean\" ||\n\t\t(record.tree !== undefined &&\n\t\t\t(typeof record.tree !== \"string\" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(record.tree))) ||\n\t\t(record.identity !== undefined && !isDirectoryIdentity(record.identity)) ||\n\t\tresolve(record.target) !== record.target ||\n\t\tresolve(record.staging) !== record.staging ||\n\t\tresolve(record.store) !== record.store ||\n\t\tdirname(record.store) !== join(storeDir, \"repositories\") ||\n\t\t!/^[0-9a-f]{24}\\.git$/.test(basename(record.store))\n\t)\n\t\treturn false;\n\t// Earlier versions named staging worktrees `.staging-<id>` and `.<target>.atomic-restore-<id>` (#5139).\n\tconst defaultStaging = [stagingWorktreeName(id), `.staging-${id}`].map((name) => join(storeDir, \"worktrees\", name));\n\tconst { staging, target } = record;\n\tconst siblingStaging = [stagingWorktreeName(id), `.atomic-restore-${id}`].map((suffix) =>\n\t\tjoin(dirname(target), `.${basename(target)}${suffix}`),\n\t);\n\treturn (\n\t\tsiblingStaging.includes(staging) ||\n\t\t(defaultStaging.includes(staging) && dirname(target) === join(storeDir, \"worktrees\"))\n\t);\n}\n\n/** Git's registered worktree paths, without shell quoting or newline ambiguity. */\nasync function registeredWorktrees(git: GitRunOptions): Promise<string[]> {\n\treturn nulFields((await runGit([\"worktree\", \"list\", \"--porcelain\", \"-z\"], git)).stdout)\n\t\t.filter((field) => field.startsWith(\"worktree \"))\n\t\t.map((field) => field.slice(\"worktree \".length));\n}\n\nfunction includesPath(paths: readonly string[], target: string): boolean {\n\tconst normalized = resolve(target);\n\treturn paths.some((path) => {\n\t\tconst candidate = resolve(path);\n\t\treturn process.platform === \"win32\"\n\t\t\t? candidate.toLowerCase() === normalized.toLowerCase()\n\t\t\t: candidate === normalized;\n\t});\n}\n\nasync function physicalPath(path: string): Promise<string> {\n\ttry {\n\t\treturn await realpath(path);\n\t} catch (error) {\n\t\tthrow unreadablePathError(path, error);\n\t}\n}\n\n/** The administrative directory the `.git` file of the directory at `path` names, or undefined when there is none. */\nasync function worktreeAdminDir(path: string): Promise<string | undefined> {\n\ttry {\n\t\tif (!(await lstat(path)).isDirectory()) return undefined;\n\t\tconst link = join(path, \".git\");\n\t\tif (!(await lstat(link)).isFile()) return undefined;\n\t\tconst named = /^gitdir: (.+)$/m.exec(await readFile(link, \"utf8\"));\n\t\treturn named === null ? undefined : await realpath(resolve(path, named[1]!.trim()));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The administrative directory of `store` that holds a worktree's own Git files, read through any symlink. */\nasync function storeAdminDirs(store: string): Promise<string | undefined> {\n\ttry {\n\t\treturn await realpath(join(store, \"worktrees\"));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The identity of the directory at `path` itself, never what a link there points to; undefined for anything else. */\nasync function directoryIdentity(path: string): Promise<DirectoryIdentity | undefined> {\n\tconst entry = await lstat(path, { bigint: true }).catch(() => undefined);\n\tif (!entry?.isDirectory()) return undefined;\n\treturn { dev: String(entry.dev), ino: String(entry.ino), birthtime: String(entry.birthtimeNs) };\n}\n\nfunction sameIdentity(a: DirectoryIdentity, b: DirectoryIdentity): boolean {\n\treturn a.dev === b.dev && a.ino === b.ino && a.birthtime === b.birthtime;\n}\n\n/**\n * How many files whose bytes differ from their blob, as a conversion at checkout leaves them, cleanup compares with what\n * the checkout writes before it keeps the worktree, set aside, instead: each takes a Git process.\n */\nconst MAX_CONVERTED_FILES_CHECKED = 1000;\n\n/** What a file a restore checked out holds, checked again right before the file is deleted. */\ntype RestoredEntry =\n\t| { readonly kind: \"file\"; readonly algorithm: \"sha1\" | \"sha256\"; readonly digest: string; readonly blob: boolean }\n\t| { readonly kind: \"link\"; readonly target: string }\n\t| { readonly kind: \"text\"; readonly content: string };\n\n/** The digest of the file at `path` under `algorithm`, as a Git blob of `size` bytes when `blob`, else of its bytes. */\nasync function digestOf(\n\tpath: string,\n\talgorithm: \"sha1\" | \"sha256\",\n\tblob: boolean,\n\tsize: bigint | number,\n): Promise<string> {\n\tconst hash = createHash(algorithm);\n\tif (blob) hash.update(`blob ${size}\\0`);\n\tconst handle = await open(path, \"r\");\n\ttry {\n\t\tfor await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk as Buffer);\n\t} finally {\n\t\tawait handle.close();\n\t}\n\treturn hash.digest(\"hex\");\n}\n\n/** The blobs `oids` of `store`, by id; an id the store does not hold as a blob is left out. */\nasync function storeBlobs(store: string, oids: readonly string[]): Promise<Map<string, Buffer>> {\n\tconst blobs = new Map<string, Buffer>();\n\tif (oids.length === 0) return blobs;\n\tconst output = (\n\t\tawait runGit([\"cat-file\", \"--batch\"], {\n\t\t\tcwd: dirname(store),\n\t\t\tenv: { GIT_DIR: store },\n\t\t\tinput: `${oids.join(\"\\n\")}\\n`,\n\t\t})\n\t).stdout;\n\tlet at = 0;\n\twhile (at < output.length) {\n\t\tconst end = output.indexOf(10, at);\n\t\tif (end < 0) break;\n\t\tconst [oid, type, size] = output.subarray(at, end).toString(\"utf8\").split(\" \");\n\t\tat = end + 1;\n\t\tif (type !== \"blob\" || oid === undefined) continue;\n\t\tconst length = Number(size);\n\t\tblobs.set(oid, output.subarray(at, at + length));\n\t\tat += length + 1;\n\t}\n\treturn blobs;\n}\n\n/** The Git LFS object a pointer blob names, or undefined when the blob is not a pointer. */\nfunction lfsObject(pointer: Buffer): { readonly oid: string; readonly size: number } | undefined {\n\tif (pointer.length > 1024) return undefined;\n\tconst text = pointer.toString(\"utf8\");\n\tif (!text.startsWith(\"version https://git-lfs.github.com/spec/v1\\n\")) return undefined;\n\tconst oid = /^oid sha256:([0-9a-f]{64})$/m.exec(text)?.[1];\n\tconst size = /^size (\\d+)$/m.exec(text)?.[1];\n\treturn oid === undefined || size === undefined ? undefined : { oid, size: Number(size) };\n}\n\n/**\n * The files of every tree a restore may have checked out into the worktree whose administrative directory is `admin`:\n * the record's `tree`, the tree the restore recorded there and the tree of its `HEAD`. All are in `store`, so a file\n * with one of their contents at its path is never lost when it is deleted.\n */\nasync function restoredTreeEntries(\n\tstore: string,\n\ttree: string | undefined,\n\tadmin: string | undefined,\n): Promise<Map<string, { readonly mode: string; readonly oid: string }[]>> {\n\tconst git: GitRunOptions = { cwd: dirname(store), env: { GIT_DIR: store } };\n\tconst trees = new Set<string>(tree === undefined ? [] : [tree]);\n\tif (admin !== undefined) {\n\t\tconst recorded = (await readFile(join(admin, RESTORED_TREE_FILE), \"utf8\").catch(() => \"\")).trim();\n\t\tif (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(recorded)) trees.add(recorded);\n\t\tconst head = await runGit([\"rev-parse\", \"--verify\", \"--quiet\", \"HEAD^{tree}\"], {\n\t\t\t...git,\n\t\t\tenv: { GIT_DIR: admin },\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\tconst headTree = head.exitCode === 0 ? head.stdout.toString(\"utf8\").trim() : \"\";\n\t\tif (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(headTree)) trees.add(headTree);\n\t}\n\tconst entries = new Map<string, { readonly mode: string; readonly oid: string }[]>();\n\tfor (const listed of trees) {\n\t\tconst listing = await runGit([\"ls-tree\", \"-r\", \"-z\", \"--full-tree\", listed], { ...git, allowExitCodes: [128] });\n\t\tif (listing.exitCode !== 0) continue;\n\t\tfor (const field of nulFields(listing.stdout)) {\n\t\t\tconst tab = field.indexOf(\"\\t\");\n\t\t\tconst [mode, , oid] = field.slice(0, tab).split(\" \");\n\t\t\tif (mode === undefined || oid === undefined) continue;\n\t\t\tconst path = field.slice(tab + 1);\n\t\t\tentries.set(path, [...(entries.get(path) ?? []), { mode, oid }]);\n\t\t}\n\t}\n\treturn entries;\n}\n\n/**\n * What deleting the directory at `path` would delete, when that is only what a restore put there (#4748): each file has,\n * at its path, the content of a tree the restore may have checked out, as a Git blob or as the Git LFS object its\n * pointer names; each symlink that tree's target; and a root `.git` file names an administrative directory of `store`.\n * Undefined when anything else is there, or when `path` is not a directory itself.\n */\nasync function inspectRestoredContent(\n\tpath: string,\n\tstore: string,\n\ttree: string | undefined,\n\town = false,\n): Promise<Map<string, RestoredEntry> | undefined> {\n\ttry {\n\t\tif (!(await lstat(path)).isDirectory()) return undefined;\n\t\tconst admin = await worktreeAdminDir(path);\n\t\tconst admins = await storeAdminDirs(store);\n\t\tconst inStore = admin !== undefined && admins !== undefined && isWithin(admins, admin);\n\t\tconst entries = await restoredTreeEntries(store, tree, inStore ? admin : undefined);\n\t\tconst found = new Map<string, RestoredEntry>();\n\t\tconst unmatched: {\n\t\t\treadonly path: string;\n\t\t\treadonly name: string;\n\t\t\treadonly size: bigint;\n\t\t\treadonly link: boolean;\n\t\t}[] = [];\n\t\tconst visit = async (dir: string, prefix: string): Promise<boolean> => {\n\t\t\tfor (const name of await readdir(dir)) {\n\t\t\t\tconst absolute = join(dir, name);\n\t\t\t\tconst relativeName = prefix === \"\" ? name : `${prefix}/${name}`;\n\t\t\t\tconst entry = await lstat(absolute, { bigint: true });\n\t\t\t\tif (entry.isDirectory()) {\n\t\t\t\t\tif (!(await visit(absolute, relativeName))) return false;\n\t\t\t\t} else if (relativeName === \".git\" && entry.isFile()) {\n\t\t\t\t\tif (!inStore) return false;\n\t\t\t\t\tfound.set(relativeName, { kind: \"text\", content: await readFile(absolute, \"utf8\") });\n\t\t\t\t} else if (entry.isSymbolicLink()) {\n\t\t\t\t\tunmatched.push({ path: absolute, name: relativeName, size: entry.size, link: true });\n\t\t\t\t} else if (entry.isFile()) {\n\t\t\t\t\tconst candidates = entries.get(relativeName) ?? [];\n\t\t\t\t\tconst algorithm = candidates[0]?.oid.length === 64 ? \"sha256\" : \"sha1\";\n\t\t\t\t\tconst digest = candidates.length === 0 ? \"\" : await digestOf(absolute, algorithm, true, entry.size);\n\t\t\t\t\tif (candidates.some((candidate) => candidate.oid === digest && candidate.mode !== \"160000\"))\n\t\t\t\t\t\tfound.set(relativeName, { kind: \"file\", algorithm, digest, blob: true });\n\t\t\t\t\telse if (candidates.length === 0) return false;\n\t\t\t\t\telse unmatched.push({ path: absolute, name: relativeName, size: entry.size, link: false });\n\t\t\t\t} else return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\t\tif (!(await visit(path, \"\"))) return undefined;\n\t\tconst converted: { readonly name: string; readonly path: string; readonly digest: string }[] = [];\n\t\tconst blobs = await storeBlobs(\n\t\t\tstore,\n\t\t\tunmatched.flatMap((file) => (entries.get(file.name) ?? []).map((candidate) => candidate.oid)),\n\t\t);\n\t\tfor (const file of unmatched) {\n\t\t\tconst candidates = (entries.get(file.name) ?? []).flatMap((candidate) => {\n\t\t\t\tconst blob = blobs.get(candidate.oid);\n\t\t\t\treturn blob === undefined ? [] : [{ mode: candidate.mode, blob }];\n\t\t\t});\n\t\t\tif (file.link) {\n\t\t\t\tconst target = await readlink(file.path);\n\t\t\t\tif (\n\t\t\t\t\t!candidates.some(\n\t\t\t\t\t\t(candidate) => candidate.mode === \"120000\" && candidate.blob.toString(\"utf8\") === target,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn undefined;\n\t\t\t\tfound.set(file.name, { kind: \"link\", target });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst object = candidates\n\t\t\t\t.map((candidate) => lfsObject(candidate.blob))\n\t\t\t\t.find((pointer) => pointer !== undefined && BigInt(pointer.size) === file.size);\n\t\t\tconst digest = await digestOf(file.path, \"sha256\", false, file.size);\n\t\t\tif (object !== undefined && digest === object.oid) {\n\t\t\t\tfound.set(file.name, { kind: \"file\", algorithm: \"sha256\", digest, blob: false });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\town &&\n\t\t\t\t(await beginsAny(\n\t\t\t\t\tfile.path,\n\t\t\t\t\tfile.size,\n\t\t\t\t\tcandidates.map((candidate) => candidate.blob),\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\tfound.set(file.name, { kind: \"file\", algorithm: \"sha256\", digest, blob: false });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconverted.push({ name: file.name, path: file.path, digest });\n\t\t}\n\t\t// A file the checkout converted, as for an end-of-line rule or a smudge filter, is the snapshot's only when its bytes\n\t\t// are exactly what the checkout writes for that path: never because a clean filter, which may drop an edit, maps it\n\t\t// back to a blob.\n\t\tif (converted.length > MAX_CONVERTED_FILES_CHECKED || (converted.length > 0 && !inStore)) return undefined;\n\t\tfor (const file of converted) {\n\t\t\tlet written = false;\n\t\t\tfor (const candidate of entries.get(file.name) ?? []) {\n\t\t\t\tconst checkout = await runGit(\n\t\t\t\t\t[\"-c\", `core.attributesFile=${devNull}`, \"cat-file\", \"--filters\", `--path=${file.name}`, candidate.oid],\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: path,\n\t\t\t\t\t\tenv: { GIT_DIR: admin!, GIT_WORK_TREE: path, GIT_LFS_SKIP_SMUDGE: \"1\" },\n\t\t\t\t\t\tneutral: true,\n\t\t\t\t\t\tallowExitCodes: [128],\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tcheckout.exitCode === 0 &&\n\t\t\t\t\t(createHash(\"sha256\").update(checkout.stdout).digest(\"hex\") === file.digest ||\n\t\t\t\t\t\t(own && (await beginsAny(file.path, undefined, [checkout.stdout]))))\n\t\t\t\t) {\n\t\t\t\t\twritten = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!written) return undefined;\n\t\t\tfound.set(file.name, { kind: \"file\", algorithm: \"sha256\", digest: file.digest, blob: false });\n\t\t}\n\t\treturn found;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Whether the bytes of the file at `path` are a beginning of one of `contents`, as a checkout stopped while it wrote the\n * file leaves it: its whole content is then still in the store, so deleting it loses nothing.\n */\nasync function beginsAny(path: string, size: bigint | undefined, contents: readonly Buffer[]): Promise<boolean> {\n\tconst length = size === undefined ? (await lstat(path)).size : Number(size);\n\tconst longer = contents.filter((content) => content.length >= length);\n\tif (longer.length === 0) return false;\n\tconst bytes = await readFile(path);\n\treturn longer.some((content) => bytes.length <= content.length && content.subarray(0, bytes.length).equals(bytes));\n}\n\n/** Whether the entry at `path` still holds what an inspection found there. */\nasync function stillRestored(path: string, expected: RestoredEntry): Promise<boolean> {\n\tconst entry = await lstat(path, { bigint: true });\n\tif (expected.kind === \"link\") return entry.isSymbolicLink() && (await readlink(path)) === expected.target;\n\tif (!entry.isFile()) return false;\n\tif (expected.kind === \"text\") return (await readFile(path, \"utf8\")) === expected.content;\n\treturn (await digestOf(path, expected.algorithm, expected.blob, entry.size)) === expected.digest;\n}\n\n/**\n * Deletes, bottom up, what an inspection found in the directory at `path` that this process set aside: each file or link\n * only while it still holds what was found, each directory only once empty, never following a link. Anything else is\n * kept, and so is every directory above it. Resolves to whether nothing is left.\n */\nasync function deleteRestoredContent(path: string, found: ReadonlyMap<string, RestoredEntry>): Promise<boolean> {\n\tconst visit = async (dir: string, prefix: string): Promise<boolean> => {\n\t\tlet emptied = true;\n\t\tfor (const name of await readdir(dir)) {\n\t\t\tconst absolute = join(dir, name);\n\t\t\tconst relativeName = prefix === \"\" ? name : `${prefix}/${name}`;\n\t\t\tconst entry = await lstat(absolute);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (!(await visit(absolute, relativeName))) emptied = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst expected = found.get(relativeName);\n\t\t\tif (expected === undefined || !(await stillRestored(absolute, expected))) {\n\t\t\t\temptied = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait writing(absolute, null, () => rm(absolute));\n\t\t}\n\t\tif (!emptied) return false;\n\t\tawait writing(dir, null, () => rmdir(dir));\n\t\treturn true;\n\t};\n\treturn visit(path, \"\");\n}\n\n/** Where a restore sets its worktree aside to delete it: beside its staging path, `.d-` in place of `.s-`. */\nfunction asidePath(record: RestoreRecord): string {\n\tconst name = basename(record.staging);\n\tconst aside = name.replace(/\\.s-([0-9a-f]{12})$/, \".d-$1\");\n\treturn join(dirname(record.staging), aside === name ? `${name}.d` : aside);\n}\n\n/** A directory a restore moved aside under the store lock, with what an inspection found in it. */\ninterface SetAside {\n\treadonly path: string;\n\treadonly found: ReadonlyMap<string, RestoredEntry> | undefined;\n}\n\n/**\n * Under the store lock, moves this restore's worktree at `path` to its aside path (#4748). Only the directory the\n * restore created moves: one with the identity recorded when Git added it, or, for a record without one, one that holds\n * only what the restore put there. What it holds is inspected first; `found` is undefined when anything else is there,\n * so the directory is kept, aside, for the user. Resolves to undefined, moving nothing, when `path` holds no such\n * directory or something already is at the aside path.\n */\nasync function setRestoredAside(path: string, record: RestoreRecord): Promise<SetAside | undefined> {\n\tconst identity = await directoryIdentity(path);\n\tif (identity === undefined) return undefined;\n\tconst created = record.identity !== undefined && sameIdentity(identity, record.identity);\n\t// Only in the restore's own directory may a file be a checkout stopped while it wrote it.\n\tconst found = await inspectRestoredContent(path, record.store, record.tree, created);\n\tif (!created && (record.identity !== undefined || found === undefined)) return undefined;\n\tconst aside = asidePath(record);\n\tif ((await lstatIfPresent(aside)) !== undefined) return undefined;\n\tawait writing(path, null, () => renameWithRetry(path, aside));\n\treturn { path: aside, found };\n}\n\n/**\n * Deletes what this restore set aside, outside the store lock: the directory must still be the one set aside, and each\n * file still what was found in it. Throws, keeping it all, when it holds anything else.\n */\nasync function deleteSetAside(record: RestoreRecord, aside: SetAside): Promise<void> {\n\tconst identity = await directoryIdentity(aside.path);\n\tconst same = identity !== undefined && (record.identity === undefined || sameIdentity(identity, record.identity));\n\tif (!same || aside.found === undefined || !(await deleteRestoredContent(aside.path, aside.found))) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", {\n\t\t\tsnapshotId: null,\n\t\t\ttarget: aside.path,\n\t\t\treason: \"not-restored\",\n\t\t});\n\t}\n}\n\n/**\n * Under the store lock: sets the restore's staging directory aside (see {@link setRestoredAside}), restores a previously\n * empty target if needed, and has Git forget the worktree. Resolves to what to delete once the lock is released: the\n * staging directory just set aside, or one an earlier cleanup set aside and did not finish deleting. A staging\n * directory this restore did not create is kept where it is and reported.\n */\nasync function cleanRestoreRecord(record: RestoreRecord, signal?: AbortSignal): Promise<SetAside[]> {\n\tconst git: GitRunOptions = { cwd: dirname(record.store), env: { GIT_DIR: record.store }, signal };\n\tconst pending: SetAside[] = [];\n\tconst aside = asidePath(record);\n\tif ((await lstatIfPresent(aside)) !== undefined) {\n\t\tconst identity = await directoryIdentity(aside);\n\t\tconst own = identity !== undefined && record.identity !== undefined && sameIdentity(identity, record.identity);\n\t\tpending.push({ path: aside, found: await inspectRestoredContent(aside, record.store, record.tree, own) });\n\t}\n\tlet entry: Stats | undefined;\n\tlet registeredPath = record.staging;\n\ttry {\n\t\tentry = await lstat(record.staging);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw unreadablePathError(record.staging, error);\n\t}\n\tif (entry) {\n\t\tif (entry.isDirectory()) registeredPath = await physicalPath(record.staging);\n\t\tconst setAside = pending.length === 0 ? await setRestoredAside(record.staging, record) : undefined;\n\t\tif (setAside === undefined) {\n\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", {\n\t\t\t\tsnapshotId: null,\n\t\t\t\ttarget: record.staging,\n\t\t\t\treason: \"not-restored\",\n\t\t\t});\n\t\t}\n\t\tpending.push(setAside);\n\t}\n\tif (!record.createdTarget && (await statIfPresent(record.target)) === undefined) {\n\t\tawait writing(record.target, null, () => mkdir(record.target, { recursive: true }));\n\t}\n\t// Git never prunes a locked worktree, as a killed `git worktree add` leaves one; unlocking touches no files.\n\tawait runGit([\"worktree\", \"unlock\", record.staging], { ...git, allowExitCodes: [128] });\n\tawait runGit([\"worktree\", \"prune\"], git);\n\tif (includesPath(await registeredWorktrees(git), registeredPath)) {\n\t\tthrow new WorkspaceGitError({\n\t\t\toperation: \"worktree prune\",\n\t\t\tcwd: git.cwd,\n\t\t\texitCode: null,\n\t\t\tdetail: \"the staging worktree is still registered\",\n\t\t});\n\t}\n\treturn pending;\n}\n\n/**\n * Cleans up after the restore of `record`: {@link cleanRestoreRecord} under the store lock, then the deletion of what it\n * set aside outside the lock. Throws, naming where the files are kept, when anything is kept.\n */\nasync function cleanUpRestore(\n\trecord: RestoreRecord,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n\tunderLock: () => Promise<SetAside[]> = () => cleanRestoreRecord(record, signal),\n): Promise<void> {\n\tconst pending = await withRepositoryLock(record.store, snapshotId, signal, underLock);\n\tfor (const aside of pending) {\n\t\tawait deleteSetAside(record, aside).catch((error: unknown) => {\n\t\t\tif (error instanceof Error) Object.defineProperty(error, \"keptAt\", { value: aside.path, configurable: true });\n\t\t\tthrow error;\n\t\t});\n\t}\n}\n\n/** Where a failed cleanup kept the restore's files: the directory its refusal names, else where they were. */\nfunction keptPath(cause: unknown, record: RestoreRecord, moved: boolean): string {\n\tconst keptAt = (cause as { keptAt?: unknown } | undefined)?.keptAt;\n\tif (typeof keptAt === \"string\") return keptAt;\n\tif (isWorkspaceRestoreError(cause) && cause.code === \"unsafe-target\" && cause.target !== undefined)\n\t\treturn cause.target;\n\treturn moved ? record.target : record.staging;\n}\n\nfunction leftoverKind(path: string, recordPath: string): \"worktree\" | \"record\" {\n\treturn path === recordPath ? \"record\" : \"worktree\";\n}\n\n/** Sweep only unlocked or stale records, leaving active processes' staging worktrees alone. */\nasync function sweepRestoreRecords(\n\tstoreDir: string,\n\twarn: (warning: WorktreeRestoreWarning) => void,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tsignal?.throwIfAborted();\n\tconst recordsDir = join(storeDir, \"restores\");\n\tlet names: string[];\n\ttry {\n\t\tnames = await readdir(recordsDir);\n\t} catch (error) {\n\t\tsignal?.throwIfAborted();\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n\t\twarn({ code: \"stale-restore-retained\", path: recordsDir, kind: \"records-directory\" });\n\t\treturn;\n\t}\n\tfor (const name of names) {\n\t\tsignal?.throwIfAborted();\n\t\tconst match = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\\.json$/.exec(name);\n\t\tif (!match) continue;\n\t\tconst recordPath = join(recordsDir, name);\n\t\tlet release: (() => Promise<void>) | undefined;\n\t\tlet compromised: Error | undefined;\n\t\tlet warningPath = recordPath;\n\t\ttry {\n\t\t\trelease = await lockShared(recordPath, {\n\t\t\t\trealpath: false,\n\t\t\t\tstale: RESTORE_LOCK_STALE_MS,\n\t\t\t\tupdate: RESTORE_LOCK_UPDATE_MS,\n\t\t\t\tretries: 0,\n\t\t\t\tonCompromised: (error) => {\n\t\t\t\t\tcompromised = error;\n\t\t\t\t},\n\t\t\t});\n\t\t\tconst record: unknown = JSON.parse(await readFile(recordPath, \"utf8\"));\n\t\t\tif (!isRestoreRecord(record, storeDir, match[1]!)) throw new Error(\"Invalid restore crash record\");\n\t\t\twarningPath = record.staging;\n\t\t\tawait cleanUpRestore(record, null, signal).catch((cause: unknown) => {\n\t\t\t\twarningPath = keptPath(cause, record, false);\n\t\t\t\tthrow cause;\n\t\t\t});\n\t\t\tif (compromised) throw compromised;\n\t\t\tawait rm(recordPath);\n\t\t} catch (error) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\tif (!(release === undefined && code === \"ELOCKED\") && !(warningPath === recordPath && code === \"ENOENT\")) {\n\t\t\t\twarn({ code: \"stale-restore-retained\", path: warningPath, kind: leftoverKind(warningPath, recordPath) });\n\t\t\t}\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\ttry {\n\t\t\t\t\tawait release();\n\t\t\t\t} catch {\n\t\t\t\t\tif (!compromised) {\n\t\t\t\t\t\twarn({\n\t\t\t\t\t\t\tcode: \"stale-restore-retained\",\n\t\t\t\t\t\t\tpath: warningPath,\n\t\t\t\t\t\t\tkind: leftoverKind(warningPath, recordPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Where the restore's worktree may be once it asked Git to move it to its target: `unchecked` until the check after the\n * move found it there (`published`), or found it nested in a directory that appeared at the target and dealt with that.\n */\ntype MoveState = \"none\" | \"unchecked\" | \"published\" | \"nested\" | \"checked\";\n\n/**\n * Under the store lock, cleanup after a restore that failed or was stopped once it asked Git to move its worktree toward\n * the target (#4748): the worktree, at the target or nested in a directory that appeared there, is set aside like its\n * staging directory (see {@link setRestoredAside}), then {@link cleanRestoreRecord} runs. Only the restore that moved it\n * does this; the crash sweep never does, so a record that a successful restore could not remove never costs the\n * worktree it published.\n */\nasync function cleanMovedRestore(record: RestoreRecord, state: MoveState): Promise<SetAside[]> {\n\tconst git: GitRunOptions = { cwd: dirname(record.store), env: { GIT_DIR: record.store } };\n\tconst pending: SetAside[] = [];\n\tconst nested = join(record.target, basename(record.staging));\n\tconst candidates = state === \"unchecked\" ? [record.target, nested] : state === \"nested\" ? [nested] : [record.target];\n\tfor (const candidate of candidates) {\n\t\tif (pending.length > 0) break;\n\t\tconst setAside = await setRestoredAside(candidate, record);\n\t\tif (setAside !== undefined) pending.push(setAside);\n\t}\n\tif (pending.length === 0) {\n\t\t// A worktree of this restore, or one Git registered where it moved it, that could not be set aside is kept and\n\t\t// reported, with its crash record, never left behind silently.\n\t\tconst registered = await registeredWorktrees(git);\n\t\tfor (const candidate of candidates) {\n\t\t\tconst identity = await directoryIdentity(candidate);\n\t\t\tif (identity === undefined) continue;\n\t\t\tconst own = record.identity !== undefined && sameIdentity(identity, record.identity);\n\t\t\tif (own || includesPath(registered, await physicalPath(candidate))) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", {\n\t\t\t\t\tsnapshotId: null,\n\t\t\t\t\ttarget: candidate,\n\t\t\t\t\treason: \"not-restored\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\tconst staged = await cleanRestoreRecord(record);\n\treturn [...pending, ...staged.filter((aside) => !pending.some((moved) => moved.path === aside.path))];\n}\n\n/**\n * Hold a crash record lock throughout staging and publication; preserve the primary failure if cleanup fails. The\n * action calls `published` once it has moved its worktree to the target, so a failure after that removes it too.\n */\nasync function withRestoreRecord(\n\tstoreDir: string,\n\tid: string,\n\trecord: RestoreRecord,\n\tsnapshotId: string | null,\n\twarn: (warning: WorktreeRestoreWarning) => void,\n\tsignal: AbortSignal | undefined,\n\taction: (\n\t\tassertActive: () => void,\n\t\tmoving: (state: MoveState) => void,\n\t\tcreated: (identity: DirectoryIdentity) => Promise<void>,\n\t) => Promise<void>,\n): Promise<void> {\n\tconst recordsDir = join(storeDir, \"restores\");\n\tconst recordPath = join(recordsDir, `${id}.json`);\n\tawait writing(recordsDir, snapshotId, () => mkdir(recordsDir, { recursive: true }));\n\tlet compromised: Error | undefined;\n\tconst release = await writing(recordPath, snapshotId, () =>\n\t\tlockShared(recordPath, {\n\t\t\trealpath: false,\n\t\t\tstale: RESTORE_LOCK_STALE_MS,\n\t\t\tupdate: RESTORE_LOCK_UPDATE_MS,\n\t\t\tretries: 0,\n\t\t\tonCompromised: (error) => {\n\t\t\t\tcompromised = error;\n\t\t\t},\n\t\t}),\n\t);\n\tlet recorded = false;\n\tlet moveState = \"none\" as MoveState;\n\tlet primary: unknown;\n\tconst assertActive = () => {\n\t\tsignal?.throwIfAborted();\n\t\tif (compromised) {\n\t\t\tthrow new WorkspaceGitError(\n\t\t\t\t{\n\t\t\t\t\toperation: \"worktree restore\",\n\t\t\t\t\tcwd: record.staging,\n\t\t\t\t\texitCode: null,\n\t\t\t\t\tdetail: \"the staging lock was lost\",\n\t\t\t\t},\n\t\t\t\tcompromised,\n\t\t\t);\n\t\t}\n\t};\n\ttry {\n\t\tawait writing(recordPath, snapshotId, () =>\n\t\t\twriteFile(recordPath, JSON.stringify(record), { flag: \"wx\", mode: 0o600 }),\n\t\t);\n\t\trecorded = true;\n\t\tassertActive();\n\t\tawait action(\n\t\t\tassertActive,\n\t\t\t(state) => {\n\t\t\t\tmoveState = state;\n\t\t\t},\n\t\t\tasync (identity) => {\n\t\t\t\trecord = { ...record, identity };\n\t\t\t\tconst written = `${recordPath}.${process.pid}.tmp`;\n\t\t\t\tawait writing(recordPath, snapshotId, async () => {\n\t\t\t\t\tawait writeFile(written, JSON.stringify(record), { mode: 0o600 });\n\t\t\t\t\tawait renameWithRetry(written, recordPath);\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\tassertActive();\n\t\ttry {\n\t\t\tawait rm(recordPath);\n\t\t} catch {\n\t\t\twarn({ code: \"stale-restore-retained\", path: record.staging, kind: \"worktree\" });\n\t\t}\n\t} catch (error) {\n\t\tprimary = error;\n\t\tif (recorded) {\n\t\t\tconst moved = moveState === \"unchecked\" || moveState === \"published\" || moveState === \"nested\";\n\t\t\ttry {\n\t\t\t\tawait cleanUpRestore(record, snapshotId, undefined, () =>\n\t\t\t\t\tmoved ? cleanMovedRestore(record, moveState) : cleanRestoreRecord(record),\n\t\t\t\t);\n\t\t\t\tawait rm(recordPath);\n\t\t\t} catch (cleanupCause) {\n\t\t\t\tif (error instanceof Error)\n\t\t\t\t\tObject.defineProperty(error, \"cleanupCause\", { value: cleanupCause, configurable: true });\n\t\t\t\twarn({ code: \"stale-restore-retained\", path: keptPath(cleanupCause, record, moved), kind: \"worktree\" });\n\t\t\t}\n\t\t}\n\t\tthrow error;\n\t} finally {\n\t\ttry {\n\t\t\tawait release();\n\t\t} catch (error) {\n\t\t\tif (primary instanceof Error && !Object.hasOwn(primary, \"cleanupCause\")) {\n\t\t\t\tObject.defineProperty(primary, \"cleanupCause\", { value: error, configurable: true });\n\t\t\t} else if (primary === undefined) {\n\t\t\t\twarn({ code: \"stale-restore-retained\", path: record.staging, kind: \"worktree\" });\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * The object store, under `storeDir`, of the checkout at `root` whose remotes are `remotes`. Checkouts of one\n * repository share it: it is named after the normalized remotes (#4748), relative paths resolved against `root`, so\n * SSH and HTTPS checkouts of one repository share it, or after the remotes as spelled when only a store an earlier\n * version created that way exists. A checkout whose remotes name no one repository, as one without remotes, has a\n * store of its own (#4989). Undefined when that checkout's `root` is unknown: its store cannot be told apart from\n * another repository's.\n */\nexport function objectStorePath(storeDir: string, remotes: readonly string[], root?: string): string | undefined {\n\tconst [current, legacy] = sharedRepositoryIdsOf(remotes, root);\n\tconst named = (repository: string) => join(storeDir, \"repositories\", `${repository}.git`);\n\tif (current === undefined) {\n\t\treturn root === undefined || !isAbsolute(root) ? undefined : named(checkoutStoreIdOf(root));\n\t}\n\tif (legacy === undefined) return named(current);\n\treturn existsSync(named(current)) || !existsSync(named(legacy)) ? named(current) : named(legacy);\n}\n\nasync function objectStorePathAsync(\n\tstoreDir: string,\n\tremotes: readonly string[],\n\troot?: string,\n): Promise<string | undefined> {\n\tconst [current, legacy] = sharedRepositoryIdsOf(remotes, root);\n\tconst named = (repository: string) => join(storeDir, \"repositories\", `${repository}.git`);\n\tif (current === undefined) {\n\t\treturn root === undefined || !isAbsolute(root) ? undefined : named(checkoutStoreIdOf(root));\n\t}\n\tif (legacy === undefined) return named(current);\n\treturn (await pathExists(named(current))) || !(await pathExists(named(legacy))) ? named(current) : named(legacy);\n}\n\n/**\n * {@link objectStorePath} of the checkout a restore of `target` restores, its snapshot's when known; rejects with\n * `commits-unavailable` when it has none, as for a binding of a checkout without remotes and no snapshot: no store can\n * be its repository's (#4989).\n */\nasync function restoreStorePath(\n\tstoreDir: string,\n\ttarget: { readonly remotes: readonly string[]; readonly head: string },\n\tcheckout: { readonly id: string | null; readonly root: string | undefined },\n): Promise<string> {\n\tconst store = await objectStorePathAsync(storeDir, target.remotes, checkout.root);\n\tif (store !== undefined) return store;\n\tthrow new WorkspaceRestoreError(\"commits-unavailable\", {\n\t\tsnapshotId: checkout.id,\n\t\thead: target.head,\n\t\tcommits: [target.head],\n\t\tremotes: [...target.remotes],\n\t\treason: \"not-fetched\",\n\t});\n}\n\n/**\n * Puts the commit `head` of the local checkout at `checkout` into the shared object store of the repository `remotes`\n * name (#4748), so a restore of it fetches nothing from a remote: a CI job's checkout keeps its credentials to itself.\n * A shallow checkout leaves the store shallow, as a depth-1 restore fetch does.\n */\nexport async function storeCheckoutHead(\n\tstoreDir: string,\n\tremotes: readonly string[],\n\tcheckout: string,\n\thead: string,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tconst store = await restoreStorePath(resolve(storeDir), { remotes, head }, { id: null, root: checkout });\n\tconst git: GitRunOptions = { cwd: checkout, signal, env: { GIT_DIR: store } };\n\tawait withRepositoryLock(store, null, signal, async () => {\n\t\tawait ensureObjectStore(store, signal);\n\t\tif (!(await hasObject(git, `${head}^{commit}`))) await runFetch(git, checkout, [head], [\"--update-shallow\"]);\n\t});\n}\n\nasync function initializedStore(store: string): Promise<boolean> {\n\ttry {\n\t\tawait stat(join(store, \"config\"));\n\t\tawait stat(join(store, \"HEAD\"));\n\t\treturn true;\n\t} catch (error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\tif (code === \"ENOENT\" || code === \"ENOTDIR\") return false;\n\t\tthrow unreadablePathError(store, error);\n\t}\n}\n\n/**\n * Creates `store` unless it already has its configuration and HEAD. Callers hold its repository lock, so no two\n * restores, in this process or others, initialize one store at once (#4951), and an existing store is left alone:\n * re-initializing rewrites its configuration, which on Windows fails the other restores' Git processes that are\n * reading it. The store is initialized beside its place and renamed into it, so a process stopped midway leaves no\n * half-made store; a directory already there that is not one, as an older build may have left, is initialized in place.\n */\nasync function ensureObjectStore(store: string, signal?: AbortSignal): Promise<void> {\n\tif (await initializedStore(store)) return enableLongPaths(store, signal);\n\tconst repositories = dirname(store);\n\tconst fresh = join(repositories, `.${basename(store)}.${process.pid}.init`);\n\ttry {\n\t\tawait runGit([\"init\", \"-q\", \"--bare\", fresh], { cwd: repositories, signal });\n\t\tawait enableLongPaths(fresh, signal);\n\t\ttry {\n\t\t\tawait renameWithRetry(fresh, store, { signal });\n\t\t} catch {\n\t\t\tawait runGit([\"init\", \"-q\", \"--bare\", store], { cwd: repositories, signal });\n\t\t}\n\t} finally {\n\t\tawait rm(fresh, { recursive: true, force: true });\n\t}\n}\n\n/**\n * On Windows, turns on `core.longpaths` in `store`'s configuration, which its worktrees share, so Git run in a restored\n * worktree by the user or an agent handles that worktree's files past 260 characters as Atomic's own Git does (#5139).\n * A store that has it is left alone, so its configuration is rewritten at most once; a failure to write it costs only\n * that, since Atomic's own Git commands set it on their command lines. Run only under the store's repository lock.\n */\nasync function enableLongPaths(store: string, signal?: AbortSignal): Promise<void> {\n\tif (process.platform !== \"win32\") return;\n\tconst config = join(store, \"config\");\n\tconst git: GitRunOptions = { cwd: store, signal, allowExitCodes: [1] };\n\tconst current = await runGit([\"config\", \"--file\", config, \"--type=bool\", \"--get\", \"core.longpaths\"], git);\n\tif (current.stdout.toString(\"utf8\").trim() === \"true\") return;\n\tawait runGit([\"config\", \"--file\", config, \"core.longpaths\", \"true\"], git).catch(() => signal?.throwIfAborted());\n}\n\nfunction bundlePrerequisites(bundle: Uint8Array): string[] {\n\tconst end = Buffer.from(bundle).indexOf(\"\\n\\n\");\n\tconst header = Buffer.from(bundle.subarray(0, end < 0 ? Math.min(bundle.length, 65536) : end)).toString(\"utf8\");\n\treturn header\n\t\t.split(\"\\n\")\n\t\t.filter((line) => line.startsWith(\"-\"))\n\t\t.map((line) => line.slice(1).split(\" \", 1)[0]!);\n}\n\n/**\n * Transports a restore may fetch over. Recorded remotes come from storage, so Git's remote helpers (`ext::`, `fd::`,\n * custom `<name>::`) are refused; local paths stay allowed for path remotes and mirrors.\n */\nconst FETCH_TRANSPORTS = [\n\t\"-c\",\n\t\"protocol.allow=never\",\n\t...[\"https\", \"http\", \"ssh\", \"git\", \"file\"].flatMap((protocol) => [\"-c\", `protocol.${protocol}.allow=always`]),\n];\n\n/**\n * `git fetch` of `refspecs` from `repository`, with `options` such as `--depth=1`; the `--` keeps a recorded value from\n * ever being read as an option.\n */\nfunction fetchArgs(repository: string, refspecs: readonly string[], options: readonly string[]): string[] {\n\treturn [\n\t\t...FETCH_TRANSPORTS,\n\t\t\"fetch\",\n\t\t\"-q\",\n\t\t\"--no-tags\",\n\t\t\"--no-write-fetch-head\",\n\t\t...options,\n\t\t\"--\",\n\t\trepository,\n\t\t...refspecs,\n\t];\n}\n\n/** Runs {@link fetchArgs} through the runner without a way to prompt, so an unreachable or unknown host fails at once. */\nfunction runFetch(\n\tgit: GitRunOptions,\n\trepository: string,\n\trefspecs: readonly string[],\n\toptions: readonly string[] = [],\n): Promise<GitRunResult> {\n\treturn runGit(fetchArgs(repository, refspecs, options), { ...git, nonInteractive: true });\n}\n\n/** The options of a fetch that brings whole history: `--unshallow` once a depth-1 fetch left the store shallow. */\nasync function historyFetchOptions(git: GitRunOptions): Promise<string[]> {\n\treturn (await gitText([\"rev-parse\", \"--is-shallow-repository\"], git)) === \"true\" ? [\"--unshallow\"] : [];\n}\n\n/** Fetch failures that do not depend on the depth: the remote cannot be reached, or does not have the commits. */\nconst FULL_FETCH_FAILS_TOO =\n\t/could not read from remote repository|unable to access|could not resolve|does not appear to be a git repository|^ssh:|not our ref|couldn't find remote ref|unadvertised object/i;\n\ninterface RemoteFetch {\n\t/** The last fetch failure, when a remote could not supply what was still missing. */\n\treadonly failure: Error | undefined;\n\t/** Whether a recorded remote's fetch of the missing commits succeeded, so that remote has every one of them. */\n\treadonly supplied: boolean;\n}\n\n/**\n * Fetches the `commits` the store lacks from the first of `remotes` that has them, with their history; with\n * `depthFirst`, each remote is first asked for the commits alone (`--depth=1`, #4748), and asked again for their\n * history only when that fails for a reason other than an unreachable remote or missing commits.\n */\nasync function fetchCommits(\n\tgit: GitRunOptions,\n\tremotes: readonly string[],\n\tcommits: readonly string[],\n\tdepthFirst = false,\n\tknownMissing?: readonly string[],\n): Promise<RemoteFetch> {\n\tlet failure: Error | undefined;\n\tlet supplied = false;\n\t// The caller's own check of the store, made just before, answers the first remote's question.\n\tlet checked = knownMissing;\n\tfor (const remote of remotes) {\n\t\tconst missing = checked ?? (await missingCommits(git, commits));\n\t\tchecked = undefined;\n\t\tif (missing.length === 0) return { failure: undefined, supplied };\n\t\tif (depthFirst) {\n\t\t\ttry {\n\t\t\t\tawait runFetch(git, remote, missing, [\"--depth=1\"]);\n\t\t\t\tsupplied = true;\n\t\t\t\tnoteRestoreFetch(\"shallow\");\n\t\t\t\tcontinue;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\t\t// A remote or Git that refuses a depth-1 fetch gets today's full fetch; one that is unreachable or lacks the\n\t\t\t\t// commits would fail it the same way, so it is not asked twice.\n\t\t\t\tif (FULL_FETCH_FAILS_TOO.test(error.detail)) {\n\t\t\t\t\tfailure = error;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tawait runFetch(git, remote, missing, await historyFetchOptions(git));\n\t\t\tsupplied = true;\n\t\t\tnoteRestoreFetch(\"full\");\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\tfailure = error;\n\t\t}\n\t}\n\treturn { failure, supplied };\n}\n\n/**\n * Fetches the whole history of a store a depth-1 fetch left shallow, with `commits`, from the first of `remotes` that\n * supplies it, so an ancestry check across the boundary is answered (#4748). Resolves whether one did; Git refuses at\n * once, without contacting a remote, for a store that holds its whole history.\n */\nasync function unshallowStore(\n\tgit: GitRunOptions,\n\tremotes: readonly string[],\n\tcommits: readonly string[],\n): Promise<boolean> {\n\tfor (const remote of remotes) {\n\t\ttry {\n\t\t\tawait runFetch(git, remote, commits, [\"--unshallow\"]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t}\n\t}\n\treturn false;\n}\n\n/** The shared object store a restored worktree's Git directory names: Atomic's own, never a user's repository. */\nconst SHARED_STORE = /[\\\\/]repositories[\\\\/][0-9a-f]{24}\\.git$/;\n\n/**\n * Fetches the whole history of the shared object store behind the restored worktree at `root` from its recorded\n * remotes, when a depth-1 restore left that store shallow, so ancestry across the boundary is answered (#4748).\n * Resolves whether it did; a checkout that is not a restored worktree, or a failed fetch, is left as it is.\n */\nexport async function unshallowRestoredWorktree(\n\troot: string,\n\tcommits: readonly string[],\n\tsignal?: AbortSignal,\n): Promise<boolean> {\n\tconst common = await runGit([\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], {\n\t\tcwd: root,\n\t\tsignal,\n\t\tallowExitCodes: [128],\n\t});\n\tconst store = common.stdout.toString(\"utf8\").trim();\n\tif (common.exitCode !== 0 || !SHARED_STORE.test(store)) return false;\n\tconst git: GitRunOptions = { cwd: dirname(store), signal, env: { GIT_DIR: store } };\n\t// Sibling worktrees of one store are compared at once: one fetches its history, the others find it complete.\n\treturn withRepositoryLock(store, null, signal, async () =>\n\t\t(await historyFetchOptions(git)).length === 0\n\t\t\t? true\n\t\t\t: unshallowStore(git, await configuredRemoteUrls(git), commits),\n\t);\n}\n\n/**\n * Makes `snapshot.head` available in the store, from the recorded remotes or else its bundle, and resolves whether\n * it came from a recorded remote. A remote's fetch of `head` alone is tried first, at depth 1 (#4748); a bundle's\n * prerequisites are fetched with their history, as its import needs.\n */\nasync function ensureHead(\n\tgit: GitRunOptions,\n\tsnapshot: Pick<WorktreeSnapshot, \"head\" | \"remotes\" | \"bundle\" | \"omitted\"> & { readonly id: string | null },\n\tblobs: SnapshotBlobStore | undefined,\n\tscratch: string,\n): Promise<boolean> {\n\tconst { head } = snapshot;\n\tlet fetched = false;\n\tif (!(await hasObject(git, `${head}^{commit}`))) {\n\t\t// Only a fetch that succeeded proves a remote has `head`: another process may import it from a bundle meanwhile.\n\t\tconst fromRemotes = await fetchCommits(git, snapshot.remotes, [head], true, [head]);\n\t\tlet failure = fromRemotes.failure;\n\t\tfetched = fromRemotes.supplied;\n\t\tlet present = await hasObject(git, `${head}^{commit}`);\n\t\tif (!present && snapshot.bundle) {\n\t\t\tconst data = await loadBlob(blobs, snapshot.bundle.blob, { snapshotId: snapshot.id, role: \"bundle\" });\n\t\t\tconst prerequisites = bundlePrerequisites(data);\n\t\t\tassertUsableBundlePrerequisites(prerequisites, snapshot.id);\n\t\t\tfailure = (await fetchCommits(git, snapshot.remotes, prerequisites)).failure ?? failure;\n\t\t\tconst file = join(scratch, \"history.bundle\");\n\t\t\tawait writing(file, snapshot.id, () => writeFile(file, data));\n\t\t\ttry {\n\t\t\t\tawait runFetch(git, file, [\"HEAD\"]);\n\t\t\t\tnoteRestoreFetch(\"bundle\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\t\tfailure = error;\n\t\t\t}\n\t\t\tpresent = await hasObject(git, `${head}^{commit}`);\n\t\t}\n\t\tif (!present) {\n\t\t\tconst denied = snapshot.omitted.find((entry) => entry.reason === \"unpushed-history-denied\");\n\t\t\tconst overCap = snapshot.omitted.find((entry) => entry.reason === \"bundle-over-cap\");\n\t\t\tthrow new WorkspaceRestoreError(\n\t\t\t\t\"commits-unavailable\",\n\t\t\t\tdenied\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\tcommits: denied.commits,\n\t\t\t\t\t\t\tpaths: denied.paths,\n\t\t\t\t\t\t\tremotes: snapshot.remotes,\n\t\t\t\t\t\t\treason: \"denied-history\",\n\t\t\t\t\t\t}\n\t\t\t\t\t: overCap\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\t\tcommits: overCap.commits,\n\t\t\t\t\t\t\t\tremotes: snapshot.remotes,\n\t\t\t\t\t\t\t\treason: \"bundle-over-cap\",\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\t\tcommits: [head],\n\t\t\t\t\t\t\t\tremotes: snapshot.remotes,\n\t\t\t\t\t\t\t\treason: \"not-fetched\",\n\t\t\t\t\t\t\t},\n\t\t\t\tfailure,\n\t\t\t);\n\t\t}\n\t}\n\treturn fetched;\n}\n\nasync function configuredRemoteUrls(git: GitRunOptions): Promise<string[]> {\n\tconst { stdout } = await runGit([\"config\", \"-z\", \"--get-regexp\", \"^remote\\\\..+\\\\.url$\"], {\n\t\t...git,\n\t\tallowExitCodes: [1],\n\t});\n\treturn nulFields(stdout).map((field) => field.slice(field.indexOf(\"\\n\") + 1));\n}\n\n/**\n * Gives a shared object store the remotes its snapshots record, in their recorded order (the first as `origin`, then\n * `origin-2`, …), so a capture in one of its worktrees records them too. Resolves whether the store's remotes are the\n * recorded ones, however each is spelled. A store without recorded remotes, or with a remote that is not credential-free or not of a scheme a\n * restore fetches over, is left without any, as before.\n */\nasync function configureRecordedRemotes(git: GitRunOptions, remotes: readonly string[]): Promise<boolean> {\n\tif (remotes.length === 0 || !remotes.every(isAllowedRemote)) return false;\n\tlet configured = await configuredRemoteUrls(git);\n\t// A store holding the start of the recorded list was set up by a restore that stopped partway; finish it.\n\tif (configured.length < remotes.length && configured.every((remote, index) => sameRemote(remote, remotes[index]!))) {\n\t\ttry {\n\t\t\tfor (let index = configured.length; index < remotes.length; index++) {\n\t\t\t\tawait runGit([\"remote\", \"add\", \"--\", index === 0 ? \"origin\" : `origin-${index + 1}`, remotes[index]!], git);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\t// Another process configured the store at the same moment; what it wrote is compared below.\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t}\n\t\tconfigured = await configuredRemoteUrls(git);\n\t}\n\treturn (\n\t\tconfigured.length === remotes.length && configured.every((remote, index) => sameRemote(remote, remotes[index]!))\n\t);\n}\n\n/** Where a restore records commits a recorded remote has, as remote-tracking refs no remote's fetch ever prunes. */\nconst PUSHED_REFS = \"refs/remotes/atomic/pushed/\";\n\n/**\n * The commits a restore knows a recorded remote has, to record as remote-tracking refs: the snapshot's `head` when the\n * restore fetched it from one or the snapshot recorded nothing unpushed, else the parents of its bundled commits that\n * the bundle does not hold, its pushed boundary. Later captures in the store's worktrees then bundle only commits that\n * are really unpushed, and never count a commit that only a bundle carried as pushed.\n */\nasync function pushedCommits(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot | null,\n\thead: string,\n\tfetched: boolean,\n): Promise<Set<string>> {\n\tconst pushed = new Set<string>();\n\tconst historyOmitted = snapshot?.omitted.some(\n\t\t(omission) => omission.reason === \"unpushed-history-denied\" || omission.reason === \"bundle-over-cap\",\n\t);\n\tif (fetched || (snapshot !== null && snapshot.bundle === null && !historyOmitted)) pushed.add(head);\n\telse if (snapshot?.bundle) {\n\t\tconst bundled = new Set(snapshot.bundle.commits);\n\t\tconst parents = await runGit([\"rev-list\", \"--no-walk=unsorted\", \"--parents\", \"--stdin\"], {\n\t\t\t...git,\n\t\t\tinput: `${snapshot.bundle.commits.join(\"\\n\")}\\n`,\n\t\t\tallowExitCodes: [128],\n\t\t});\n\t\tif (parents.exitCode === 0) {\n\t\t\tfor (const line of parents.stdout.toString(\"utf8\").split(\"\\n\")) {\n\t\t\t\tfor (const parent of line.split(\" \").slice(1)) if (!bundled.has(parent)) pushed.add(parent);\n\t\t\t}\n\t\t}\n\t}\n\treturn pushed;\n}\n\nasync function reconstructTree(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot,\n\tpatches: readonly (Uint8Array | null)[],\n\tscratch: string,\n): Promise<void> {\n\tconst indexed: GitRunOptions = { ...git, env: { ...git.env, GIT_INDEX_FILE: join(scratch, \"restore-index\") } };\n\tconst stored = await storedTrees(\n\t\tgit,\n\t\tsnapshot.chain.map((link) => link.tree),\n\t);\n\tlet resumeAt = snapshot.chain.length;\n\twhile (resumeAt > 0 && !stored.has(snapshot.chain[resumeAt - 1]!.tree)) resumeAt--;\n\tawait runGit([\"read-tree\", resumeAt === 0 ? snapshot.head : snapshot.chain[resumeAt - 1]!.tree], indexed);\n\tfor (const [deltaIndex, link] of snapshot.chain.entries()) {\n\t\tif (deltaIndex < resumeAt) continue;\n\t\tconst patch = patches[deltaIndex];\n\t\tlet applyFailure: Error | undefined;\n\t\tif (patch) {\n\t\t\tconst file = join(scratch, `delta-${deltaIndex}.patch`);\n\t\t\tawait writing(file, snapshot.id, () => writeFile(file, patch));\n\t\t\ttry {\n\t\t\t\tawait runGit(\n\t\t\t\t\t[\"apply\", \"--cached\", \"--binary\", \"--whitespace=nowarn\", \"--no-ignore-whitespace\", \"--no-3way\", file],\n\t\t\t\t\tindexed,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\t\tapplyFailure = error;\n\t\t\t}\n\t\t}\n\t\tconst actualTree = applyFailure ? null : await gitText([\"write-tree\"], indexed);\n\t\tif (actualTree !== link.tree) {\n\t\t\tthrow new WorkspaceRestoreError(\n\t\t\t\t\"delta-failed\",\n\t\t\t\t{\n\t\t\t\t\tsnapshotId: snapshot.id,\n\t\t\t\t\tdeltaIndex,\n\t\t\t\t\t...(link.patch ? { blob: link.patch } : {}),\n\t\t\t\t\texpectedTree: link.tree,\n\t\t\t\t\tactualTree,\n\t\t\t\t},\n\t\t\t\tapplyFailure,\n\t\t\t);\n\t\t}\n\t}\n}\n\nasync function lfsPaths(worktree: GitRunOptions): Promise<string[]> {\n\tconst files = (await runGit([\"ls-files\", \"-z\"], worktree)).stdout;\n\tconst fields = nulFields(\n\t\t(await runGit([\"check-attr\", \"--stdin\", \"-z\", \"filter\"], { ...worktree, input: files })).stdout,\n\t);\n\tconst paths: string[] = [];\n\tfor (let index = 0; index + 2 < fields.length; index += 3) {\n\t\tif (fields[index + 2] === \"lfs\") paths.push(fields[index]!);\n\t}\n\treturn paths;\n}\n\n/** The form of a recorded remote that Git LFS can find its server from: a local path needs to be a `file://` URL. */\nfunction lfsRemote(remote: string): string {\n\treturn isAbsolute(remote) ? pathToFileURL(remote).href : remote;\n}\n\nconst LFS_POINTER_PREFIX = Buffer.from(\"version https://git-lfs.github.com/spec/v1\");\nconst LFS_POINTER_MAX_BYTES = 1024;\n\nasync function isLfsPointer(file: string): Promise<boolean> {\n\ttry {\n\t\tif (!(await lstat(file)).isFile()) return false;\n\t\tconst handle = await open(file, \"r\");\n\t\ttry {\n\t\t\tconst buffer = Buffer.alloc(LFS_POINTER_MAX_BYTES);\n\t\t\tconst { bytesRead } = await handle.read(buffer, 0, LFS_POINTER_MAX_BYTES, 0);\n\t\t\treturn (\n\t\t\t\tbytesRead < LFS_POINTER_MAX_BYTES &&\n\t\t\t\tbuffer.subarray(0, LFS_POINTER_PREFIX.length).equals(LFS_POINTER_PREFIX)\n\t\t\t);\n\t\t} finally {\n\t\t\tawait handle.close();\n\t\t}\n\t} catch (error) {\n\t\tthrow unreadablePathError(file, error);\n\t}\n}\n\nasync function remainingPointers(root: string, paths: readonly string[]): Promise<string[]> {\n\tconst pointers: string[] = [];\n\tfor (const path of paths) if (await isLfsPointer(join(root, path))) pointers.push(path);\n\treturn pointers;\n}\n\n/**\n * Downloads the Git LFS objects of the snapshot's tree into the staged worktree from each recorded remote in turn,\n * while any LFS file still holds a pointer, and returns the files that still do. `git lfs pull` fetches only the\n * objects of HEAD's tree and its exit status does not say which files arrived, so the staged HEAD and index name the\n * snapshot's commit during the pulls, and the files themselves are inspected after each one. The staging worktree\n * belongs to a per-repository store that is created without remotes, so each recorded remote is named explicitly,\n * after `--` so that a value can never be read as an option, and the download can never wait for a person.\n */\nasync function pullLfsObjects(\n\tworktree: GitRunOptions,\n\thead: string,\n\ttree: string,\n\tremotes: readonly string[],\n): Promise<string[]> {\n\tconst snapshotCommit = await writeSnapshotCommit(worktree, head, tree);\n\tawait runGit([\"update-ref\", \"--no-deref\", \"HEAD\", snapshotCommit], worktree);\n\tawait runGit([\"read-tree\", snapshotCommit], worktree);\n\tlet pointers = await remainingPointers(worktree.cwd, await lfsPaths(worktree));\n\tfor (const remote of remotes) {\n\t\tif (pointers.length === 0) break;\n\t\ttry {\n\t\t\tawait runGit([\"lfs\", \"pull\", \"--\", lfsRemote(remote)], { ...worktree, nonInteractive: true });\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\tworktree.signal?.throwIfAborted();\n\t\t}\n\t\tpointers = await remainingPointers(worktree.cwd, pointers);\n\t}\n\tawait runGit([\"update-ref\", \"--no-deref\", \"HEAD\", head], worktree);\n\tawait runGit([\"read-tree\", head], worktree);\n\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...worktree, neutral: true, allowExitCodes: [1] });\n\treturn pointers;\n}\n\n/**\n * The file in a restored worktree's own Git directory that says its LFS download has not completed (#5099): written\n * before a worktree whose download is deferred is published, removed once every LFS file has its content, so a resume\n * interrupted during the download leaves the next one a way to finish it.\n */\nconst LFS_PENDING_FILE = \"atomic-lfs-pending.json\";\n\ninterface PendingLfs {\n\treadonly head: string;\n\treadonly tree: string;\n\treadonly remotes: readonly string[];\n\t/** The process downloading, while one is: its Git steps may leave locks behind if it is killed. */\n\treadonly holder?: ProcessHolder;\n}\n\n/**\n * How long a download whose process cannot be told from a later one given its id, where its start cannot be read,\n * counts as running: past this its locks are its leftovers.\n */\nconst UNSTARTED_LFS_HOLDER_LIMIT_MS = 24 * 60 * 60_000;\n\n/** The marks of the worktrees this process is downloading into now. */\nconst pullingHere = new Set<string>();\n\n/** `name` in the worktree's own Git directory. */\nasync function worktreeGitPath(worktree: GitRunOptions, name: string): Promise<string> {\n\treturn resolve(worktree.cwd, await gitText([\"rev-parse\", \"--path-format=absolute\", \"--git-path\", name], worktree));\n}\n\nfunction pendingLfsPath(worktree: GitRunOptions): Promise<string> {\n\treturn worktreeGitPath(worktree, LFS_PENDING_FILE);\n}\n\nasync function markLfsPending(worktree: GitRunOptions, pending: PendingLfs, snapshotId: string | null): Promise<void> {\n\tconst marker = await pendingLfsPath(worktree);\n\tawait writing(marker, snapshotId, () => writeFile(marker, JSON.stringify(pending)));\n}\n\n/**\n * Replaces the mark of a worktree that other processes may read at once: written beside it and renamed over it, so a\n * reader finds the old mark or the new one, never one a write has truncated, which reads as unusable and is removed.\n */\nasync function rewritePendingMark(marker: string, pending: PendingLfs): Promise<void> {\n\tconst partial = `${marker}.${randomUUID()}.partial`;\n\ttry {\n\t\tawait writeFile(partial, JSON.stringify(pending));\n\t\tawait renameWithRetry(partial, marker);\n\t} catch (error) {\n\t\tawait rm(partial, { force: true });\n\t\tthrow error;\n\t}\n}\n\n/** {@link pullLfsObjects} into a worktree marked pending, clearing the mark once no LFS file holds a pointer. */\nasync function pullPendingLfs(worktree: GitRunOptions, pending: PendingLfs): Promise<string[]> {\n\tconst marker = await pendingLfsPath(worktree);\n\tconst waiting: PendingLfs = { head: pending.head, tree: pending.tree, remotes: pending.remotes };\n\tpullingHere.add(marker);\n\ttry {\n\t\tawait rewritePendingMark(marker, { ...waiting, holder: await thisProcess() });\n\t\tconst pointers = await pullLfsObjects(worktree, pending.head, pending.tree, pending.remotes);\n\t\tif (pointers.length === 0) await rm(marker, { force: true });\n\t\telse await rewritePendingMark(marker, waiting);\n\t\treturn pointers;\n\t} finally {\n\t\tpullingHere.delete(marker);\n\t}\n}\n\n/**\n * Whether the download that `pending` names is still running, in this process or another, so nothing of it may be\n * touched. A download whose process is gone may have left `HEAD.lock` or `index.lock` behind.\n */\nasync function lfsHolderRuns(marker: string, pending: PendingLfs): Promise<boolean> {\n\tif (pullingHere.has(marker)) return true;\n\tconst holder = pending.holder;\n\tif (holder === undefined) return false;\n\t// This process, when it is not downloading into the worktree, stopped the download that names it.\n\tif (holder.host === HOST && holder.pid === process.pid) return false;\n\ttry {\n\t\tconst age = Date.now() - (await stat(marker)).mtimeMs;\n\t\treturn await holderRuns(holder, age, UNSTARTED_LFS_HOLDER_LIMIT_MS);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return true;\n\t\tthrow error;\n\t}\n}\n\nfunction isPendingLfs(value: unknown): value is PendingLfs {\n\tconst pending = value as Partial<PendingLfs> | null;\n\treturn (\n\t\ttypeof pending?.head === \"string\" &&\n\t\t/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(pending.head) &&\n\t\ttypeof pending.tree === \"string\" &&\n\t\t/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(pending.tree) &&\n\t\tArray.isArray(pending.remotes) &&\n\t\tpending.remotes.every((remote) => typeof remote === \"string\" && isAllowedRemote(remote)) &&\n\t\t(pending.holder === undefined ||\n\t\t\t(typeof pending.holder?.host === \"string\" &&\n\t\t\t\tNumber.isSafeInteger(pending.holder.pid) &&\n\t\t\t\t(pending.holder.start === undefined || typeof pending.holder.start === \"string\")))\n\t);\n}\n\n/** How long a resume waits for another running process to finish a download it holds before it warns (#5099). */\nexport const LFS_HOLDER_WAIT_MS = 10 * 60_000;\n/** How often a resume waiting for another process's download checks on it. */\nconst LFS_HOLDER_POLL_MS = 250;\n\n/**\n * The Git LFS download left unfinished in the restored worktree at `worktree` (#5099), by a resume that was interrupted\n * or by another Atomic process still running it, or undefined when none is pending. The returned function finishes it\n * and resolves to the files that still hold pointers, as a restore's download does: it waits for a running process to\n * end its download, at most {@link LFS_HOLDER_WAIT_MS}, and takes over from one that stopped. A worktree whose `HEAD`\n * moved since its restore, or whose mark cannot be read, is not changed: the function then rejects, saying to run\n * `git lfs pull` there, and the mark is removed so this is said once.\n */\nexport async function pendingLfsDownload(\n\tworktree: string,\n\toptions: { readonly signal?: AbortSignal } = {},\n): Promise<(() => Promise<readonly string[]>) | undefined> {\n\tconst git: GitRunOptions = { cwd: worktree, signal: options.signal };\n\tconst marker = await pendingLfsPath(git);\n\tif ((await readPendingMark(marker)) === undefined) return undefined;\n\treturn () => finishPendingLfs(git, marker);\n}\n\nasync function readPendingMark(marker: string): Promise<string | undefined> {\n\ttry {\n\t\treturn await readFile(marker, \"utf8\");\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\tthrow error;\n\t}\n}\n\nasync function finishPendingLfs(git: GitRunOptions, marker: string): Promise<string[]> {\n\tconst waitingSince = Date.now();\n\tfor (;;) {\n\t\tconst text = await readPendingMark(marker);\n\t\t// Its process finished the download: every LFS file has its content.\n\t\tif (text === undefined) return [];\n\t\tconst pending = parsePendingLfs(text);\n\t\tif (pending === undefined || !(await lfsHolderRuns(marker, pending))) {\n\t\t\tconst claim = await claimPendingLfs(git, marker);\n\t\t\tif (claim.kind === \"finished\") return [];\n\t\t\tif (claim.kind === \"claimed\") {\n\t\t\t\ttry {\n\t\t\t\t\treturn await takeOverPendingLfs(git, marker, claim.pending);\n\t\t\t\t} finally {\n\t\t\t\t\tpullingHere.delete(marker);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (Date.now() - waitingSince >= LFS_HOLDER_WAIT_MS) return remainingPointers(git.cwd, await lfsPaths(git));\n\t\tawait sleep(LFS_HOLDER_POLL_MS, undefined, { signal: git.signal });\n\t}\n}\n\n/** How a {@link claimPendingLfs} went: the download is done, another process runs it, or this process now holds it. */\ntype LfsClaim =\n\t| { readonly kind: \"finished\" }\n\t| { readonly kind: \"running\" }\n\t| { readonly kind: \"claimed\"; readonly pending: PendingLfs | undefined };\n\n/**\n * Makes this process the holder of the download pending in the worktree, when its process stopped or it names none,\n * one process at a time: under the takeover mutex of its mark, an advisory lock the kernel releases when its holder\n * dies (#5193), the mark is read again, the locks a stopped download's Git steps left are removed, and the mark names\n * this process before the mutex is released. Another process that judged the same download stopped then finds this\n * one running it and waits, rather than removing the locks this one's Git holds, or downloading beside it.\n */\nasync function claimPendingLfs(git: GitRunOptions, marker: string): Promise<LfsClaim> {\n\tconst locks = await Promise.all([\"HEAD.lock\", \"index.lock\"].map((name) => worktreeGitPath(git, name)));\n\tconst mutex = await takeTakeoverMutexAsync(marker, 0);\n\tif (mutex === undefined) return { kind: \"running\" };\n\ttry {\n\t\tconst text = await readPendingMark(marker);\n\t\tif (text === undefined) return { kind: \"finished\" };\n\t\tconst pending = parsePendingLfs(text);\n\t\tif ((pending !== undefined && (await lfsHolderRuns(marker, pending))) || !(await mutex.owned()))\n\t\t\treturn { kind: \"running\" };\n\t\t// A download killed during its Git steps leaves their locks; nothing else takes them in a worktree with a mark.\n\t\tif (pending?.holder !== undefined) for (const lock of locks) await rm(lock, { force: true });\n\t\tif (pending !== undefined) {\n\t\t\tconst { head, tree, remotes } = pending;\n\t\t\tawait rewritePendingMark(marker, { head, tree, remotes, holder: await thisProcess() });\n\t\t\tpullingHere.add(marker);\n\t\t}\n\t\treturn { kind: \"claimed\", pending };\n\t} finally {\n\t\tawait mutex.release();\n\t}\n}\n\n/** Finishes the download pending in the worktree once this process holds it ({@link claimPendingLfs}). */\nasync function takeOverPendingLfs(\n\tgit: GitRunOptions,\n\tmarker: string,\n\tpending: PendingLfs | undefined,\n): Promise<string[]> {\n\tconst head = await gitText([\"rev-parse\", \"-q\", \"--verify\", \"HEAD^{commit}\"], { ...git, allowExitCodes: [1] });\n\t// A download cut off mid-pull leaves HEAD at the snapshot's commit, which it names while it runs.\n\tif (\n\t\tpending !== undefined &&\n\t\t(head === pending.head || head === (await writeSnapshotCommit(git, pending.head, pending.tree)))\n\t) {\n\t\treturn pullPendingLfs(git, pending);\n\t}\n\tawait rm(marker, { force: true });\n\tthrow new Error(\n\t\t\"its LFS download was interrupted and the worktree changed since, so it was not repeated; run `git lfs pull` in it\",\n\t);\n}\n\nfunction parsePendingLfs(text: string): PendingLfs | undefined {\n\ttry {\n\t\tconst pending: unknown = JSON.parse(text);\n\t\treturn isPendingLfs(pending) ? pending : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function materialize(\n\tgit: GitRunOptions,\n\tstore: string,\n\ttarget: string,\n\thead: string,\n\ttree: string,\n\tscratch: string,\n\tsnapshotId: string | null,\n\tcreated: (identity: DirectoryIdentity) => Promise<void>,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tawait withRepositoryLock(store, snapshotId, signal, async () => {\n\t\t// Git adds a worktree into an empty directory too: only one it creates itself is the restore's.\n\t\tif ((await lstatIfPresent(target)) !== undefined) {\n\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target, reason: \"not-empty\" });\n\t\t}\n\t\tawait runGit([\"worktree\", \"add\", \"-q\", \"--detach\", \"--no-checkout\", target, head], git);\n\t\tconst identity = await directoryIdentity(target);\n\t\tif (identity !== undefined) await created(identity);\n\t});\n\tconst attributes = join(scratch, \"empty-attributes\");\n\tawait writing(attributes, snapshotId, () => writeFile(attributes, \"\"));\n\tconst neutral: GitRunOptions = { cwd: target, signal, neutral: true, env: { GIT_LFS_SKIP_SMUDGE: \"1\" } };\n\tawait runGit([\"-c\", `core.attributesFile=${attributes}`, \"read-tree\", \"--reset\", \"-u\", tree], neutral);\n\tawait runGit([\"read-tree\", head], neutral);\n\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...neutral, allowExitCodes: [1] });\n\tawait recordRestoredTree(neutral, tree);\n}\n\n/** Removes the restored worktree at `target` from the store `git` points at, then prunes what its removal left. */\nasync function removeWorktree(git: GitRunOptions, target: string): Promise<void> {\n\tawait runGit([\"worktree\", \"remove\", \"--force\", target], { ...git, signal: undefined, allowExitCodes: [128] });\n\tawait writing(target, null, () => rm(target, { recursive: true, force: true }));\n\tawait runGit([\"worktree\", \"prune\"], { ...git, signal: undefined });\n}\n\nfunction resolveSnapshot(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\tsnapshots: readonly WorktreeSnapshot[] | undefined,\n): WorktreeSnapshot | null {\n\tif (isSnapshot(target)) return target;\n\tconst candidates = (snapshots ?? []).filter(\n\t\t(snapshot) => isSnapshot(snapshot) && snapshot.tree === target.tree && snapshot.head === target.head,\n\t);\n\treturn candidates.at(-1) ?? null;\n}\n\n/**\n * Restores a snapshot, or the snapshot a binding names, into a new worktree over the host's shared object store for\n * its repository, and returns the worktree only after its HEAD and recomputed tree match. Checks the target and every\n * blob before writing to the target; on failure removes what it created and throws a typed error. With `git`, every Git\n * command of the restore runs that executable.\n */\nexport async function restoreWorktree(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\toptions: RestoreWorktreeSnapshotOptions = {},\n): Promise<RestoredWorktree> {\n\tif (!isBinding(target)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"target\", \"a WorkspaceBinding or a WorktreeSnapshot\");\n\t}\n\tif (options.into !== undefined && (typeof options.into !== \"string\" || options.into.length === 0)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"into\", \"a directory path\");\n\t}\n\tif (options.git !== undefined && (typeof options.git?.path !== \"string\" || options.git.path.length === 0)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"git\", \"a Git executable with a non-empty path\");\n\t}\n\treturn withWorktreeSnapshotGit(options.git, () => restoreValidated(target, options, undefined));\n}\n\n/**\n * {@link restoreWorktree} into `slot`, a pooled slot path under `storeDir`/worktrees that does not exist yet (#4748),\n * staged like a restore into a new default path. Session resumes use it; `into` stays the SDK's way to choose a path.\n */\nexport async function restoreWorktreeAt(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\tslot: string,\n\toptions: Omit<RestoreWorktreeSnapshotOptions, \"into\"> & {\n\t\t/** The root of the checkout a binding was recorded in, which its relative-path remotes are relative to (#4989). */\n\t\treadonly root?: string;\n\t} = {},\n): Promise<RestoredWorktree> {\n\tif (!isBinding(target)) {\n\t\tthrow new WorkspaceConfigError(\"sdk\", \"target\", \"a WorkspaceBinding or a WorktreeSnapshot\");\n\t}\n\treturn withWorktreeSnapshotGit(options.git, () => restoreValidated(target, options, slot, options.root));\n}\n\nasync function restoreValidated(\n\ttarget: WorkspaceBinding,\n\toptions: RestoreWorktreeSnapshotOptions,\n\tslot: string | undefined,\n\troot?: string,\n): Promise<RestoredWorktree> {\n\tconst { signal } = options;\n\tconst snapshot = resolveSnapshot(target, options.snapshots);\n\tassertUsableSnapshotRecord(target, snapshot);\n\tconst snapshotId = snapshot?.id ?? null;\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst path = resolve(\n\t\toptions.into ??\n\t\t\tslot ??\n\t\t\tjoin(storeDir, \"worktrees\", `${(snapshot?.id ?? target.tree).slice(0, 12)}-${randomUUID().slice(0, 8)}`),\n\t);\n\tawait checkTarget(path, snapshotId);\n\tconst patches = await snapshotPatches(snapshot, options.blobs);\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst retained = new Set<string>();\n\tconst warn = (warning: WorktreeRestoreWarning) => {\n\t\tif (warning.code === \"stale-restore-retained\") {\n\t\t\tif (retained.has(warning.path)) return;\n\t\t\tretained.add(warning.path);\n\t\t}\n\t\twarnings.push(warning);\n\t\toptions.onWarning?.(warning);\n\t};\n\tawait checkPathBudget(\n\t\tstoreDir,\n\t\t() => restoreStorePath(storeDir, target, snapshot ?? { id: null, root }),\n\t\tpath,\n\t\toptions.into,\n\t\tsnapshotId,\n\t);\n\tawait sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = await restoreStorePath(storeDir, target, snapshot ?? { id: null, root });\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tawait storeSnapshotObjects(git, store, target, snapshot, patches, options.blobs, scratch);\n\t\tawait publishWorktree({\n\t\t\tgit,\n\t\t\tstore,\n\t\t\tstoreDir,\n\t\t\tpath,\n\t\t\tinto: options.into,\n\t\t\thead: target.head,\n\t\t\ttree: target.tree,\n\t\t\tsnapshot,\n\t\t\tscratch,\n\t\t\twarn,\n\t\t\tsignal,\n\t\t\tverify: \"tree\",\n\t\t\t// The download runs later, with the Git this restore runs.\n\t\t\tdeferLfs:\n\t\t\t\toptions.deferLfs &&\n\t\t\t\t((worktree, pull) => options.deferLfs!(worktree, () => withWorktreeSnapshotGit(options.git, pull))),\n\t\t});\n\t\tif (snapshot) for (const warning of snapshotRestoreWarnings(snapshot)) warn(warning);\n\t\treturn {\n\t\t\tpath,\n\t\t\tsnapshot,\n\t\t\tbinding: { remotes: [...target.remotes], head: target.head, tree: target.tree, envHash: target.envHash },\n\t\t\twarnings,\n\t\t};\n\t});\n}\n\n/**\n * Makes `target`'s commit and tree objects of the shared store `store`, which `git` points at: fetches or unbundles the\n * commit when the store lacks it, keeps it and the commits known to be pushed referenced, and rebuilds the tree from\n * the snapshot's change sets when the store lacks it too.\n */\nasync function storeSnapshotObjects(\n\tgit: GitRunOptions,\n\tstore: string,\n\ttarget: WorkspaceBinding,\n\tsnapshot: WorktreeSnapshot | null,\n\tpatches: readonly (Uint8Array | null)[],\n\tblobs: SnapshotBlobStore | undefined,\n\tscratch: string,\n): Promise<void> {\n\tawait withRepositoryLock(store, snapshot?.id ?? null, git.signal, async () => {\n\t\tawait ensureObjectStore(store, git.signal);\n\t\tconst fetched = await timeRestorePhase(\"fetch\", () =>\n\t\t\tensureHead(\n\t\t\t\tgit,\n\t\t\t\tsnapshot ?? { id: null, head: target.head, remotes: target.remotes, bundle: null, omitted: [] },\n\t\t\t\tblobs,\n\t\t\t\tscratch,\n\t\t\t),\n\t\t);\n\t\t// What a snapshot of other remotes, such as a fork at the same commit, says is pushed is not this store's.\n\t\tconst sameRemotes =\n\t\t\tsnapshot === null ||\n\t\t\t(snapshot.remotes.length === target.remotes.length &&\n\t\t\t\tsnapshot.remotes.every((remote, index) => sameRemote(remote, target.remotes[index]!)));\n\t\tconst pushed =\n\t\t\t(await configureRecordedRemotes(git, target.remotes)) && sameRemotes\n\t\t\t\t? await pushedCommits(git, snapshot, target.head, fetched)\n\t\t\t\t: new Set<string>();\n\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t...git,\n\t\t\tinput: [\n\t\t\t\t`update refs/atomic/heads/${target.head} ${target.head}\\n`,\n\t\t\t\t...[...pushed].map((commit) => `update ${PUSHED_REFS}${commit} ${commit}\\n`),\n\t\t\t].join(\"\"),\n\t\t});\n\t\tif (!(await hasObject(git, `${target.tree}^{tree}`))) {\n\t\t\tif (!snapshot) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"snapshot-not-found\", {\n\t\t\t\t\tsnapshotId: null,\n\t\t\t\t\thead: target.head,\n\t\t\t\t\ttree: target.tree,\n\t\t\t\t});\n\t\t\t}\n\t\t\tawait timeRestorePhase(\"reconstruct\", () => reconstructTree(git, snapshot, patches, scratch));\n\t\t}\n\t});\n}\n\n/** The change sets of `snapshot`'s chain, each checked against its recorded hash; null for a link without one. */\nfunction snapshotPatches(\n\tsnapshot: WorktreeSnapshot | null,\n\tblobs: SnapshotBlobStore | undefined,\n): Promise<(Uint8Array | null)[]> {\n\tif (!snapshot) return Promise.resolve([]);\n\treturn Promise.all(\n\t\tsnapshot.chain.map((link, deltaIndex) =>\n\t\t\tlink.patch === null\n\t\t\t\t? null\n\t\t\t\t: loadBlob(blobs, link.patch, { snapshotId: snapshot.id, role: \"patch\", deltaIndex }),\n\t\t),\n\t);\n}\n\n/**\n * Makes `snapshot`'s commit and tree objects of this host's shared object store for its repository, as a restore does,\n * without writing a worktree, and resolves with the store's path (#4922). Rejects with the restore's typed failures,\n * such as `blob-missing` or `commits-unavailable`, and `invalid-snapshot` for a record that fails the security checks.\n */\nexport async function storeSnapshotTree(\n\tsnapshot: WorktreeSnapshot,\n\toptions: Pick<RestoreWorktreeSnapshotOptions, \"blobs\" | \"storeDir\" | \"signal\">,\n): Promise<string> {\n\tconst binding: WorkspaceBinding = { ...snapshot, remotes: [...snapshot.remotes] };\n\tassertUsableSnapshotRecord(binding, snapshot);\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst patches = await snapshotPatches(snapshot, options.blobs);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = await restoreStorePath(storeDir, snapshot, snapshot);\n\t\tconst git: GitRunOptions = { cwd: scratch, signal: options.signal, env: { GIT_DIR: store } };\n\t\tawait storeSnapshotObjects(git, store, binding, snapshot, patches, options.blobs, scratch);\n\t\treturn store;\n\t});\n}\n\nexport interface ResetPooledWorktreeOptions {\n\treadonly storeDir: string;\n\treadonly blobs?: SnapshotBlobStore;\n\treadonly signal?: AbortSignal;\n\t/** Runs once the snapshot's objects are in the store, right before the first write to the worktree. */\n\treadonly beforeReset: () => Promise<void>;\n}\n\n/**\n * Resets the existing pooled worktree at `slot`, whose files are exactly the recorded tree `from`, to `snapshot`\n * (#4748): files `from` holds and the snapshot does not are removed, the snapshot's are written where they differ, and\n * HEAD and the index name the snapshot's commit. Files Git ignores, such as dependencies and build output, stay;\n * unchanged files keep their timestamps. Resolves to the restore's warnings once HEAD and the recomputed tree match\n * the snapshot; rejects with `tree-mismatch` when they do not. A failure before `beforeReset` ran left the worktree\n * untouched. Only the pool's claim calls this: it is the one way an existing worktree is rewritten.\n */\nexport async function resetPooledWorktree(\n\tsnapshot: WorktreeSnapshot,\n\tslot: string,\n\tfrom: { readonly tree: string },\n\toptions: ResetPooledWorktreeOptions,\n): Promise<WorktreeRestoreWarning[]> {\n\tconst { signal } = options;\n\tconst binding: WorkspaceBinding = {\n\t\tremotes: [...snapshot.remotes],\n\t\thead: snapshot.head,\n\t\ttree: snapshot.tree,\n\t\tenvHash: snapshot.envHash,\n\t};\n\tassertUsableSnapshotRecord(binding, snapshot);\n\tconst patches = await snapshotPatches(snapshot, options.blobs);\n\t// The slot's own store: one an earlier version named after the remotes as spelled stays the slot's (#4748).\n\tconst store = await pooledWorktreeStore(options.storeDir, slot, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tawait storeSnapshotObjects(git, store, binding, snapshot, patches, options.blobs, scratch);\n\t\tawait options.beforeReset();\n\t\t// A download an interrupted resume left pending is the reset's to finish, or to leave pending again.\n\t\tawait rm(await pendingLfsPath({ cwd: slot, signal }), { force: true });\n\t\tawait timeRestorePhase(\"materialize\", async () => {\n\t\t\tconst attributes = join(scratch, \"empty-attributes\");\n\t\t\tawait writing(attributes, snapshot.id, () => writeFile(attributes, \"\"));\n\t\t\tconst neutral: GitRunOptions = { cwd: slot, signal, neutral: true, env: { GIT_LFS_SKIP_SMUDGE: \"1\" } };\n\t\t\t// The index takes `from` first, keeping the timestamps of the entries it already had, so the reset below\n\t\t\t// removes the files `from` holds beyond HEAD as well, and writes only what differs.\n\t\t\tawait runGit([\"read-tree\", \"--reset\", from.tree], neutral);\n\t\t\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...neutral, allowExitCodes: [1] });\n\t\t\tawait runGit(\n\t\t\t\t[\"-c\", `core.attributesFile=${attributes}`, \"read-tree\", \"--reset\", \"-u\", snapshot.tree],\n\t\t\t\tneutral,\n\t\t\t);\n\t\t\tawait runGit([\"update-ref\", \"--no-deref\", \"HEAD\", snapshot.head], neutral);\n\t\t\tawait runGit([\"read-tree\", \"--reset\", snapshot.head], neutral);\n\t\t\tawait runGit([\"update-index\", \"-q\", \"--refresh\"], { ...neutral, allowExitCodes: [1] });\n\t\t\tawait recordRestoredTree(neutral, snapshot.tree);\n\t\t});\n\t\tconst warnings = snapshotRestoreWarnings(snapshot);\n\t\tif (snapshot.filters?.drivers.includes(\"lfs\")) {\n\t\t\tconst worktree: GitRunOptions = { cwd: slot, signal };\n\t\t\tconst pending: PendingLfs = { head: snapshot.head, tree: snapshot.tree, remotes: snapshot.remotes };\n\t\t\tconst pointers = await timeRestorePhase(\"lfs\", () => pullPendingLfs(worktree, pending));\n\t\t\tif (pointers.length > 0) warnings.unshift({ code: \"lfs-objects-unavailable\", paths: pointers });\n\t\t}\n\t\tawait timeRestorePhase(\"verify\", () =>\n\t\t\tverifyRestoredTree(slot, slot, snapshot.head, snapshot.tree, \"tree\", scratch, snapshot.id, signal),\n\t\t);\n\t\treturn warnings;\n\t});\n}\n\n/**\n * The shared object store under `storeDir` that the restored worktree at `worktree` belongs to; rejects with\n * `unsafe-target` when it belongs to none.\n */\nexport async function pooledWorktreeStore(\n\tstoreDir: string,\n\tworktree: string,\n\tsignal: AbortSignal | undefined,\n): Promise<string> {\n\tconst store = resolve(\n\t\tawait gitText([\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], { cwd: worktree, signal }),\n\t);\n\tif (\n\t\t(await canonicalizeWorktreePathAsync(dirname(store))) !==\n\t\t(await canonicalizeWorktreePathAsync(join(storeDir, \"repositories\")))\n\t) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId: null, target: worktree, reason: \"not-restored\" });\n\t}\n\treturn store;\n}\n\n/** Restore errors after which a degraded restore can still give the session part of its snapshot (#4733). */\nconst DEGRADABLE_RESTORE_CODES: ReadonlySet<string> = new Set([\n\t\"blob-missing\",\n\t\"blob-corrupt\",\n\t\"commits-unavailable\",\n\t\"delta-failed\",\n\t\"tree-mismatch\",\n]);\n\n/** Whether a degraded restore can follow `error`, the failure of an exact restore. */\nexport function isDegradableRestoreFailure(error: unknown): error is WorkspaceRestoreError {\n\treturn isWorkspaceRestoreError(error) && DEGRADABLE_RESTORE_CODES.has(error.code);\n}\n\nexport interface RestoreDegradedWorktreeOptions extends Omit<RestoreWorktreeSnapshotOptions, \"into\" | \"snapshots\"> {\n\t/**\n\t * Commits close to the snapshot's `HEAD` to try, nearest first, after its pushed base and before its branch tip:\n\t * the `HEAD`s of the checkout's earlier snapshots, for example.\n\t */\n\treadonly candidates?: readonly string[];\n}\n\nexport interface DegradedWorktree {\n\treadonly path: string;\n\treadonly degraded: WorktreeDegradedRestore;\n\treadonly warnings: readonly WorktreeRestoreWarning[];\n}\n\n/**\n * Restores the best state of `snapshot` that this host can reach after an exact restore failed with `failure` (#4733),\n * into a new worktree: the recorded `HEAD` with the change sets of the patch chain that apply, each whole or not at\n * all, up to the first that cannot; else the closest commit it can fetch from the recorded remotes, trying the\n * snapshot's pushed base, then `candidates`, then the recorded branch's tip. Rejects with `failure` when no commit is\n * reachable, and with `invalid-snapshot` for a record that fails the security checks, before any Git work.\n */\nexport async function restoreDegradedWorktree(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\toptions: RestoreDegradedWorktreeOptions = {},\n): Promise<DegradedWorktree> {\n\treturn withWorktreeSnapshotGit(options.git, () => restoreDegradedValidated(snapshot, failure, options, undefined));\n}\n\n/** {@link restoreDegradedWorktree} into `slot`, a pooled slot path as for {@link restoreWorktreeAt} (#4748). */\nexport async function restoreDegradedWorktreeAt(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\tslot: string,\n\toptions: RestoreDegradedWorktreeOptions = {},\n): Promise<DegradedWorktree> {\n\treturn withWorktreeSnapshotGit(options.git, () => restoreDegradedValidated(snapshot, failure, options, slot));\n}\n\nasync function restoreDegradedValidated(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\toptions: RestoreDegradedWorktreeOptions,\n\tslot: string | undefined,\n): Promise<DegradedWorktree> {\n\tconst { signal } = options;\n\tassertUsableSnapshotRecord(\n\t\t{ remotes: [...snapshot.remotes], head: snapshot.head, tree: snapshot.tree, envHash: snapshot.envHash },\n\t\tsnapshot,\n\t);\n\tconst candidates = options.candidates ?? [];\n\tconst unusable = candidates.findIndex((commit) => !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(commit));\n\tif (unusable >= 0) throw new WorkspaceConfigError(\"sdk\", `candidates[${unusable}]`, \"a Git commit id\");\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst path =\n\t\tslot === undefined\n\t\t\t? join(storeDir, \"worktrees\", `${snapshot.id.slice(0, 12)}-${randomUUID().slice(0, 8)}`)\n\t\t\t: resolve(slot);\n\tawait checkTarget(path, snapshot.id);\n\tconst warnings: WorktreeRestoreWarning[] = [];\n\tconst warn = (warning: WorktreeRestoreWarning) => {\n\t\twarnings.push(warning);\n\t\toptions.onWarning?.(warning);\n\t};\n\tawait checkPathBudget(storeDir, () => restoreStorePath(storeDir, snapshot, snapshot), path, undefined, snapshot.id);\n\tawait sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = await restoreStorePath(storeDir, snapshot, snapshot);\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tconst cause = {\n\t\t\tcause: failure.code,\n\t\t\t...(failure.reason ? { causeReason: failure.reason } : {}),\n\t\t\thint: failure.hint,\n\t\t};\n\t\tconst degraded = await withRepositoryLock(\n\t\t\tstore,\n\t\t\tsnapshot.id,\n\t\t\tsignal,\n\t\t\tasync (): Promise<WorktreeDegradedRestore> => {\n\t\t\t\tawait ensureObjectStore(store, signal);\n\t\t\t\tconst configured = await configureRecordedRemotes(git, snapshot.remotes);\n\t\t\t\t// The exact restore may have stopped before it reached the recorded commit: fetch it, or take it from the bundle.\n\t\t\t\tconst reached = await timeRestorePhase(\"fetch\", () =>\n\t\t\t\t\tensureHead(git, snapshot, options.blobs, scratch),\n\t\t\t\t).then(\n\t\t\t\t\t(fetched) => ({ fetched }),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tif (isWorkspaceRestoreError(error)) return undefined;\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (reached !== undefined) {\n\t\t\t\t\tconst partial = await timeRestorePhase(\"reconstruct\", () =>\n\t\t\t\t\t\tapplicableChanges(git, snapshot, options.blobs, scratch),\n\t\t\t\t\t);\n\t\t\t\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t\t\t\t...git,\n\t\t\t\t\t\tinput: [\n\t\t\t\t\t\t\t`update refs/atomic/heads/${snapshot.head} ${snapshot.head}\\n`,\n\t\t\t\t\t\t\t...(configured && reached.fetched\n\t\t\t\t\t\t\t\t? [`update ${PUSHED_REFS}${snapshot.head} ${snapshot.head}\\n`]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t].join(\"\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstage: \"partial-changes\",\n\t\t\t\t\t\thead: snapshot.head,\n\t\t\t\t\t\ttree: partial.tree,\n\t\t\t\t\t\tmissingLinks: partial.missingLinks,\n\t\t\t\t\t\tmissingPaths: partial.missingPaths,\n\t\t\t\t\t\tmissingCommits: [],\n\t\t\t\t\t\t...cause,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst closest = await timeRestorePhase(\"fetch\", () =>\n\t\t\t\t\tclosestCommit(git, snapshot, candidates, options.blobs),\n\t\t\t\t);\n\t\t\t\tif (closest === undefined) throw failure;\n\t\t\t\t// Which unpushed commits the closest commit's history lacks is an ancestry question a shallow store cannot answer.\n\t\t\t\tawait unshallowStore(git, snapshot.remotes, [closest.commit]);\n\t\t\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t\t\t...git,\n\t\t\t\t\tinput: [\n\t\t\t\t\t\t`update refs/atomic/heads/${closest.commit} ${closest.commit}\\n`,\n\t\t\t\t\t\t...(configured && closest.fromRemote\n\t\t\t\t\t\t\t? [`update ${PUSHED_REFS}${closest.commit} ${closest.commit}\\n`]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t].join(\"\"),\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tstage: \"closest-commit\",\n\t\t\t\t\thead: closest.commit,\n\t\t\t\t\ttree: await gitText([\"rev-parse\", `${closest.commit}^{tree}`], git),\n\t\t\t\t\tbasis: closest.basis,\n\t\t\t\t\tmissingLinks: snapshot.chain.flatMap((link, index) => (link.patch === null ? [] : [index])),\n\t\t\t\t\tmissingPaths: [],\n\t\t\t\t\tmissingCommits: await notInHistory(git, unpushedCommits(snapshot), closest.commit),\n\t\t\t\t\t...cause,\n\t\t\t\t};\n\t\t\t},\n\t\t);\n\t\tconst measured = await publishWorktree({\n\t\t\tgit,\n\t\t\tstore,\n\t\t\tstoreDir,\n\t\t\tpath,\n\t\t\tinto: undefined,\n\t\t\thead: degraded.head,\n\t\t\ttree: degraded.tree,\n\t\t\tsnapshot,\n\t\t\tscratch,\n\t\t\twarn,\n\t\t\tsignal,\n\t\t\t// Whatever started the degraded restore, this host's checkout filters may change the files it writes (#4744):\n\t\t\t// check its HEAD and keep the checkout, recording the tree it holds.\n\t\t\tverify: \"head\",\n\t\t});\n\t\t// This host's checkout filters may have changed files, and a case-insensitive file system may hold one file for\n\t\t// paths that differ only in case: record what the worktree holds, and which files differ.\n\t\tconst differing = nulFields(\n\t\t\t(await runGit([\"diff-tree\", \"-r\", \"-z\", \"--name-only\", \"--no-renames\", degraded.tree, measured], git)).stdout,\n\t\t);\n\t\tconst folded = await caseFoldedPaths(git, degraded.tree, path);\n\t\tconst missingPaths = [...new Set([...degraded.missingPaths, ...differing, ...folded])].sort();\n\t\treturn { path, degraded: { ...degraded, tree: measured, missingPaths }, warnings };\n\t});\n}\n\n/**\n * The paths of `tree` that differ from another only in case (`dir/b.txt` and `Dir/b.txt`) where the worktree at `root`\n * lacks one of them under its own spelling: a case-insensitive file system holds one file for them all, so none can be\n * relied on (#4932).\n */\nasync function caseFoldedPaths(git: GitRunOptions, tree: string, root: string): Promise<string[]> {\n\tconst groups = new Map<string, string[]>();\n\tfor (const path of nulFields((await runGit([\"ls-tree\", \"-r\", \"-z\", \"--name-only\", tree], git)).stdout)) {\n\t\tconst key = path.toLowerCase();\n\t\tgroups.set(key, [...(groups.get(key) ?? []), path]);\n\t}\n\tconst spelledAsRecorded = async (path: string) => {\n\t\tconst parts = path.split(\"/\");\n\t\tfor (let index = 0; index < parts.length; index++) {\n\t\t\tconst names: string[] = await readdir(join(root, ...parts.slice(0, index))).catch(() => []);\n\t\t\tif (!names.includes(parts[index]!)) return false;\n\t\t}\n\t\treturn true;\n\t};\n\tconst folded: string[] = [];\n\tfor (const group of groups.values()) {\n\t\tif (group.length < 2) continue;\n\t\tfor (const path of group) {\n\t\t\tif (await spelledAsRecorded(path)) continue;\n\t\t\tfolded.push(...group);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn folded;\n}\n\n/** The commits `snapshot` recorded as not pushed: its bundle's, else those its omissions name, else its `HEAD`. */\nfunction unpushedCommits(snapshot: WorktreeSnapshot): string[] {\n\tif (snapshot.bundle) return [...snapshot.bundle.commits];\n\tconst named = snapshot.omitted.flatMap((omission) => (\"commits\" in omission ? omission.commits : []));\n\treturn named.length > 0 ? [...new Set(named)] : [snapshot.head];\n}\n\n/** `commits` without those `head`'s history holds: the restored history already has them (#4744). */\nasync function notInHistory(git: GitRunOptions, commits: readonly string[], head: string): Promise<string[]> {\n\tconst missing: string[] = [];\n\tfor (const commit of commits) {\n\t\t// Exit 1: not an ancestor; 128: not in the store, so not in the restored history either.\n\t\tconst { exitCode } = await runGit([\"merge-base\", \"--is-ancestor\", commit, head], {\n\t\t\t...git,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\tif (exitCode !== 0) missing.push(commit);\n\t}\n\treturn missing;\n}\n\n/**\n * The tree of `snapshot`'s `HEAD` with its patch chain applied in the store, link by link, up to the first link whose\n * patch is missing, corrupt or does not give the link's tree; that link and every later one are left out whole. Lists\n * the paths the left-out links touch where their patches are readable.\n */\nasync function applicableChanges(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot,\n\tblobs: SnapshotBlobStore | undefined,\n\tscratch: string,\n): Promise<{ tree: string; missingLinks: number[]; missingPaths: string[] }> {\n\tconst indexed: GitRunOptions = { ...git, env: { ...git.env, GIT_INDEX_FILE: join(scratch, \"degraded-index\") } };\n\tlet tree = await gitText([\"rev-parse\", `${snapshot.head}^{tree}`], git);\n\tawait runGit([\"read-tree\", tree], indexed);\n\tlet stop = snapshot.chain.length;\n\tconst patches: (Uint8Array | undefined)[] = [];\n\tfor (const [deltaIndex, link] of snapshot.chain.entries()) {\n\t\tconst patch =\n\t\t\tlink.patch === null\n\t\t\t\t? null\n\t\t\t\t: await loadBlob(blobs, link.patch, { snapshotId: snapshot.id, role: \"patch\", deltaIndex }).catch(\n\t\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\t\tif (isWorkspaceRestoreError(error)) return undefined;\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\tpatches.push(patch ?? undefined);\n\t\tif (stop < snapshot.chain.length) continue;\n\t\tif (patch === undefined) {\n\t\t\tstop = deltaIndex;\n\t\t\tcontinue;\n\t\t}\n\t\tif (patch !== null) {\n\t\t\tconst file = join(scratch, `degraded-${deltaIndex}.patch`);\n\t\t\tawait writing(file, snapshot.id, () => writeFile(file, patch));\n\t\t\t// `git apply` changes nothing when any hunk does not apply, so a link is applied whole or not at all.\n\t\t\tconst applied = await runGit(\n\t\t\t\t[\"apply\", \"--cached\", \"--binary\", \"--whitespace=nowarn\", \"--no-ignore-whitespace\", \"--no-3way\", file],\n\t\t\t\t{ ...indexed, allowExitCodes: [1, 128] },\n\t\t\t);\n\t\t\tif (applied.exitCode !== 0) {\n\t\t\t\tstop = deltaIndex;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tconst written = await gitText([\"write-tree\"], indexed);\n\t\tif (written !== link.tree) {\n\t\t\tawait runGit([\"read-tree\", tree], indexed);\n\t\t\tstop = deltaIndex;\n\t\t\tcontinue;\n\t\t}\n\t\ttree = written;\n\t}\n\tconst missingLinks = snapshot.chain.flatMap((_link, index) => (index >= stop ? [index] : []));\n\tconst missingPaths = new Set<string>();\n\tfor (const index of missingLinks) {\n\t\tconst patch = patches[index];\n\t\tif (!patch) continue;\n\t\tconst file = join(scratch, `degraded-${index}.patch`);\n\t\tawait writing(file, snapshot.id, () => writeFile(file, patch));\n\t\tconst listed = await runGit([\"apply\", \"--numstat\", \"-z\", file], { ...git, allowExitCodes: [1, 128] });\n\t\tif (listed.exitCode !== 0) continue;\n\t\tfor (const field of nulFields(listed.stdout)) {\n\t\t\tconst path = field.split(\"\\t\").at(-1);\n\t\t\tif (path) missingPaths.add(path);\n\t\t}\n\t}\n\treturn { tree, missingLinks, missingPaths: [...missingPaths].sort() };\n}\n\n/** Whether Git accepts `name`, a branch name from a snapshot record, as a branch name (`git check-ref-format --branch`). */\nasync function isBranchName(git: GitRunOptions, name: string): Promise<boolean> {\n\tif (name.startsWith(\"-\") || name.includes(\"@{\") || /[\\u0000-\\u001f\\u007f]/.test(name)) return false;\n\tconst { exitCode } = await runGit([\"check-ref-format\", \"--branch\", name], { ...git, allowExitCodes: [1, 128] });\n\treturn exitCode === 0;\n}\n\n/**\n * The commit nearest `snapshot`'s `HEAD` that the store holds or a recorded remote supplies: the pushed base of its\n * bundle, when the bundle is readable, then each of `candidates`, then the tip of the recorded branch (the remote's\n * default branch for a detached `HEAD`).\n */\nasync function closestCommit(\n\tgit: GitRunOptions,\n\tsnapshot: WorktreeSnapshot,\n\tcandidates: readonly string[],\n\tblobs: SnapshotBlobStore | undefined,\n): Promise<{ commit: string; basis: WorktreeDegradedRestoreBasis; fromRemote: boolean } | undefined> {\n\tconst tried = new Set<string>([snapshot.head]);\n\tconst reachable = async (commit: string): Promise<{ commit: string; fromRemote: boolean } | undefined> => {\n\t\tif (tried.has(commit)) return undefined;\n\t\ttried.add(commit);\n\t\tif (await hasObject(git, `${commit}^{commit}`)) return { commit, fromRemote: false };\n\t\tconst fetched = await fetchCommits(git, snapshot.remotes, [commit], false, [commit]);\n\t\treturn fetched.supplied && (await hasObject(git, `${commit}^{commit}`))\n\t\t\t? { commit, fromRemote: true }\n\t\t\t: undefined;\n\t};\n\tif (snapshot.bundle) {\n\t\tconst data = await blobs?.getBlob(snapshot.bundle.blob).catch(() => undefined);\n\t\tif (data !== undefined && sha256Hex(data) === snapshot.bundle.blob) {\n\t\t\tconst prerequisites = bundlePrerequisites(data);\n\t\t\tassertUsableBundlePrerequisites(prerequisites, snapshot.id);\n\t\t\tfor (const commit of prerequisites) {\n\t\t\t\tconst found = await reachable(commit);\n\t\t\t\tif (found) return { ...found, basis: \"pushed-base\" };\n\t\t\t}\n\t\t}\n\t}\n\tfor (const commit of candidates) {\n\t\tconst found = await reachable(commit);\n\t\tif (found) return { ...found, basis: \"earlier-snapshot\" };\n\t}\n\t// The recorded branch's tip, when Git accepts its name as a branch; the remote's default branch only for a\n\t// detached HEAD, never in place of a branch that has a name.\n\tif (snapshot.branch !== null && !(await isBranchName(git, snapshot.branch))) return undefined;\n\tconst source = snapshot.branch === null ? \"HEAD\" : `refs/heads/${snapshot.branch}`;\n\tconst ref = `refs/atomic/tips/${snapshot.id}`;\n\tfor (const remote of snapshot.remotes) {\n\t\ttry {\n\t\t\tawait runFetch(git, remote, [`+${source}:${ref}`]);\n\t\t\tnoteRestoreFetch(\"full\");\n\t\t} catch (error) {\n\t\t\tif (!isWorkspaceGitError(error)) throw error;\n\t\t\tcontinue;\n\t\t}\n\t\tconst tip = await runGit([\"rev-parse\", \"-q\", \"--verify\", `${ref}^{commit}`], {\n\t\t\t...git,\n\t\t\tallowExitCodes: [1, 128],\n\t\t});\n\t\tawait runGit([\"update-ref\", \"-d\", ref], git);\n\t\tif (tip.exitCode === 0)\n\t\t\treturn { commit: tip.stdout.toString(\"utf8\").trim(), basis: \"branch-tip\", fromRemote: true };\n\t}\n\treturn undefined;\n}\n\ninterface PublishWorktree {\n\treadonly git: GitRunOptions;\n\treadonly store: string;\n\treadonly storeDir: string;\n\treadonly path: string;\n\treadonly into: string | undefined;\n\treadonly head: string;\n\treadonly tree: string;\n\treadonly snapshot: WorktreeSnapshot | null;\n\treadonly scratch: string;\n\treadonly warn: (warning: WorktreeRestoreWarning) => void;\n\treadonly signal: AbortSignal | undefined;\n\t/** Where an exact restore hands its LFS download instead of running it (#5099). */\n\treadonly deferLfs?: RestoreWorktreeSnapshotOptions[\"deferLfs\"];\n\t/**\n\t * What the staged worktree is checked against before it is moved to `path`: its HEAD and recomputed tree (`tree`),\n\t * or its HEAD alone (`head`), for a degraded restore whose content this host's filters may change.\n\t */\n\treadonly verify: \"tree\" | \"head\";\n}\n\n/** The staging worktree of the restore `id` into `path`: under `storeDir`, or beside `path` when the caller chose it. */\nfunction stagingPath(storeDir: string, path: string, into: string | undefined, id: string): string {\n\treturn into === undefined\n\t\t? join(storeDir, \"worktrees\", stagingWorktreeName(id))\n\t\t: join(dirname(path), `.${basename(path)}${stagingWorktreeName(id)}`);\n}\n\n/**\n * On Windows, fails a restore into `path` over the object store `store` names before it writes anything when a path it\n * would create is longer than Git for Windows accepts (#5139). Staging names have one length, whatever the id.\n */\nasync function checkPathBudget(\n\tstoreDir: string,\n\tstore: () => Promise<string>,\n\tpath: string,\n\tinto: string | undefined,\n\tsnapshotId: string | null,\n): Promise<void> {\n\tif (process.platform !== \"win32\") return;\n\tconst named = await store().then(\n\t\t(value) => ({ value }),\n\t\t() => undefined,\n\t);\n\tif (named === undefined) return;\n\tconst staging = stagingPath(storeDir, path, into, \"0\".repeat(12));\n\tassertRestorePathBudget({ storeDir, store: () => named.value, staging, target: path, snapshotId });\n}\n\n/**\n * Checks `head` and `tree` out of `store` into a staging worktree, verifies it, and moves it to `path`, under a crash\n * record, so a final path never holds an unverified worktree.\n */\nasync function publishWorktree(publish: PublishWorktree): Promise<string> {\n\tconst { git, store, storeDir, path, head, tree, snapshot, scratch, warn, signal } = publish;\n\t// Only an exact restore defers its download: a degraded one records the tree it holds after it (#5099).\n\tconst deferred = publish.verify === \"tree\" ? publish.deferLfs : undefined;\n\tlet measured = tree;\n\tconst snapshotId = snapshot?.id ?? null;\n\tawait checkTarget(path, snapshotId);\n\tconst createdTarget = (await statIfPresent(path)) === undefined;\n\tconst id = randomUUID();\n\tconst staging = stagingPath(storeDir, path, publish.into, id);\n\tconst record: RestoreRecord = { staging, target: path, store, createdTarget, tree };\n\tawait withRestoreRecord(storeDir, id, record, snapshotId, warn, signal, async (assertActive, moving, created) => {\n\t\tawait timeRestorePhase(\"materialize\", () =>\n\t\t\tmaterialize(git, store, staging, head, tree, scratch, snapshotId, created, signal),\n\t\t);\n\t\tassertActive();\n\t\tconst lfs = snapshot?.filters?.drivers.includes(\"lfs\") ? snapshot.remotes : undefined;\n\t\tconst pending: PendingLfs | undefined = lfs === undefined ? undefined : { head, tree, remotes: lfs };\n\t\t// Marked before it is published, so a worktree whose deferred download never completed says so (#5099).\n\t\tif (pending !== undefined && deferred !== undefined)\n\t\t\tawait markLfsPending({ cwd: staging, signal }, pending, snapshotId);\n\t\tif (lfs !== undefined && deferred === undefined) {\n\t\t\tconst worktree: GitRunOptions = { cwd: staging, signal };\n\t\t\tconst pointers = await timeRestorePhase(\"lfs\", () => pullLfsObjects(worktree, head, tree, lfs));\n\t\t\tif (pointers.length > 0) warn({ code: \"lfs-objects-unavailable\", paths: pointers });\n\t\t}\n\t\tmeasured = await timeRestorePhase(\"verify\", () =>\n\t\t\tverifyRestoredTree(staging, path, head, tree, publish.verify, scratch, snapshotId, signal),\n\t\t);\n\t\tassertActive();\n\t\tawait timeRestorePhase(\"publish\", () =>\n\t\t\twithRepositoryLock(store, snapshotId, signal, () => moveIntoPlace(publish, record, snapshotId, moving)),\n\t\t);\n\t\tassertActive();\n\t\tif (pending !== undefined && deferred !== undefined) {\n\t\t\tconst worktree: GitRunOptions = { cwd: path, signal };\n\t\t\t// Taken as any other process takes the download over, so it never runs beside one that took it first.\n\t\t\tdeferred(\n\t\t\t\tpath,\n\t\t\t\tdeferRestorePhase(\"lfs\", async () => finishPendingLfs(worktree, await pendingLfsPath(worktree))),\n\t\t\t);\n\t\t}\n\t});\n\treturn measured;\n}\n\n/**\n * Checks that the worktree at `dir`, restored for `target`, has HEAD `head` and, unless only HEAD is checked, the\n * neutral policy tree `tree`, ignoring conversion filters through the empty attributes file in `scratch`. Resolves to\n * the tree it measured; rejects with `tree-mismatch`.\n */\nasync function verifyRestoredTree(\n\tdir: string,\n\ttarget: string,\n\thead: string,\n\ttree: string,\n\tverify: \"tree\" | \"head\",\n\tscratch: string,\n\tsnapshotId: string | null,\n\tsignal: AbortSignal | undefined,\n): Promise<string> {\n\tconst checkout = await locateCheckout(dir, signal);\n\tif (checkout instanceof Error) throw checkout;\n\tconst policy = await loadSnapshotPathPolicy(dir);\n\tconst actual = await withScratchDirectory((verifyScratch) =>\n\t\twriteWorkingTree(checkout, DEFAULT_WORKTREE_SNAPSHOT_SETTINGS, policy, verifyScratch, {\n\t\t\tsignal,\n\t\t\tneutral: true,\n\t\t\tseedTree: tree,\n\t\t\tattributesFile: join(scratch, \"empty-attributes\"),\n\t\t}),\n\t);\n\tif (checkout.head !== head || (verify === \"tree\" && actual.tree !== tree)) {\n\t\tthrow new WorkspaceRestoreError(\"tree-mismatch\", {\n\t\t\tsnapshotId,\n\t\t\ttarget,\n\t\t\texpectedTree: tree,\n\t\t\tactualTree: actual.tree,\n\t\t});\n\t}\n\treturn actual.tree;\n}\n\n/**\n * Moves the verified staging worktree to the restore's final path, never into a directory that appeared there, telling\n * `moving` where the worktree may be: `unchecked` as Git is asked to move it, then `published` once it is registered at\n * that path, or `checked` once a nested move was refused.\n */\nasync function moveIntoPlace(\n\tpublish: PublishWorktree,\n\trecord: RestoreRecord,\n\tsnapshotId: string | null,\n\tmoving: (state: MoveState) => void,\n): Promise<void> {\n\tconst { git, path, signal } = publish;\n\tconst { staging, createdTarget } = record;\n\tif (createdTarget) {\n\t\tif ((await statIfPresent(path)) !== undefined) {\n\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t\t}\n\t} else {\n\t\tawait writing(path, snapshotId, () => rmdir(path));\n\t}\n\t// `-f` replaces only a registration whose directory is gone, as a store restored from a CI cache keeps for the\n\t// worktree its saving job built at this path (#4748); a directory at the path was refused above.\n\t// The move and the check of where it went are never stopped midway (#4748): a Git killed mid-move leaves a worktree\n\t// that neither the staging path nor `published` accounts for. Both are short; a stop is noticed right after them.\n\tsignal?.throwIfAborted();\n\tmoving(\"unchecked\");\n\tawait runGit([\"worktree\", \"move\", \"-f\", staging, path], { ...git, signal: undefined });\n\t// Git moves *inside* an existing directory. If one appeared after our check, never return it as the\n\t// verified worktree: remove only the nested worktree that Git registered and leave the user's files alone,\n\t// even when that directory is itself a worktree of this store.\n\tconst registered = await registeredWorktrees({ ...git, signal: undefined });\n\tconst destination = await physicalPath(path);\n\tconst nested = join(destination, basename(staging));\n\tif (includesPath(registered, destination) && !includesPath(registered, nested)) {\n\t\tmoving(\"published\");\n\t} else {\n\t\t// The cleanup that follows takes a worktree Git nested in the directory that appeared out again.\n\t\tmoving(includesPath(registered, nested) ? \"nested\" : \"checked\");\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t}\n}\n\n/** The entry at `path` itself, a symlink rather than what it points to, or undefined when there is none. */\nasync function lstatIfPresent(path: string): Promise<Stats | undefined> {\n\ttry {\n\t\treturn await lstat(path);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\tthrow unreadablePathError(path, error);\n\t}\n}\n\n/** The entry at `path`, or undefined when there is none. */\nasync function statIfPresent(path: string): Promise<Stats | undefined> {\n\ttry {\n\t\treturn await stat(path);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\tthrow unreadablePathError(path, error);\n\t}\n}\n\n/**\n * Removes a worktree that a restore created, for callers that roll back a multi-checkout restore; a path that no\n * longer exists is already removed. Refuses, with `unsafe-target` (reason `not-restored`), any path that is not a\n * worktree of a shared store under `storeDir`, including a file, so it can never touch a user's checkout.\n */\nexport async function removeRestoredWorktree(\n\tpath: string,\n\toptions: {\n\t\treadonly storeDir?: string;\n\t\treadonly signal?: AbortSignal;\n\t\treadonly onWarning?: (warning: WorktreeRestoreWarning) => void;\n\t} = {},\n): Promise<void> {\n\tconst target = resolve(path);\n\tconst storeDir = resolve(options.storeDir ?? defaultWorktreeSnapshotStoreDir());\n\tconst warned = new Set<string>();\n\tawait sweepRestoreRecords(\n\t\tstoreDir,\n\t\t(warning) => {\n\t\t\tif (warning.code !== \"stale-restore-retained\" || warned.has(warning.path)) return;\n\t\t\twarned.add(warning.path);\n\t\t\tif (options.onWarning) options.onWarning(warning);\n\t\t\telse\n\t\t\t\tprocess.emitWarning(\n\t\t\t\t\t`A restore interrupted earlier left ${warning.path}, which may hold your files; check them, then delete the directory yourself.`,\n\t\t\t\t);\n\t\t},\n\t\toptions.signal,\n\t);\n\tconst entry = await statIfPresent(target);\n\tif (entry === undefined) return;\n\t// A staging or set-aside directory is only ever what a cleanup kept, which may hold a user's files (#4748).\n\tif (isRestoreScratchName(basename(target)) || (await namedByRestoreRecord(storeDir, target))) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId: null, target, reason: \"not-restored\" });\n\t}\n\tconst repositories = join(storeDir, \"repositories\");\n\tconst common = entry.isDirectory()\n\t\t? await runGit([\"rev-parse\", \"--path-format=absolute\", \"--git-common-dir\"], {\n\t\t\t\tcwd: target,\n\t\t\t\tsignal: options.signal,\n\t\t\t\tallowExitCodes: [128],\n\t\t\t})\n\t\t: undefined;\n\tconst store = common ? resolve(common.stdout.toString(\"utf8\").trim()) : \"\";\n\tif (\n\t\tcommon?.exitCode !== 0 ||\n\t\t!isWithin(repositories, store) ||\n\t\trelative(store, target) === \"\" ||\n\t\tisWithin(store, target)\n\t) {\n\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId: null, target, reason: \"not-restored\" });\n\t}\n\tawait withRepositoryLock(store, null, options.signal, () =>\n\t\tremoveWorktree({ cwd: repositories, env: { GIT_DIR: store }, signal: options.signal }, target),\n\t);\n}\n\n/**\n * Whether `name` is one a restore gives the directory it stages its worktree in, or sets it aside in to delete it: never\n * the name of a worktree a restore returned. Earlier versions named staging `.staging-<id>` and `.<target>.atomic-restore-<id>`.\n */\nfunction isRestoreScratchName(name: string): boolean {\n\treturn (\n\t\t/^(?:\\.[sd]|\\..+\\.[sd])-[0-9a-f]{12}$/.test(name) ||\n\t\t/^\\.staging-[0-9a-f-]{36}$/.test(name) ||\n\t\t/\\.atomic-restore-[0-9a-f-]{36}$/.test(name)\n\t);\n}\n\n/** Whether a crash record under `storeDir` names `path` as its staging directory. */\nasync function namedByRestoreRecord(storeDir: string, path: string): Promise<boolean> {\n\tconst recordsDir = join(storeDir, \"restores\");\n\tconst names = await readdir(recordsDir).catch(() => [] as string[]);\n\tfor (const name of names) {\n\t\tif (!name.endsWith(\".json\")) continue;\n\t\tconst record = await readFile(join(recordsDir, name), \"utf8\")\n\t\t\t.then((text) => JSON.parse(text) as { staging?: unknown })\n\t\t\t.catch(() => undefined);\n\t\tif (typeof record?.staging === \"string\" && includesPath([record.staging], path)) return true;\n\t}\n\treturn false;\n}\n\nfunction isWithin(parent: string, child: string): boolean {\n\tconst path = relative(parent, child);\n\t// A child named like `..x` is inside; only `..` or `../…` leaves.\n\treturn path !== \"\" && path !== \"..\" && !path.startsWith(`..${sep}`) && !isAbsolute(path);\n}\n\n/**\n * Restores `target` into a new worktree and resolves to its path after verifying its HEAD and tree. Restore-time\n * notices (omitted content, conversion filters, unavailable LFS objects) go to `onWarning`.\n */\nexport async function restoreWorktreeSnapshot(\n\ttarget: WorkspaceBinding | WorktreeSnapshot,\n\toptions: RestoreWorktreeSnapshotOptions = {},\n): Promise<string> {\n\treturn (await restoreWorktree(target, options)).path;\n}\n\nexport interface VerifyWorktreeOptions {\n\t/** Snapshot settings that decide whether a file the recorded tree does not hold counts as drift. */\n\treadonly settings?: WorktreeSnapshotSettingsInput;\n\treadonly signal?: AbortSignal;\n}\n\n/**\n * Resolves to the binding of the checkout at `dir` when its HEAD and policy-filtered tree equal `binding`'s; rejects\n * with {@link WorkspaceDriftError} otherwise, and with the typed reason when Git or a repository is missing.\n */\nexport async function verifyWorktree(\n\tbinding: WorkspaceBinding | WorktreeSnapshot,\n\tdir: string,\n\toptions: VerifyWorktreeOptions = {},\n): Promise<WorkspaceBinding> {\n\tif (!isBinding(binding)) throw new WorkspaceConfigError(\"sdk\", \"binding\", \"a WorkspaceBinding\");\n\tif (typeof dir !== \"string\" || dir.length === 0) throw new WorkspaceConfigError(\"sdk\", \"dir\", \"a directory path\");\n\tconst settings = resolveWorktreeSnapshotSettings(options.settings, \"sdk\", \"settings\");\n\tassertUsableSnapshotRecord(binding, isSnapshot(binding) ? binding : null);\n\tconst checkout = await locateCheckout(dir, options.signal);\n\tif (checkout instanceof Error) throw checkout;\n\tif (!(await hasObject({ cwd: checkout.root, signal: options.signal }, `${binding.tree}^{tree}`))) {\n\t\tthrow new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: binding.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: binding.tree,\n\t\t\tactualTree: null,\n\t\t\tsnapshotId: isSnapshot(binding) ? binding.id : null,\n\t\t});\n\t}\n\tconst policy = await loadSnapshotPathPolicy(checkout.root);\n\tconst state = await withScratchDirectory((scratch) =>\n\t\twriteWorkingTree(checkout, settings, policy, scratch, { signal: options.signal, seedTree: binding.tree }),\n\t);\n\tif (checkout.head !== binding.head || state.tree !== binding.tree) {\n\t\tthrow new WorkspaceDriftError({\n\t\t\troot: checkout.root,\n\t\t\texpectedHead: binding.head,\n\t\t\tactualHead: checkout.head,\n\t\t\texpectedTree: binding.tree,\n\t\t\tactualTree: state.tree,\n\t\t\tsnapshotId: isSnapshot(binding) ? binding.id : null,\n\t\t});\n\t}\n\treturn {\n\t\tremotes: (await readRepositoryConfig(checkout.root, options.signal)).remotes,\n\t\thead: checkout.head,\n\t\ttree: state.tree,\n\t\tenvHash: await computeEnvironmentHash(checkout.root),\n\t};\n}\n"]}
|