@bastani/atomic 0.9.84-alpha.1 → 0.9.85-alpha.1
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 +52 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/broker.ts +25 -7
- package/dist/builtin/intercom/broker/spawn.ts +83 -17
- package/dist/builtin/intercom/index.bundle.mjs +89 -26
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
- package/dist/builtin/workflows/src/index.js +48 -9
- package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
- package/dist/config.d.ts +3 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +2 -2
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +4 -5
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts.map +1 -1
- package/dist/core/agent-session-summary.js +8 -1
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +3 -6
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts.map +1 -1
- package/dist/core/builtin-resource-loader.js +1 -1
- package/dist/core/builtin-resource-loader.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +6 -2
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +13 -9
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-discovery.js +1 -1
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +133 -78
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.js +18 -2
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
- package/dist/core/mandatory-resource-loader.d.ts +5 -2
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +17 -12
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -3
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +1 -1
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.js +1 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resume/blueprint/resume.d.ts +4 -4
- package/dist/core/resume/blueprint/resume.js +4 -4
- package/dist/core/resume/blueprint/resume.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +6 -3
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +159 -37
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +10 -4
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +23 -6
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -2
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +2 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +13 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +21 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +61 -4
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +261 -28
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/storage/session/entry-structure.js +31 -1
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +13 -14
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/worktree-snapshot/index.d.ts +2 -2
- package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/index.js +1 -1
- package/dist/core/worktree-snapshot/index.js.map +1 -1
- package/dist/core/worktree-snapshot/records.d.ts +6 -0
- package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/records.js +18 -4
- package/dist/core/worktree-snapshot/records.js.map +1 -1
- package/dist/core/worktree-snapshot/restore.d.ts +24 -1
- package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/restore.js +443 -72
- package/dist/core/worktree-snapshot/restore.js.map +1 -1
- package/dist/core/worktree-snapshot/types.d.ts +44 -0
- package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +4 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +11 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
- package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/environment-variables.md +1 -1
- package/docs/guides/resume-on-any-machine.md +6 -4
- package/docs/intercom/operations.md +4 -0
- package/docs/rpc/protocol.md +2 -2
- package/docs/sdk/reference.md +3 -0
- package/docs/sdk.md +2 -2
- package/docs/session-format.md +11 -2
- package/docs/sessions.md +4 -2
- package/docs/settings.md +1 -1
- package/docs/workflows/api-reference.md +2 -2
- package/docs/worktree-snapshots.md +13 -5
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/restore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIN,OAAO,EACP,SAAS,EACT,MAAM,EACN,uBAAuB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAA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C;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 { randomUUID } from \"node:crypto\";\nimport type { Stats } from \"node:fs\";\nimport { lstat, mkdir, open, readdir, readFile, realpath, rm, rmdir, stat, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../../config.js\";\nimport {\n\tlocateCheckout,\n\treadRepositoryConfig,\n\twithScratchDirectory,\n\twriteSnapshotCommit,\n\twriteWorkingTree,\n} from \"./capture.ts\";\nimport { computeEnvironmentHash, sha256Hex } from \"./env-hash.ts\";\nimport {\n\tisWorkspaceGitError,\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 { loadSnapshotPathPolicy } from \"./policy.ts\";\nimport { assertUsableBundlePrerequisites, assertUsableSnapshotRecord } from \"./records.ts\";\nimport {\n\tDEFAULT_WORKTREE_SNAPSHOT_SETTINGS,\n\tresolveWorktreeSnapshotSettings,\n\ttype WorktreeSnapshotSettingsInput,\n} from \"./settings.ts\";\nimport type { SnapshotBlobStore, WorkspaceBinding, WorktreeRestoreWarning, WorktreeSnapshot } 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 * 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 function defaultWorktreeSnapshotStoreDir(): string {\n\treturn join(getAgentDir(), \"worktree-snapshots\");\n}\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; Git's own locks cover other processes. */\nasync function withRepositoryLock<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/** 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}\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\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\tconst defaultStaging = join(storeDir, \"worktrees\", `.staging-${id}`);\n\tconst siblingStaging = join(dirname(record.target), `.${basename(record.target)}.atomic-restore-${id}`);\n\treturn (\n\t\trecord.staging === siblingStaging ||\n\t\t(record.staging === defaultStaging && dirname(record.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/** Remove a registered or partially initialized staging worktree, then restore a previously empty target if needed. */\nasync function cleanRestoreRecord(record: RestoreRecord, signal?: AbortSignal): Promise<void> {\n\tconst git: GitRunOptions = { cwd: dirname(record.store), env: { GIT_DIR: record.store }, signal };\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\tif (!entry.isDirectory() || !includesPath(await registeredWorktrees(git), registeredPath)) {\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}\n\tconst removed = await runGit([\"worktree\", \"remove\", \"--force\", \"--force\", record.staging], {\n\t\t...git,\n\t\tallowExitCodes: [128],\n\t});\n\tif (entry && removed.exitCode !== 0) {\n\t\tthrow new WorkspaceGitError({\n\t\t\toperation: \"worktree remove\",\n\t\t\tcwd: git.cwd,\n\t\t\texitCode: removed.exitCode,\n\t\t\tdetail: \"could not remove the staging worktree\",\n\t\t});\n\t}\n\tawait writing(record.staging, null, () => rm(record.staging, { recursive: true, force: true }));\n\tif (!record.createdTarget && (await statIfPresent(record.target)) === undefined) {\n\t\tawait writing(record.target, null, () => mkdir(record.target, { recursive: true }));\n\t}\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}\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 lockfile.lock(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 withRepositoryLock(record.store, () => cleanRestoreRecord(record, signal));\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/** Hold a crash record lock throughout staging and publication; preserve the primary failure if cleanup fails. */\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: (assertActive: () => void) => 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\tlockfile.lock(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 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(assertActive);\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\ttry {\n\t\t\t\tawait cleanRestoreRecord(record);\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: record.staging, 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/** The shared object store of the repository that `remotes` name, under `storeDir`. */\nfunction objectStorePath(storeDir: string, remotes: readonly string[]): string {\n\treturn join(storeDir, \"repositories\", `${sha256Hex(remotes.join(\"\\n\")).slice(0, 24)}.git`);\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 restores never\n * initialize one store at once, and an existing store is left alone: re-initializing rewrites its configuration, which\n * on Windows fails the other restores' Git processes that are reading it.\n */\nasync function ensureObjectStore(store: string, snapshotId: string | null, signal?: AbortSignal): Promise<void> {\n\tif (await initializedStore(store)) return;\n\tconst repositories = dirname(store);\n\tawait writing(repositories, snapshotId, () => mkdir(repositories, { recursive: true }));\n\tawait runGit([\"init\", \"-q\", \"--bare\", store], { cwd: repositories, signal });\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/** `git fetch` of `refspecs` from `repository`; the `--` keeps a recorded value from ever being read as an option. */\nfunction fetchArgs(repository: string, refspecs: readonly string[]): string[] {\n\treturn [...FETCH_TRANSPORTS, \"fetch\", \"-q\", \"--no-tags\", \"--no-write-fetch-head\", \"--\", repository, ...refspecs];\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(git: GitRunOptions, repository: string, refspecs: readonly string[]): Promise<GitRunResult> {\n\treturn runGit(fetchArgs(repository, refspecs), { ...git, nonInteractive: true });\n}\n\nasync function fetchCommits(\n\tgit: GitRunOptions,\n\tremotes: readonly string[],\n\tcommits: readonly string[],\n): Promise<Error | undefined> {\n\tlet failure: Error | undefined;\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 undefined;\n\t\ttry {\n\t\t\tawait runFetch(git, remote, missing);\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;\n}\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<void> {\n\tconst { head } = snapshot;\n\tif (!(await hasObject(git, `${head}^{commit}`))) {\n\t\tlet failure = await fetchCommits(git, snapshot.remotes, [head]);\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;\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} 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\tawait runGit([\"update-ref\", `refs/atomic/heads/${head}`, head], git);\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\nasync function materialize(\n\tgit: GitRunOptions,\n\ttarget: string,\n\thead: string,\n\ttree: string,\n\tscratch: string,\n\tsnapshotId: string | null,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tawait runGit([\"worktree\", \"add\", \"-q\", \"--detach\", \"--no-checkout\", target, head], git);\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}\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));\n}\n\nasync function restoreValidated(\n\ttarget: WorkspaceBinding,\n\toptions: RestoreWorktreeSnapshotOptions,\n): Promise<RestoredWorktree> {\n\tconst settings = DEFAULT_WORKTREE_SNAPSHOT_SETTINGS;\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\tjoin(storeDir, \"worktrees\", `${(snapshot?.id ?? target.tree).slice(0, 12)}-${randomUUID().slice(0, 8)}`),\n\t);\n\tawait checkTarget(path, snapshotId);\n\tconst patches = snapshot\n\t\t? await Promise.all(\n\t\t\t\tsnapshot.chain.map((link, deltaIndex) =>\n\t\t\t\t\tlink.patch === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: loadBlob(options.blobs, link.patch, { snapshotId: snapshot.id, role: \"patch\", deltaIndex }),\n\t\t\t\t),\n\t\t\t)\n\t\t: [];\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 sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = objectStorePath(storeDir, target.remotes);\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tawait withRepositoryLock(store, async () => {\n\t\t\tawait ensureObjectStore(store, snapshotId, signal);\n\t\t\tawait ensureHead(\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\toptions.blobs,\n\t\t\t\tscratch,\n\t\t\t);\n\t\t\tif (!(await hasObject(git, `${target.tree}^{tree}`))) {\n\t\t\t\tif (!snapshot) {\n\t\t\t\t\tthrow new WorkspaceRestoreError(\"snapshot-not-found\", {\n\t\t\t\t\t\tsnapshotId: null,\n\t\t\t\t\t\thead: target.head,\n\t\t\t\t\t\ttree: target.tree,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tawait reconstructTree(git, snapshot, patches, scratch);\n\t\t\t}\n\t\t});\n\t\tawait checkTarget(path, snapshotId);\n\t\tconst createdTarget = (await statIfPresent(path)) === undefined;\n\t\tconst id = randomUUID();\n\t\tconst staging =\n\t\t\toptions.into === undefined\n\t\t\t\t? join(storeDir, \"worktrees\", `.staging-${id}`)\n\t\t\t\t: join(dirname(path), `.${basename(path)}.atomic-restore-${id}`);\n\t\tconst record: RestoreRecord = { staging, target: path, store, createdTarget };\n\t\tawait withRestoreRecord(storeDir, id, record, snapshotId, warn, signal, async (assertActive) => {\n\t\t\tawait materialize(git, staging, target.head, target.tree, scratch, snapshotId, signal);\n\t\t\tassertActive();\n\t\t\tif (snapshot?.filters?.drivers.includes(\"lfs\")) {\n\t\t\t\tconst worktree: GitRunOptions = { cwd: staging, signal };\n\t\t\t\tconst pointers = await pullLfsObjects(worktree, target.head, target.tree, snapshot.remotes);\n\t\t\t\tif (pointers.length > 0) warn({ code: \"lfs-objects-unavailable\", paths: pointers });\n\t\t\t}\n\t\t\tconst checkout = await locateCheckout(staging, signal);\n\t\t\tif (checkout instanceof Error) throw checkout;\n\t\t\tconst policy = await loadSnapshotPathPolicy(staging);\n\t\t\tconst actual = await withScratchDirectory((verifyScratch) =>\n\t\t\t\twriteWorkingTree(checkout, settings, policy, verifyScratch, {\n\t\t\t\t\tsignal,\n\t\t\t\t\tneutral: true,\n\t\t\t\t\tseedTree: target.tree,\n\t\t\t\t\tattributesFile: join(scratch, \"empty-attributes\"),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (checkout.head !== target.head || actual.tree !== target.tree) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"tree-mismatch\", {\n\t\t\t\t\tsnapshotId,\n\t\t\t\t\ttarget: path,\n\t\t\t\t\texpectedTree: target.tree,\n\t\t\t\t\tactualTree: actual.tree,\n\t\t\t\t});\n\t\t\t}\n\t\t\tassertActive();\n\t\t\tif (createdTarget) {\n\t\t\t\tif ((await statIfPresent(path)) !== undefined) {\n\t\t\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tawait writing(path, snapshotId, () => rmdir(path));\n\t\t\t}\n\t\t\tawait runGit([\"worktree\", \"move\", staging, path], git);\n\t\t\t// Git moves *inside* an existing directory. If one appeared after our check, never return it as the\n\t\t\t// verified worktree: remove only the nested worktree that Git registered and leave the user's files alone.\n\t\t\tconst registered = await registeredWorktrees(git);\n\t\t\tconst destination = await physicalPath(path);\n\t\t\tif (!includesPath(registered, destination)) {\n\t\t\t\tconst error = new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t\t\t\tconst nested = join(destination, basename(staging));\n\t\t\t\tif (includesPath(registered, nested)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait runGit([\"worktree\", \"remove\", \"--force\", \"--force\", nested], { ...git, signal: undefined });\n\t\t\t\t\t} catch (cleanupCause) {\n\t\t\t\t\t\tObject.defineProperty(error, \"cleanupCause\", { value: cleanupCause, configurable: true });\n\t\t\t\t\t\twarn({ code: \"stale-restore-retained\", path: nested, kind: \"worktree\" });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tassertActive();\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/** 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}; remove the directory and retry cleanup.`,\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\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 removeWorktree({ cwd: repositories, env: { GIT_DIR: store }, signal: options.signal }, target);\n}\n\nfunction isWithin(parent: string, child: string): boolean {\n\tconst path = relative(parent, child);\n\treturn path !== \"\" && !path.startsWith(\"..\") && !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,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACN,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIN,OAAO,EACP,SAAS,EACT,MAAM,EACN,uBAAuB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EACN,kCAAkC,EAClC,+BAA+B,GAE/B,MAAM,eAAe,CAAC;AAmCvB,oHAAoH;AACpH,MAAM,UAAU,uBAAuB,CAAC,QAA0B;IACj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AAC,CACzG,CAAC;IACF,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;QACnE,MAAM,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 { randomUUID } from \"node:crypto\";\nimport type { Stats } from \"node:fs\";\nimport { lstat, mkdir, open, readdir, readFile, realpath, rm, rmdir, stat, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../../config.js\";\nimport {\n\tlocateCheckout,\n\treadRepositoryConfig,\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 { loadSnapshotPathPolicy } from \"./policy.ts\";\nimport { assertUsableBundlePrerequisites, assertUsableSnapshotRecord, isAllowedRemote } from \"./records.ts\";\nimport {\n\tDEFAULT_WORKTREE_SNAPSHOT_SETTINGS,\n\tresolveWorktreeSnapshotSettings,\n\ttype WorktreeSnapshotSettingsInput,\n} from \"./settings.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 * 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 function defaultWorktreeSnapshotStoreDir(): string {\n\treturn join(getAgentDir(), \"worktree-snapshots\");\n}\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; Git's own locks cover other processes. */\nasync function withRepositoryLock<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/** 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}\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\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\tconst defaultStaging = join(storeDir, \"worktrees\", `.staging-${id}`);\n\tconst siblingStaging = join(dirname(record.target), `.${basename(record.target)}.atomic-restore-${id}`);\n\treturn (\n\t\trecord.staging === siblingStaging ||\n\t\t(record.staging === defaultStaging && dirname(record.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/** Remove a registered or partially initialized staging worktree, then restore a previously empty target if needed. */\nasync function cleanRestoreRecord(record: RestoreRecord, signal?: AbortSignal): Promise<void> {\n\tconst git: GitRunOptions = { cwd: dirname(record.store), env: { GIT_DIR: record.store }, signal };\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\tif (!entry.isDirectory() || !includesPath(await registeredWorktrees(git), registeredPath)) {\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}\n\tconst removed = await runGit([\"worktree\", \"remove\", \"--force\", \"--force\", record.staging], {\n\t\t...git,\n\t\tallowExitCodes: [128],\n\t});\n\tif (entry && removed.exitCode !== 0) {\n\t\tthrow new WorkspaceGitError({\n\t\t\toperation: \"worktree remove\",\n\t\t\tcwd: git.cwd,\n\t\t\texitCode: removed.exitCode,\n\t\t\tdetail: \"could not remove the staging worktree\",\n\t\t});\n\t}\n\tawait writing(record.staging, null, () => rm(record.staging, { recursive: true, force: true }));\n\tif (!record.createdTarget && (await statIfPresent(record.target)) === undefined) {\n\t\tawait writing(record.target, null, () => mkdir(record.target, { recursive: true }));\n\t}\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}\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 lockfile.lock(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 withRepositoryLock(record.store, () => cleanRestoreRecord(record, signal));\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/** Hold a crash record lock throughout staging and publication; preserve the primary failure if cleanup fails. */\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: (assertActive: () => void) => 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\tlockfile.lock(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 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(assertActive);\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\ttry {\n\t\t\t\tawait cleanRestoreRecord(record);\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: record.staging, 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/** The shared object store of the repository that `remotes` name, under `storeDir`. */\nfunction objectStorePath(storeDir: string, remotes: readonly string[]): string {\n\treturn join(storeDir, \"repositories\", `${sha256Hex(remotes.join(\"\\n\")).slice(0, 24)}.git`);\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 restores never\n * initialize one store at once, and an existing store is left alone: re-initializing rewrites its configuration, which\n * on Windows fails the other restores' Git processes that are reading it.\n */\nasync function ensureObjectStore(store: string, snapshotId: string | null, signal?: AbortSignal): Promise<void> {\n\tif (await initializedStore(store)) return;\n\tconst repositories = dirname(store);\n\tawait writing(repositories, snapshotId, () => mkdir(repositories, { recursive: true }));\n\tawait runGit([\"init\", \"-q\", \"--bare\", store], { cwd: repositories, signal });\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/** `git fetch` of `refspecs` from `repository`; the `--` keeps a recorded value from ever being read as an option. */\nfunction fetchArgs(repository: string, refspecs: readonly string[]): string[] {\n\treturn [...FETCH_TRANSPORTS, \"fetch\", \"-q\", \"--no-tags\", \"--no-write-fetch-head\", \"--\", repository, ...refspecs];\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(git: GitRunOptions, repository: string, refspecs: readonly string[]): Promise<GitRunResult> {\n\treturn runGit(fetchArgs(repository, refspecs), { ...git, nonInteractive: true });\n}\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\nasync function fetchCommits(\n\tgit: GitRunOptions,\n\tremotes: readonly string[],\n\tcommits: readonly string[],\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\ttry {\n\t\t\tawait runFetch(git, remote, missing);\n\t\t\tsupplied = true;\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 * 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.\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]);\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} 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. 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) => 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 configured.length === remotes.length && configured.every((remote, index) => remote === remotes[index]);\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\nasync function materialize(\n\tgit: GitRunOptions,\n\ttarget: string,\n\thead: string,\n\ttree: string,\n\tscratch: string,\n\tsnapshotId: string | null,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tawait runGit([\"worktree\", \"add\", \"-q\", \"--detach\", \"--no-checkout\", target, head], git);\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}\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));\n}\n\nasync function restoreValidated(\n\ttarget: WorkspaceBinding,\n\toptions: RestoreWorktreeSnapshotOptions,\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\tjoin(storeDir, \"worktrees\", `${(snapshot?.id ?? target.tree).slice(0, 12)}-${randomUUID().slice(0, 8)}`),\n\t);\n\tawait checkTarget(path, snapshotId);\n\tconst patches = snapshot\n\t\t? await Promise.all(\n\t\t\t\tsnapshot.chain.map((link, deltaIndex) =>\n\t\t\t\t\tlink.patch === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: loadBlob(options.blobs, link.patch, { snapshotId: snapshot.id, role: \"patch\", deltaIndex }),\n\t\t\t\t),\n\t\t\t)\n\t\t: [];\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 sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = objectStorePath(storeDir, target.remotes);\n\t\tconst git: GitRunOptions = { cwd: scratch, signal, env: { GIT_DIR: store } };\n\t\tawait withRepositoryLock(store, async () => {\n\t\t\tawait ensureObjectStore(store, snapshotId, signal);\n\t\t\tconst fetched = await ensureHead(\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\toptions.blobs,\n\t\t\t\tscratch,\n\t\t\t);\n\t\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\t\tconst sameRemotes =\n\t\t\t\tsnapshot === null ||\n\t\t\t\t(snapshot.remotes.length === target.remotes.length &&\n\t\t\t\t\tsnapshot.remotes.every((remote, index) => remote === target.remotes[index]));\n\t\t\tconst pushed =\n\t\t\t\t(await configureRecordedRemotes(git, target.remotes)) && sameRemotes\n\t\t\t\t\t? await pushedCommits(git, snapshot, target.head, fetched)\n\t\t\t\t\t: new Set<string>();\n\t\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t\t...git,\n\t\t\t\tinput: [\n\t\t\t\t\t`update refs/atomic/heads/${target.head} ${target.head}\\n`,\n\t\t\t\t\t...[...pushed].map((commit) => `update ${PUSHED_REFS}${commit} ${commit}\\n`),\n\t\t\t\t].join(\"\"),\n\t\t\t});\n\t\t\tif (!(await hasObject(git, `${target.tree}^{tree}`))) {\n\t\t\t\tif (!snapshot) {\n\t\t\t\t\tthrow new WorkspaceRestoreError(\"snapshot-not-found\", {\n\t\t\t\t\t\tsnapshotId: null,\n\t\t\t\t\t\thead: target.head,\n\t\t\t\t\t\ttree: target.tree,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tawait reconstructTree(git, snapshot, patches, scratch);\n\t\t\t}\n\t\t});\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});\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/** 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));\n}\n\nasync function restoreDegradedValidated(\n\tsnapshot: WorktreeSnapshot,\n\tfailure: WorkspaceRestoreError,\n\toptions: RestoreDegradedWorktreeOptions,\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 = join(storeDir, \"worktrees\", `${snapshot.id.slice(0, 12)}-${randomUUID().slice(0, 8)}`);\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 sweepRestoreRecords(storeDir, warn, signal);\n\treturn withScratchDirectory(async (scratch) => {\n\t\tconst store = objectStorePath(storeDir, snapshot.remotes);\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(store, async (): Promise<WorktreeDegradedRestore> => {\n\t\t\tawait ensureObjectStore(store, snapshot.id, signal);\n\t\t\tconst configured = await configureRecordedRemotes(git, snapshot.remotes);\n\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\tconst reached = await ensureHead(git, snapshot, options.blobs, scratch).then(\n\t\t\t\t(fetched) => ({ fetched }),\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tif (isWorkspaceRestoreError(error)) return undefined;\n\t\t\t\t\tthrow error;\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (reached !== undefined) {\n\t\t\t\tconst partial = await applicableChanges(git, snapshot, options.blobs, scratch);\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/${snapshot.head} ${snapshot.head}\\n`,\n\t\t\t\t\t\t...(configured && reached.fetched\n\t\t\t\t\t\t\t? [`update ${PUSHED_REFS}${snapshot.head} ${snapshot.head}\\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: \"partial-changes\",\n\t\t\t\t\thead: snapshot.head,\n\t\t\t\t\ttree: partial.tree,\n\t\t\t\t\tmissingLinks: partial.missingLinks,\n\t\t\t\t\tmissingPaths: partial.missingPaths,\n\t\t\t\t\tmissingCommits: [],\n\t\t\t\t\t...cause,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst closest = await closestCommit(git, snapshot, candidates, options.blobs);\n\t\t\tif (closest === undefined) throw failure;\n\t\t\tawait runGit([\"update-ref\", \"--stdin\"], {\n\t\t\t\t...git,\n\t\t\t\tinput: [\n\t\t\t\t\t`update refs/atomic/heads/${closest.commit} ${closest.commit}\\n`,\n\t\t\t\t\t...(configured && closest.fromRemote\n\t\t\t\t\t\t? [`update ${PUSHED_REFS}${closest.commit} ${closest.commit}\\n`]\n\t\t\t\t\t\t: []),\n\t\t\t\t].join(\"\"),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tstage: \"closest-commit\",\n\t\t\t\thead: closest.commit,\n\t\t\t\ttree: await gitText([\"rev-parse\", `${closest.commit}^{tree}`], git),\n\t\t\t\tbasis: closest.basis,\n\t\t\t\tmissingLinks: snapshot.chain.flatMap((link, index) => (link.patch === null ? [] : [index])),\n\t\t\t\tmissingPaths: [],\n\t\t\t\tmissingCommits: unpushedCommits(snapshot),\n\t\t\t\t...cause,\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\tverify: failure.code === \"tree-mismatch\" ? \"head\" : \"tree\",\n\t\t});\n\t\tif (measured === degraded.tree) return { path, degraded, warnings };\n\t\t// This host's checkout filters changed files: 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 missingPaths = [...new Set([...degraded.missingPaths, ...differing])].sort();\n\t\treturn { path, degraded: { ...degraded, tree: measured, missingPaths }, warnings };\n\t});\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/**\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} 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/**\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/**\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\tlet measured = tree;\n\tconst settings = DEFAULT_WORKTREE_SNAPSHOT_SETTINGS;\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 =\n\t\tpublish.into === undefined\n\t\t\t? join(storeDir, \"worktrees\", `.staging-${id}`)\n\t\t\t: join(dirname(path), `.${basename(path)}.atomic-restore-${id}`);\n\tconst record: RestoreRecord = { staging, target: path, store, createdTarget };\n\tawait withRestoreRecord(storeDir, id, record, snapshotId, warn, signal, async (assertActive) => {\n\t\tawait materialize(git, staging, head, tree, scratch, snapshotId, signal);\n\t\tassertActive();\n\t\tif (snapshot?.filters?.drivers.includes(\"lfs\")) {\n\t\t\tconst worktree: GitRunOptions = { cwd: staging, signal };\n\t\t\tconst pointers = await pullLfsObjects(worktree, head, tree, snapshot.remotes);\n\t\t\tif (pointers.length > 0) warn({ code: \"lfs-objects-unavailable\", paths: pointers });\n\t\t}\n\t\tconst checkout = await locateCheckout(staging, signal);\n\t\tif (checkout instanceof Error) throw checkout;\n\t\tconst policy = await loadSnapshotPathPolicy(staging);\n\t\tconst actual = await withScratchDirectory((verifyScratch) =>\n\t\t\twriteWorkingTree(checkout, settings, policy, verifyScratch, {\n\t\t\t\tsignal,\n\t\t\t\tneutral: true,\n\t\t\t\tseedTree: tree,\n\t\t\t\tattributesFile: join(scratch, \"empty-attributes\"),\n\t\t\t}),\n\t\t);\n\t\tmeasured = actual.tree;\n\t\tif (checkout.head !== head || (publish.verify === \"tree\" && actual.tree !== tree)) {\n\t\t\tthrow new WorkspaceRestoreError(\"tree-mismatch\", {\n\t\t\t\tsnapshotId,\n\t\t\t\ttarget: path,\n\t\t\t\texpectedTree: tree,\n\t\t\t\tactualTree: actual.tree,\n\t\t\t});\n\t\t}\n\t\tassertActive();\n\t\tif (createdTarget) {\n\t\t\tif ((await statIfPresent(path)) !== undefined) {\n\t\t\t\tthrow new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t\t\t}\n\t\t} else {\n\t\t\tawait writing(path, snapshotId, () => rmdir(path));\n\t\t}\n\t\tawait runGit([\"worktree\", \"move\", staging, path], git);\n\t\t// Git moves *inside* an existing directory. If one appeared after our check, never return it as the\n\t\t// verified worktree: remove only the nested worktree that Git registered and leave the user's files alone.\n\t\tconst registered = await registeredWorktrees(git);\n\t\tconst destination = await physicalPath(path);\n\t\tif (!includesPath(registered, destination)) {\n\t\t\tconst error = new WorkspaceRestoreError(\"unsafe-target\", { snapshotId, target: path, reason: \"not-empty\" });\n\t\t\tconst nested = join(destination, basename(staging));\n\t\t\tif (includesPath(registered, nested)) {\n\t\t\t\ttry {\n\t\t\t\t\tawait runGit([\"worktree\", \"remove\", \"--force\", \"--force\", nested], { ...git, signal: undefined });\n\t\t\t\t} catch (cleanupCause) {\n\t\t\t\t\tObject.defineProperty(error, \"cleanupCause\", { value: cleanupCause, configurable: true });\n\t\t\t\t\twarn({ code: \"stale-restore-retained\", path: nested, kind: \"worktree\" });\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tassertActive();\n\t});\n\treturn measured;\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}; remove the directory and retry cleanup.`,\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\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 removeWorktree({ cwd: repositories, env: { GIT_DIR: store }, signal: options.signal }, target);\n}\n\nfunction isWithin(parent: string, child: string): boolean {\n\tconst path = relative(parent, child);\n\treturn path !== \"\" && !path.startsWith(\"..\") && !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"]}
|
|
@@ -129,6 +129,33 @@ export type WorktreeRestoreWarning = {
|
|
|
129
129
|
/** What was left: a staging or nested worktree, a crash record file, or the crash-record directory itself. */
|
|
130
130
|
readonly kind: "worktree" | "record" | "records-directory";
|
|
131
131
|
};
|
|
132
|
+
/** Which commit a restore that could not reach a snapshot's recorded `HEAD` checked out instead. */
|
|
133
|
+
export type WorktreeDegradedRestoreBasis = "pushed-base" | "earlier-snapshot" | "branch-tip";
|
|
134
|
+
/**
|
|
135
|
+
* What a restore that could not reproduce its snapshot exactly restored instead (#4733): the recorded `HEAD` with the
|
|
136
|
+
* change sets of the patch chain that could be applied (`partial-changes`), or the closest commit it could fetch, with
|
|
137
|
+
* none of the snapshot's changes (`closest-commit`).
|
|
138
|
+
*/
|
|
139
|
+
export interface WorktreeDegradedRestore {
|
|
140
|
+
readonly stage: "partial-changes" | "closest-commit";
|
|
141
|
+
/** The commit the worktree has checked out. */
|
|
142
|
+
readonly head: string;
|
|
143
|
+
/** The Git tree of the worktree's content when it was restored. */
|
|
144
|
+
readonly tree: string;
|
|
145
|
+
/** With `closest-commit`, where `head` came from. */
|
|
146
|
+
readonly basis?: WorktreeDegradedRestoreBasis;
|
|
147
|
+
/** Indexes of the patch chain's change sets that are not in the worktree. */
|
|
148
|
+
readonly missingLinks: readonly number[];
|
|
149
|
+
/** Paths those change sets touch, where their content was available to list them. */
|
|
150
|
+
readonly missingPaths: readonly string[];
|
|
151
|
+
/** Recorded commits that are not in the worktree. */
|
|
152
|
+
readonly missingCommits: readonly string[];
|
|
153
|
+
/** The code of the restore error that kept the exact state from being restored, and its reason when it has one. */
|
|
154
|
+
readonly cause: string;
|
|
155
|
+
readonly causeReason?: string;
|
|
156
|
+
/** What to do to get the rest: the restore error's hint. */
|
|
157
|
+
readonly hint: string;
|
|
158
|
+
}
|
|
132
159
|
/** A checkout restored on this host in place of one recorded elsewhere: work under `from` now happens under `to`. */
|
|
133
160
|
export interface WorktreeRootMapping {
|
|
134
161
|
readonly from: string;
|
|
@@ -136,5 +163,22 @@ export interface WorktreeRootMapping {
|
|
|
136
163
|
readonly snapshotId: string;
|
|
137
164
|
readonly tree: string;
|
|
138
165
|
readonly restoredAt: string;
|
|
166
|
+
/** Present when `to` holds less than the snapshot: what it holds and what is missing (#4733). */
|
|
167
|
+
readonly degraded?: WorktreeDegradedRestore;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* A checkout a resume continued without (#4733): nothing of its snapshot could be restored on this host, so the
|
|
171
|
+
* session went on in `continuedIn`, as it was.
|
|
172
|
+
*/
|
|
173
|
+
export interface WorktreeUnrestored {
|
|
174
|
+
readonly snapshotId: string;
|
|
175
|
+
readonly continuedIn: string;
|
|
176
|
+
/** Whether `continuedIn` is the session's recorded working directory, or the directory the resume started in. */
|
|
177
|
+
readonly place: "recorded" | "launch";
|
|
178
|
+
readonly cause: string;
|
|
179
|
+
readonly causeReason?: string;
|
|
180
|
+
readonly detail: string;
|
|
181
|
+
readonly hint: string;
|
|
182
|
+
readonly at: string;
|
|
139
183
|
}
|
|
140
184
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,qHAAqH;AACrH,MAAM,WAAW,wBAAwB;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gHAAgH;IAChH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,4FAA4F;IAC5F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4H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,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The portable identity of a workspace: the remotes that hold its history, the commit it is based on, the Git tree of\n * its content, and a fingerprint of its dependency inputs. Schedulers and workspace providers consume this shape.\n */\nexport interface WorkspaceBinding {\n\tremotes: string[];\n\thead: string;\n\ttree: string;\n\tenvHash: string;\n}\n\n/** Snapshot capture settings, from `snapshots.*` in settings.json, `createAgentSession`, or workflow run options. */\nexport interface WorktreeSnapshotSettings {\n\t/** Record snapshots at all. Default true. */\n\treadonly enabled: boolean;\n\t/** Capture untracked files that no ignore rule or deny pattern excludes. Default true. */\n\treadonly includeUntracked: boolean;\n\t/** Largest single file captured, in bytes. Default 5 MiB. */\n\treadonly maxFileBytes: number;\n\t/** Largest total of captured file content, patch chain and unpushed-commit bundle, in bytes. Default 50 MiB. */\n\treadonly maxSnapshotBytes: number;\n\t/** Record a full delta against `head` after this many incremental snapshots. Default 10. */\n\treadonly fullEvery: number;\n\t/** Delete unreferenced snapshot blobs automatically when a session closes or a root workflow run finishes. Default true. */\n\treadonly autoCollect: boolean;\n\t/** Shortest time between two automatic collections of one database, in seconds, on the database's clock. Default 3600. */\n\treadonly collectIntervalSeconds: number;\n\t/** Blobs stored or re-stored less than this many seconds ago are never collected. 0 turns the protection off. Default 3600. */\n\treadonly graceSeconds: number;\n}\n\nexport type WorktreeSnapshotPathOmissionReason = \"denied\" | \"snapshot-ignore\" | \"untracked-excluded\";\nexport type WorktreeSnapshotSizeOmissionReason = \"over-file-cap\" | \"over-snapshot-cap\";\n\n/** Content a snapshot left out, and why. */\nexport type WorktreeSnapshotOmission =\n\t| { readonly reason: WorktreeSnapshotPathOmissionReason; readonly path: string }\n\t| { readonly reason: WorktreeSnapshotSizeOmissionReason; readonly path: string; readonly bytes: number }\n\t| {\n\t\t\treadonly reason: \"unpushed-history-denied\";\n\t\t\treadonly commits: readonly string[];\n\t\t\treadonly paths: readonly string[];\n\t }\n\t| { readonly reason: \"bundle-over-cap\"; readonly commits: readonly string[]; readonly bytes: number };\n\nexport type WorktreeSnapshotOmissionReason = WorktreeSnapshotOmission[\"reason\"];\n\n/** One step of a patch chain: applying `patch` (a blob hash, or null for no change) produces `tree`. */\nexport interface WorktreeSnapshotChainLink {\n\treadonly tree: string;\n\treadonly patch: string | null;\n\treadonly bytes: number;\n}\n\n/** Conversion settings on the recording machine that can make a worktree's files differ from Git's stored content. */\nexport interface WorktreeSnapshotFilters {\n\treadonly autocrlf: string | null;\n\treadonly eol: string | null;\n\t/** Filter drivers that the repository's `.gitattributes` files name, such as `lfs`. */\n\treadonly drivers: readonly string[];\n}\n\nexport interface WorktreeSnapshotBundle {\n\t/** Blob hash of a `git bundle` holding the commits reachable from `head` and from no remote-tracking ref. */\n\treadonly blob: string;\n\treadonly bytes: number;\n\treadonly commits: readonly string[];\n}\n\n/** The recorded state of one repository checkout. Every field is JSON. Blob hashes refer to a {@link SnapshotBlobStore}. */\nexport interface WorktreeSnapshot {\n\treadonly version: 1;\n\t/** Content-derived identity: equal ids mean equal reconstruction inputs. */\n\treadonly id: string;\n\t/** Absolute checkout root on the recording machine. Informational. */\n\treadonly root: string;\n\treadonly remotes: readonly string[];\n\t/** Current branch, or null when detached. */\n\treadonly branch: string | null;\n\treadonly head: string;\n\t/** Commit object for the full working tree, parented on `head`. Local to the recording machine. */\n\treadonly snapshot: string;\n\treadonly tree: string;\n\treadonly envHash: string;\n\t/** The newest link: a full delta against `head`, or an incremental one against the previous snapshot. */\n\treadonly delta: { readonly base: \"head\" | string; readonly patch: string | null; readonly bytes: number };\n\t/** Links from the latest full delta to this snapshot, in application order. Never longer than `fullEvery`. */\n\treadonly chain: readonly WorktreeSnapshotChainLink[];\n\treadonly bundle: WorktreeSnapshotBundle | null;\n\treadonly omitted: readonly WorktreeSnapshotOmission[];\n\treadonly filters: WorktreeSnapshotFilters | null;\n\treadonly capturedAt: string;\n}\n\nexport interface SnapshotBlob {\n\t/** Lowercase hex SHA-256 of `data`. */\n\treadonly hash: string;\n\treadonly data: Uint8Array;\n}\n\n/** Content-addressed storage for snapshot patches and bundles, kept in the same storage as sessions or journals. */\nexport interface SnapshotBlobStore {\n\t/** Stores each blob once. Storing a hash that exists keeps its bytes and restarts its age, which protects it from collection. */\n\tputBlobs(blobs: readonly SnapshotBlob[]): Promise<void>;\n\tgetBlob(hash: string): Promise<Uint8Array | undefined>;\n\t/**\n\t * Restarts the age of each stored hash, as storing it again would, without its bytes. Resolves false when any is\n\t * missing. Capture calls it before reusing an earlier snapshot's blobs, so collection keeps them until the new\n\t * snapshot that references them is published.\n\t */\n\trefreshBlobs(hashes: readonly string[]): Promise<boolean>;\n\t/** Every stored hash. */\n\tlistBlobHashes(): Promise<readonly string[]>;\n}\n\n/** Restore-time notices that never block a verified restore. */\nexport type WorktreeRestoreWarning =\n\t| { readonly code: \"omitted-content\"; readonly omitted: readonly WorktreeSnapshotOmission[] }\n\t| { readonly code: \"filters\"; readonly filters: WorktreeSnapshotFilters }\n\t| { readonly code: \"lfs-objects-unavailable\"; readonly paths: readonly string[] }\n\t| {\n\t\t\treadonly code: \"stale-restore-retained\";\n\t\t\treadonly path: string;\n\t\t\t/** What was left: a staging or nested worktree, a crash record file, or the crash-record directory itself. */\n\t\t\treadonly kind: \"worktree\" | \"record\" | \"records-directory\";\n\t };\n\n/** A checkout restored on this host in place of one recorded elsewhere: work under `from` now happens under `to`. */\nexport interface WorktreeRootMapping {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly snapshotId: string;\n\treadonly tree: string;\n\treadonly restoredAt: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The portable identity of a workspace: the remotes that hold its history, the commit it is based on, the Git tree of\n * its content, and a fingerprint of its dependency inputs. Schedulers and workspace providers consume this shape.\n */\nexport interface WorkspaceBinding {\n\tremotes: string[];\n\thead: string;\n\ttree: string;\n\tenvHash: string;\n}\n\n/** Snapshot capture settings, from `snapshots.*` in settings.json, `createAgentSession`, or workflow run options. */\nexport interface WorktreeSnapshotSettings {\n\t/** Record snapshots at all. Default true. */\n\treadonly enabled: boolean;\n\t/** Capture untracked files that no ignore rule or deny pattern excludes. Default true. */\n\treadonly includeUntracked: boolean;\n\t/** Largest single file captured, in bytes. Default 5 MiB. */\n\treadonly maxFileBytes: number;\n\t/** Largest total of captured file content, patch chain and unpushed-commit bundle, in bytes. Default 50 MiB. */\n\treadonly maxSnapshotBytes: number;\n\t/** Record a full delta against `head` after this many incremental snapshots. Default 10. */\n\treadonly fullEvery: number;\n\t/** Delete unreferenced snapshot blobs automatically when a session closes or a root workflow run finishes. Default true. */\n\treadonly autoCollect: boolean;\n\t/** Shortest time between two automatic collections of one database, in seconds, on the database's clock. Default 3600. */\n\treadonly collectIntervalSeconds: number;\n\t/** Blobs stored or re-stored less than this many seconds ago are never collected. 0 turns the protection off. Default 3600. */\n\treadonly graceSeconds: number;\n}\n\nexport type WorktreeSnapshotPathOmissionReason = \"denied\" | \"snapshot-ignore\" | \"untracked-excluded\";\nexport type WorktreeSnapshotSizeOmissionReason = \"over-file-cap\" | \"over-snapshot-cap\";\n\n/** Content a snapshot left out, and why. */\nexport type WorktreeSnapshotOmission =\n\t| { readonly reason: WorktreeSnapshotPathOmissionReason; readonly path: string }\n\t| { readonly reason: WorktreeSnapshotSizeOmissionReason; readonly path: string; readonly bytes: number }\n\t| {\n\t\t\treadonly reason: \"unpushed-history-denied\";\n\t\t\treadonly commits: readonly string[];\n\t\t\treadonly paths: readonly string[];\n\t }\n\t| { readonly reason: \"bundle-over-cap\"; readonly commits: readonly string[]; readonly bytes: number };\n\nexport type WorktreeSnapshotOmissionReason = WorktreeSnapshotOmission[\"reason\"];\n\n/** One step of a patch chain: applying `patch` (a blob hash, or null for no change) produces `tree`. */\nexport interface WorktreeSnapshotChainLink {\n\treadonly tree: string;\n\treadonly patch: string | null;\n\treadonly bytes: number;\n}\n\n/** Conversion settings on the recording machine that can make a worktree's files differ from Git's stored content. */\nexport interface WorktreeSnapshotFilters {\n\treadonly autocrlf: string | null;\n\treadonly eol: string | null;\n\t/** Filter drivers that the repository's `.gitattributes` files name, such as `lfs`. */\n\treadonly drivers: readonly string[];\n}\n\nexport interface WorktreeSnapshotBundle {\n\t/** Blob hash of a `git bundle` holding the commits reachable from `head` and from no remote-tracking ref. */\n\treadonly blob: string;\n\treadonly bytes: number;\n\treadonly commits: readonly string[];\n}\n\n/** The recorded state of one repository checkout. Every field is JSON. Blob hashes refer to a {@link SnapshotBlobStore}. */\nexport interface WorktreeSnapshot {\n\treadonly version: 1;\n\t/** Content-derived identity: equal ids mean equal reconstruction inputs. */\n\treadonly id: string;\n\t/** Absolute checkout root on the recording machine. Informational. */\n\treadonly root: string;\n\treadonly remotes: readonly string[];\n\t/** Current branch, or null when detached. */\n\treadonly branch: string | null;\n\treadonly head: string;\n\t/** Commit object for the full working tree, parented on `head`. Local to the recording machine. */\n\treadonly snapshot: string;\n\treadonly tree: string;\n\treadonly envHash: string;\n\t/** The newest link: a full delta against `head`, or an incremental one against the previous snapshot. */\n\treadonly delta: { readonly base: \"head\" | string; readonly patch: string | null; readonly bytes: number };\n\t/** Links from the latest full delta to this snapshot, in application order. Never longer than `fullEvery`. */\n\treadonly chain: readonly WorktreeSnapshotChainLink[];\n\treadonly bundle: WorktreeSnapshotBundle | null;\n\treadonly omitted: readonly WorktreeSnapshotOmission[];\n\treadonly filters: WorktreeSnapshotFilters | null;\n\treadonly capturedAt: string;\n}\n\nexport interface SnapshotBlob {\n\t/** Lowercase hex SHA-256 of `data`. */\n\treadonly hash: string;\n\treadonly data: Uint8Array;\n}\n\n/** Content-addressed storage for snapshot patches and bundles, kept in the same storage as sessions or journals. */\nexport interface SnapshotBlobStore {\n\t/** Stores each blob once. Storing a hash that exists keeps its bytes and restarts its age, which protects it from collection. */\n\tputBlobs(blobs: readonly SnapshotBlob[]): Promise<void>;\n\tgetBlob(hash: string): Promise<Uint8Array | undefined>;\n\t/**\n\t * Restarts the age of each stored hash, as storing it again would, without its bytes. Resolves false when any is\n\t * missing. Capture calls it before reusing an earlier snapshot's blobs, so collection keeps them until the new\n\t * snapshot that references them is published.\n\t */\n\trefreshBlobs(hashes: readonly string[]): Promise<boolean>;\n\t/** Every stored hash. */\n\tlistBlobHashes(): Promise<readonly string[]>;\n}\n\n/** Restore-time notices that never block a verified restore. */\nexport type WorktreeRestoreWarning =\n\t| { readonly code: \"omitted-content\"; readonly omitted: readonly WorktreeSnapshotOmission[] }\n\t| { readonly code: \"filters\"; readonly filters: WorktreeSnapshotFilters }\n\t| { readonly code: \"lfs-objects-unavailable\"; readonly paths: readonly string[] }\n\t| {\n\t\t\treadonly code: \"stale-restore-retained\";\n\t\t\treadonly path: string;\n\t\t\t/** What was left: a staging or nested worktree, a crash record file, or the crash-record directory itself. */\n\t\t\treadonly kind: \"worktree\" | \"record\" | \"records-directory\";\n\t };\n\n/** Which commit a restore that could not reach a snapshot's recorded `HEAD` checked out instead. */\nexport type WorktreeDegradedRestoreBasis = \"pushed-base\" | \"earlier-snapshot\" | \"branch-tip\";\n\n/**\n * What a restore that could not reproduce its snapshot exactly restored instead (#4733): the recorded `HEAD` with the\n * change sets of the patch chain that could be applied (`partial-changes`), or the closest commit it could fetch, with\n * none of the snapshot's changes (`closest-commit`).\n */\nexport interface WorktreeDegradedRestore {\n\treadonly stage: \"partial-changes\" | \"closest-commit\";\n\t/** The commit the worktree has checked out. */\n\treadonly head: string;\n\t/** The Git tree of the worktree's content when it was restored. */\n\treadonly tree: string;\n\t/** With `closest-commit`, where `head` came from. */\n\treadonly basis?: WorktreeDegradedRestoreBasis;\n\t/** Indexes of the patch chain's change sets that are not in the worktree. */\n\treadonly missingLinks: readonly number[];\n\t/** Paths those change sets touch, where their content was available to list them. */\n\treadonly missingPaths: readonly string[];\n\t/** Recorded commits that are not in the worktree. */\n\treadonly missingCommits: readonly string[];\n\t/** The code of the restore error that kept the exact state from being restored, and its reason when it has one. */\n\treadonly cause: string;\n\treadonly causeReason?: string;\n\t/** What to do to get the rest: the restore error's hint. */\n\treadonly hint: string;\n}\n\n/** A checkout restored on this host in place of one recorded elsewhere: work under `from` now happens under `to`. */\nexport interface WorktreeRootMapping {\n\treadonly from: string;\n\treadonly to: string;\n\treadonly snapshotId: string;\n\treadonly tree: string;\n\treadonly restoredAt: string;\n\t/** Present when `to` holds less than the snapshot: what it holds and what is missing (#4733). */\n\treadonly degraded?: WorktreeDegradedRestore;\n}\n\n/**\n * A checkout a resume continued without (#4733): nothing of its snapshot could be restored on this host, so the\n * session went on in `continuedIn`, as it was.\n */\nexport interface WorktreeUnrestored {\n\treadonly snapshotId: string;\n\treadonly continuedIn: string;\n\t/** Whether `continuedIn` is the session's recorded working directory, or the directory the resume started in. */\n\treadonly place: \"recorded\" | \"launch\";\n\treadonly cause: string;\n\treadonly causeReason?: string;\n\treadonly detail: string;\n\treadonly hint: string;\n\treadonly at: string;\n}\n"]}
|