@gitkraken/core-gitlens 0.10.7 → 0.11.0

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/dist/git/cache.d.ts +34 -2
  3. package/dist/git/cache.js +53 -7
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +1 -1
  6. package/dist/git/models/repository.d.ts +3 -2
  7. package/dist/git/models/repository.js +5 -4
  8. package/dist/git/models/repository.js.map +1 -1
  9. package/dist/git/providers/branches.d.ts +22 -0
  10. package/dist/git/providers/config.d.ts +3 -1
  11. package/dist/git/providers/provider.d.ts +13 -1
  12. package/dist/git/providers/staging.d.ts +1 -1
  13. package/dist/git/service.d.ts +17 -1
  14. package/dist/git/service.js +59 -8
  15. package/dist/git/service.js.map +1 -1
  16. package/dist/git/watching/changeEvent.d.ts +48 -5
  17. package/dist/git/watching/changeEvent.js +82 -7
  18. package/dist/git/watching/changeEvent.js.map +1 -1
  19. package/dist/git/watching/classifyChange.d.ts +13 -2
  20. package/dist/git/watching/classifyChange.js +40 -5
  21. package/dist/git/watching/classifyChange.js.map +1 -1
  22. package/dist/git/watching/gitIgnoreFilter.d.ts +57 -10
  23. package/dist/git/watching/gitIgnoreFilter.js +186 -29
  24. package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
  25. package/dist/git/watching/initWatcher.d.ts +5 -1
  26. package/dist/git/watching/initWatcher.js +1 -1
  27. package/dist/git/watching/initWatcher.js.map +1 -1
  28. package/dist/git/watching/provider.d.ts +33 -8
  29. package/dist/git/watching/watchGroup.d.ts +13 -2
  30. package/dist/git/watching/watchGroup.js +60 -14
  31. package/dist/git/watching/watchGroup.js.map +1 -1
  32. package/dist/git/watching/watchService.d.ts +42 -1
  33. package/dist/git/watching/watchService.js +172 -20
  34. package/dist/git/watching/watchService.js.map +1 -1
  35. package/dist/git/watching/watchSession.d.ts +50 -17
  36. package/dist/git/watching/watchSession.js +274 -83
  37. package/dist/git/watching/watchSession.js.map +1 -1
  38. package/dist/git/watching/watcherPatterns.d.ts +13 -2
  39. package/dist/git/watching/watcherPatterns.js +22 -2
  40. package/dist/git/watching/watcherPatterns.js.map +1 -1
  41. package/dist/git/watching/worktreeSummary.d.ts +121 -0
  42. package/dist/git/watching/worktreeSummary.js +427 -0
  43. package/dist/git/watching/worktreeSummary.js.map +1 -0
  44. package/dist/git-cli/cliGitProvider.d.ts +6 -1
  45. package/dist/git-cli/cliGitProvider.js +87 -2
  46. package/dist/git-cli/cliGitProvider.js.map +1 -1
  47. package/dist/git-cli/providers/blame.js +1 -1
  48. package/dist/git-cli/providers/branches.d.ts +32 -1
  49. package/dist/git-cli/providers/branches.js +195 -0
  50. package/dist/git-cli/providers/branches.js.map +1 -1
  51. package/dist/git-cli/providers/commits.js +1 -1
  52. package/dist/git-cli/providers/config.d.ts +3 -0
  53. package/dist/git-cli/providers/config.js +12 -6
  54. package/dist/git-cli/providers/config.js.map +1 -1
  55. package/dist/git-cli/providers/contributors.js +1 -1
  56. package/dist/git-cli/providers/graph.js +1 -1
  57. package/dist/git-cli/providers/maintenance.js +1 -1
  58. package/dist/git-cli/providers/refs.js +1 -1
  59. package/dist/git-cli/providers/staging.js +1 -1
  60. package/dist/git-cli/providers/status.js +1 -1
  61. package/dist/git-cli/service.js +1 -0
  62. package/dist/git-cli/service.js.map +1 -1
  63. package/dist/ipc/ipcServer.js +1 -1
  64. package/dist/plus/agents/providers/gkAgentProvider.js +2 -2
  65. package/dist/plus/git-github/api/github.d.ts +1 -1
  66. package/dist/plus/git-github/api/github.js +1 -1
  67. package/dist/plus/git-github/providers/github/blame.js +1 -1
  68. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +1 -1
  69. package/dist/plus/integrations/context.d.ts +1 -1
  70. package/dist/plus/integrations/integrationService.js +1 -1
  71. package/dist/plus/integrations/models/integration.js +1 -1
  72. package/dist/plus/integrations/providers/bitbucket-server.d.ts +1 -1
  73. package/dist/utils/event.d.ts +1 -1
  74. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","names":[],"sources":["../../../git/src/cache.ts"],"sourcesContent":["import { exhaustiveArray } from '@gitlens/utils/array.js';\nimport { raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { invalidateMemoized } from '@gitlens/utils/decorators/memoize.js';\nimport { getBranchId } from '@gitlens/utils/gitRefs.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport type { PromiseOrValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { PromiseCache, PromiseMap, RepoPromiseCacheMap } from '@gitlens/utils/promiseCache.js';\nimport type { ResourceUsage } from '@gitlens/utils/resourceUsage.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport type { ProgressiveGitBlame } from './models/blame.js';\nimport type { BranchMetadata, GitBranch } from './models/branch.js';\nimport type { GitCommit, GitStashCommit } from './models/commit.js';\nimport type { GitContributor, GitContributorsStats } from './models/contributor.js';\nimport type { ParsedGitDiffHunks } from './models/diff.js';\nimport type { GitLog } from './models/log.js';\nimport type { ConflictDetectionResult } from './models/mergeConflicts.js';\nimport type { GitPausedOperationStatus } from './models/pausedOperationStatus.js';\nimport type { GitBranchReference, GitRefTip, RefRecord } from './models/reference.js';\nimport type { GitRemote } from './models/remote.js';\nimport type { RemoteProvider } from './models/remoteProvider.js';\nimport type { GitDir, RepositoryChange } from './models/repository.js';\nimport type { GitStash } from './models/stash.js';\nimport type { GitTag } from './models/tag.js';\nimport type { GitUser } from './models/user.js';\nimport type { GitWorktree } from './models/worktree.js';\nimport type { BranchContributionsOverview, GitBranchMergedStatus } from './providers/branches.js';\nimport type { GitCommitReachability, LeftRightCommitCountResult } from './providers/commits.js';\nimport type { GitContributorsResult } from './providers/contributors.js';\nimport type { ResolvedRevision } from './providers/revision.js';\nimport type { GitResult } from './run.types.js';\nimport { createReference } from './utils/reference.utils.js';\nimport { getCommonRepositoryPath, getRepositoryOrWorktreePath } from './utils/repository.utils.js';\nimport type { GitIgnoreFilter } from './watching/gitIgnoreFilter.js';\n\ntype RepoPath = string;\n\n/** Cache types that are keyed by file path within a repo — support per-file clearing */\nexport type UriScopedCachedGitTypes = 'blame' | 'diff' | 'fileLog';\n\nconst uriScopedCachedGitTypes: UriScopedCachedGitTypes[] = ['blame', 'diff', 'fileLog'];\nexport function areUriScopedCachedGitTypes(types: string[]): types is UriScopedCachedGitTypes[] {\n\treturn types.every(t => uriScopedCachedGitTypes.includes(t as UriScopedCachedGitTypes));\n}\n\nexport type CachedGitTypes =\n\t| UriScopedCachedGitTypes\n\t| 'branch'\n\t| 'branches'\n\t| 'config'\n\t| 'contributors'\n\t| 'gitignore'\n\t| 'gkConfig'\n\t| 'lastFetched'\n\t| 'providers'\n\t| 'remotes'\n\t| 'stashes'\n\t| 'status'\n\t| 'tags'\n\t| 'tracking'\n\t| 'worktrees';\n\n/**\n * What a gk-config reconcile did, so `Cache` knows whether the coarse fallback is still owed.\n *\n * `'deferred'` is NOT a failure — a pass already in flight folds the change into its trailing pass — and\n * must not trigger the fallback, or a burst of gk writes would coarse-clear on every one, which is exactly\n * the churn the key-aware reconcile replaced.\n */\nexport type GkReconcileOutcome = 'reconciled' | 'deferred' | 'failed';\n\nexport type ConflictDetectionCacheKey =\n\t| `apply:${string}:${string}:${string}`\n\t| `merge:${string}:${string}`\n\t| `reapply:${string}:${string}`;\n\n/**\n * Ceiling on how long a derived branch base is trusted. Long enough that repeated reads during normal use\n * are served from cache, short enough that a base that changed by a route with no eviction signal (an\n * external delete-and-recreate of a branch that is never checked out) self-heals without a reload.\n */\nconst baseBranchNameTTL = 5 * 60 * 1000; // 5 minutes\n\n/**\n * Completed blame graphs retain several objects and substrings per line. Keep normal files hot, but let large\n * documents be owned by their active tracked-document snapshot instead of retaining a second long-lived owner.\n */\nconst maxCachedBlameLines = 5000;\n\nexport async function shouldEvictBlameCacheEntry(progressive: ProgressiveGitBlame | undefined): Promise<boolean> {\n\tif (progressive == null) return false;\n\n\ttry {\n\t\tconst blame = await progressive.completed;\n\t\treturn blame.lines.length > maxCachedBlameLines;\n\t} catch {\n\t\t// The provider factory resolves as soon as streaming starts, so a later stream failure must also be retried.\n\t\treturn true;\n\t}\n}\n\n/**\n * gkConfig keys that participate in the `branchOverviews` cache's mergeTarget/mergeBase lineage.\n * Capture group 1 is the ref name (which may itself contain `.`/`/`).\n */\nconst branchOverviewGkConfigKeysRegex = /^branch\\.(.+)\\.(?:gk-merge-(?:base|target(?:-user)?)|gk-target-base)$/;\n\n/**\n * Downstream caches that `deleteGkConfig` may invalidate when a `branch.<ref>.gk-...` key changes.\n * Callers performing a \"self-write\" (where the value being written matches what they just resolved,\n * so the about-to-be-evicted entry is exactly the entry they want to preserve) can opt out by\n * naming the targets to skip via `skipInvalidation`.\n */\nexport type GkConfigInvalidationTarget = 'branchOverviews' | 'baseBranchName';\n\n/** Per-worktree caches — cleared by repoPath directly */\ninterface Caches {\n\tbestRemotes: PromiseMap<RepoPath, GitRemote<RemoteProvider>[]> | undefined;\n\tblame: RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined> | undefined;\n\tbranch: PromiseMap<RepoPath, GitBranch | undefined> | undefined;\n\tcommit: RepoPromiseCacheMap<string, GitCommit | undefined> | undefined;\n\tcommitCount: RepoPromiseCacheMap<string, number | undefined> | undefined;\n\tconflictDetection: RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult> | undefined;\n\tcurrentBranchReference: PromiseCache<RepoPath, GitBranchReference | undefined> | undefined;\n\tcurrentUser: Map<RepoPath, GitUser | null> | undefined;\n\tdiff: RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined> | undefined;\n\tfileExistence: RepoPromiseCacheMap<string, boolean> | undefined;\n\tfileLog: RepoPromiseCacheMap<string, GitLog | undefined> | undefined;\n\tgitDir: Map<RepoPath, GitDir> | undefined;\n\tgitIgnore: Map<RepoPath, GitIgnoreFilter> | undefined;\n\tignoreRevsFile: PromiseCache<string, boolean> | undefined;\n\tleftRightCommitCount: RepoPromiseCacheMap<string, LeftRightCommitCountResult | undefined> | undefined;\n\tmergeBase: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tpatchIds: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tpausedOperationStatus: PromiseMap<RepoPath, GitPausedOperationStatus | undefined> | undefined;\n\treachability: RepoPromiseCacheMap<string, GitCommitReachability | undefined> | undefined;\n\tresolvedRevisions: RepoPromiseCacheMap<string, ResolvedRevision> | undefined;\n\ttrackedPaths: RepoPromiseCacheMap<string, [string, string] | false> | undefined;\n}\n\n/** Shared caches — cleared via commonPath + all worktree paths */\ninterface SharedCaches {\n\tbaseBranchName: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tbranchMergedStatus: RepoPromiseCacheMap<string, GitBranchMergedStatus> | undefined;\n\tbranchMetadataMap: PromiseMap<RepoPath, Map<string, BranchMetadata>> | undefined;\n\tbranchOverviews: RepoPromiseCacheMap<string, BranchContributionsOverview | undefined> | undefined;\n\tbranches: PromiseMap<RepoPath, PagedResult<GitBranch>> | undefined;\n\tconfigKeys: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tconfigPatterns: RepoPromiseCacheMap<string, Map<string, string>> | undefined;\n\tcontributors: RepoPromiseCacheMap<string, GitContributorsResult> | undefined;\n\tcontributorsLite: RepoPromiseCacheMap<string, GitContributor[]> | undefined;\n\tcontributorsStats: RepoPromiseCacheMap<string, GitContributorsStats | undefined> | undefined;\n\tdefaultBranchName: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\t/** The empty tree's id — a property of the repository's object format, which never changes for its lifetime. */\n\temptyTreeSha: PromiseMap<RepoPath, string> | undefined;\n\tgitResults: RepoPromiseCacheMap<string, GitResult> | undefined;\n\tgkConfigMap: PromiseMap<RepoPath, Map<string, string>> | undefined;\n\tinitialCommitSha: PromiseMap<RepoPath, string | undefined> | undefined;\n\t/** Keyed by commonPath — `FETCH_HEAD` lives in the common git dir, shared across worktrees. */\n\tlastFetched: PromiseCache<RepoPath, number | undefined> | undefined;\n\tlogShas: RepoPromiseCacheMap<string, string[]> | undefined;\n\trefs: PromiseMap<RepoPath, RefRecord[]> | undefined;\n\trefTips: PromiseMap<RepoPath, GitRefTip[]> | undefined;\n\tremotes: PromiseMap<RepoPath, GitRemote[]> | undefined;\n\tsharedBranches: PromiseMap<RepoPath, PagedResult<GitBranch>> | undefined;\n\tstashes: RepoPromiseCacheMap<string, GitStash> | undefined;\n\ttags: PromiseMap<RepoPath, PagedResult<GitTag>> | undefined;\n\tworktrees: PromiseMap<RepoPath, GitWorktree[]> | undefined;\n}\n\ntype AllCaches = Caches & SharedCaches;\n\n/** Compile-time enforced: adding a key to SharedCaches without listing it here is a type error */\nconst sharedCacheKeys: ReadonlySet<keyof AllCaches> = new Set(\n\texhaustiveArray<keyof SharedCaches>()([\n\t\t'baseBranchName',\n\t\t'branchMergedStatus',\n\t\t'branchMetadataMap',\n\t\t'branchOverviews',\n\t\t'branches',\n\t\t'configKeys',\n\t\t'configPatterns',\n\t\t'contributors',\n\t\t'contributorsLite',\n\t\t'contributorsStats',\n\t\t'defaultBranchName',\n\t\t'emptyTreeSha',\n\t\t'gitResults',\n\t\t'gkConfigMap',\n\t\t'initialCommitSha',\n\t\t'lastFetched',\n\t\t'logShas',\n\t\t'refs',\n\t\t'refTips',\n\t\t'remotes',\n\t\t'sharedBranches',\n\t\t'stashes',\n\t\t'tags',\n\t\t'worktrees',\n\t]),\n);\n\nfunction createEmptyCaches(): AllCaches {\n\treturn {\n\t\tbaseBranchName: undefined,\n\t\tbestRemotes: undefined,\n\t\tblame: undefined,\n\t\tbranch: undefined,\n\t\tbranchMergedStatus: undefined,\n\t\tbranchMetadataMap: undefined,\n\t\tbranchOverviews: undefined,\n\t\tbranches: undefined,\n\t\tcommit: undefined,\n\t\tcommitCount: undefined,\n\t\tfileExistence: undefined,\n\t\tignoreRevsFile: undefined,\n\t\tleftRightCommitCount: undefined,\n\t\tmergeBase: undefined,\n\t\tpatchIds: undefined,\n\t\tconfigKeys: undefined,\n\t\tconfigPatterns: undefined,\n\t\tconflictDetection: undefined,\n\t\tdiff: undefined,\n\t\tfileLog: undefined,\n\t\tcontributors: undefined,\n\t\tcontributorsLite: undefined,\n\t\tcontributorsStats: undefined,\n\t\tcurrentBranchReference: undefined,\n\t\tcurrentUser: undefined,\n\t\tdefaultBranchName: undefined,\n\t\temptyTreeSha: undefined,\n\t\tgitDir: undefined,\n\t\tgitIgnore: undefined,\n\t\tgitResults: undefined,\n\t\tgkConfigMap: undefined,\n\t\tinitialCommitSha: undefined,\n\t\tlastFetched: undefined,\n\t\tlogShas: undefined,\n\t\tpausedOperationStatus: undefined,\n\t\tresolvedRevisions: undefined,\n\t\treachability: undefined,\n\t\trefs: undefined,\n\t\trefTips: undefined,\n\t\tremotes: undefined,\n\t\tsharedBranches: undefined,\n\t\tstashes: undefined,\n\t\ttags: undefined,\n\t\ttrackedPaths: undefined,\n\t\tworktrees: undefined,\n\t};\n}\n\nexport class Cache implements Disposable {\n\tprivate _caches: AllCaches = createEmptyCaches();\n\tprivate _commonPathRegistry = new Map<RepoPath, string>();\n\t/** Reverse index: commonPath → set of worktree repoPaths that share it */\n\tprivate _worktreesByCommonPath = new Map<string, Set<RepoPath>>();\n\t/** Monotonic per-worktree \"status clock\" — see {@link getStatusGeneration}. */\n\tprivate _statusGenerations = new Map<RepoPath, number>();\n\t/** Monotonic per-path \"close clock\" — see {@link getCloseGeneration}. */\n\tprivate _closeGenerations = new Map<RepoPath, number>();\n\n\t/**\n\t * Per-commonPath snapshot of the merge-relevant subset of `.git/gk/config` (keys matching\n\t * {@link branchOverviewGkConfigKeysRegex}), used by {@link reconcileGkConfigMap} to diff a watcher\n\t * `'gkConfig'` event down to only the keys that actually changed, instead of coarsely re-deriving\n\t * `baseBranchName`/`branchOverviews` on every gk write. Absent means \"never observed\".\n\t */\n\tprivate _gkConfigMergeSnapshots = new Map<string, Map<string, string>>();\n\n\t/**\n\t * Reconciler registered by the CLI config sub-provider (see {@link setGkConfigReconciler}),\n\t * invoked on a watcher-observed `'gkConfig'` change instead of the coarse `clearCaches(repoPath,\n\t * 'gkConfig')` cascade. `undefined` (e.g. the GitHub provider, which has no `.git/gk/config`)\n\t * falls back to the coarse clear.\n\t */\n\tprivate _gkConfigReconciler:\n\t\t| ((\n\t\t\t\trepoPath: string,\n\t\t\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\t ) => PromiseOrValue<GkReconcileOutcome>)\n\t\t| undefined;\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tthis.reset();\n\t}\n\n\t/** Resource usage retained by instantiated sub-caches and their bookkeeping maps. */\n\tgetResourceUsage(): ResourceUsage {\n\t\tconst usage: ResourceUsage = {};\n\t\tfor (const [name, cache] of Object.entries(this._caches)) {\n\t\t\tif (cache != null) {\n\t\t\t\tusage[`cache.${name}.entries.count`] =\n\t\t\t\t\tcache instanceof RepoPromiseCacheMap ? cache.entryCount : cache.size;\n\t\t\t}\n\t\t}\n\t\tusage['cache.commonPathRegistry.entries.count'] = this._commonPathRegistry.size;\n\t\tusage['cache.worktreesByCommonPath.entries.count'] = this._worktreesByCommonPath.size;\n\t\tusage['cache.statusGenerations.entries.count'] = this._statusGenerations.size;\n\t\tusage['cache.closeGenerations.entries.count'] = this._closeGenerations.size;\n\t\tusage['cache.gkConfigMergeSnapshots.entries.count'] = this._gkConfigMergeSnapshots.size;\n\t\treturn usage;\n\t}\n\n\tget bestRemotes(): PromiseMap<RepoPath, GitRemote<RemoteProvider>[]> {\n\t\treturn (this._caches.bestRemotes ??= new PromiseMap<RepoPath, GitRemote<RemoteProvider>[]>());\n\t}\n\n\tget blame(): RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined> {\n\t\treturn (this._caches.blame ??= new RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined>({\n\t\t\tcreateTTL: 1000 * 60 * 10, // 10 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tget diff(): RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined> {\n\t\treturn (this._caches.diff ??= new RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined>({\n\t\t\tcreateTTL: 1000 * 60 * 10, // 10 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tget fileLog(): RepoPromiseCacheMap<string, GitLog | undefined> {\n\t\treturn (this._caches.fileLog ??= new RepoPromiseCacheMap<string, GitLog | undefined>({\n\t\t\tcreateTTL: 1000 * 60 * 10, // 10 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tprivate get baseBranchName(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.baseBranchName ??= new RepoPromiseCacheMap<string, string | undefined>());\n\t}\n\n\tget branch(): PromiseMap<RepoPath, GitBranch | undefined> {\n\t\treturn (this._caches.branch ??= new PromiseMap<RepoPath, GitBranch | undefined>());\n\t}\n\n\tget branchMergedStatus(): RepoPromiseCacheMap<string, GitBranchMergedStatus> {\n\t\treturn (this._caches.branchMergedStatus ??= new RepoPromiseCacheMap<string, GitBranchMergedStatus>({\n\t\t\tcreateTTL: 1000 * 60 * 30, // 30 minutes — content-keyed on tip shas, so this is just a backstop\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 100, // Limit to 100 branch-pairs per repo\n\t\t}));\n\t}\n\n\tprivate get branchMetadataMap(): PromiseMap<RepoPath, Map<string, BranchMetadata>> {\n\t\treturn (this._caches.branchMetadataMap ??= new PromiseMap<RepoPath, Map<string, BranchMetadata>>());\n\t}\n\n\tprivate get branchOverviews(): RepoPromiseCacheMap<string, BranchContributionsOverview | undefined> {\n\t\treturn (this._caches.branchOverviews ??= new RepoPromiseCacheMap<\n\t\t\tstring,\n\t\t\tBranchContributionsOverview | undefined\n\t\t>(\n\t\t\t{ accessTTL: 1000 * 60 * 60 }, // 60 minutes\n\t\t));\n\t}\n\n\tget branches(): PromiseMap<RepoPath, PagedResult<GitBranch>> {\n\t\treturn (this._caches.branches ??= new PromiseMap<RepoPath, PagedResult<GitBranch>>());\n\t}\n\n\t/**\n\t * Internal cache for raw shared branch data (keyed by commonPath)\n\t * Separate from branches cache because branches need to be mapped for each worktree\n\t */\n\tprivate get sharedBranches(): PromiseMap<RepoPath, PagedResult<GitBranch>> {\n\t\treturn (this._caches.sharedBranches ??= new PromiseMap<RepoPath, PagedResult<GitBranch>>());\n\t}\n\n\tprivate get configKeys(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.configKeys ??= new RepoPromiseCacheMap<string, string | undefined>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds - ensures global config changes are picked up\n\t\t}));\n\t}\n\n\tprivate get configPatterns(): RepoPromiseCacheMap<string, Map<string, string>> {\n\t\treturn (this._caches.configPatterns ??= new RepoPromiseCacheMap<string, Map<string, string>>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds - ensures global config changes are picked up\n\t\t}));\n\t}\n\n\tprivate get gkConfigMap(): PromiseMap<RepoPath, Map<string, string>> {\n\t\treturn (this._caches.gkConfigMap ??= new PromiseMap<RepoPath, Map<string, string>>());\n\t}\n\n\tget currentBranchReference(): PromiseCache<RepoPath, GitBranchReference | undefined> {\n\t\treturn (this._caches.currentBranchReference ??= new PromiseCache<RepoPath, GitBranchReference | undefined>());\n\t}\n\n\tsetCurrentBranchReferenceIfAbsent(worktreePath: string, reference: GitBranchReference | undefined): void {\n\t\tif (this.currentBranchReference.get(worktreePath) == null) {\n\t\t\tthis.currentBranchReference.set(worktreePath, Promise.resolve(reference));\n\t\t}\n\t}\n\n\tget conflictDetection(): RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult> {\n\t\treturn (this._caches.conflictDetection ??= new RepoPromiseCacheMap<\n\t\t\tConflictDetectionCacheKey,\n\t\t\tConflictDetectionResult\n\t\t>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds\n\t\t}));\n\t}\n\n\tget contributors(): RepoPromiseCacheMap<string, GitContributorsResult> {\n\t\treturn (this._caches.contributors ??= new RepoPromiseCacheMap<string, GitContributorsResult>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget contributorsLite(): RepoPromiseCacheMap<string, GitContributor[]> {\n\t\treturn (this._caches.contributorsLite ??= new RepoPromiseCacheMap<string, GitContributor[]>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget contributorsStats(): RepoPromiseCacheMap<string, GitContributorsStats | undefined> {\n\t\treturn (this._caches.contributorsStats ??= new RepoPromiseCacheMap<string, GitContributorsStats | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget currentUser(): Map<RepoPath, GitUser | null> {\n\t\treturn (this._caches.currentUser ??= new Map<RepoPath, GitUser | null>());\n\t}\n\n\tget defaultBranchName(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.defaultBranchName ??= new RepoPromiseCacheMap<string, string | undefined>());\n\t}\n\n\tget emptyTreeSha(): PromiseMap<RepoPath, string> {\n\t\treturn (this._caches.emptyTreeSha ??= new PromiseMap<RepoPath, string>());\n\t}\n\n\tget gitDir(): Map<RepoPath, GitDir> {\n\t\treturn (this._caches.gitDir ??= new Map<RepoPath, GitDir>());\n\t}\n\n\tget gitIgnore(): Map<RepoPath, GitIgnoreFilter> {\n\t\treturn (this._caches.gitIgnore ??= new Map<RepoPath, GitIgnoreFilter>());\n\t}\n\n\tget gitResults(): RepoPromiseCacheMap<RepoPath, GitResult> {\n\t\treturn (this._caches.gitResults ??= new RepoPromiseCacheMap<RepoPath, GitResult>({ capacity: 200 }));\n\t}\n\n\tget initialCommitSha(): PromiseMap<RepoPath, string | undefined> {\n\t\treturn (this._caches.initialCommitSha ??= new PromiseMap<RepoPath, string | undefined>());\n\t}\n\n\tget lastFetched(): PromiseCache<RepoPath, number | undefined> {\n\t\treturn (this._caches.lastFetched ??= new PromiseCache<RepoPath, number | undefined>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds\n\t\t}));\n\t}\n\n\tget leftRightCommitCount(): RepoPromiseCacheMap<string, LeftRightCommitCountResult | undefined> {\n\t\treturn (this._caches.leftRightCommitCount ??= new RepoPromiseCacheMap<\n\t\t\tstring,\n\t\t\tLeftRightCommitCountResult | undefined\n\t\t>({\n\t\t\tcreateTTL: 1000 * 60 * 5, // 5 minutes max age — invalidated sooner on branch/remote changes\n\t\t\tcapacity: 50, // Limit to 50 ref-pairs per repo\n\t\t}));\n\t}\n\n\tget commit(): RepoPromiseCacheMap<string, GitCommit | undefined> {\n\t\treturn (this._caches.commit ??= new RepoPromiseCacheMap<string, GitCommit | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 100, // Limit to 100 commits per repo\n\t\t}));\n\t}\n\n\tget commitCount(): RepoPromiseCacheMap<string, number | undefined> {\n\t\treturn (this._caches.commitCount ??= new RepoPromiseCacheMap<string, number | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tget mergeBase(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.mergeBase ??= new RepoPromiseCacheMap<string, string | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\t/**\n\t * Patch IDs keyed by full commit sha (plus `paths` and `verbatim`). A commit's content is immutable, so no\n\t * ref or worktree event can make an entry stale and nothing clears it short of a full cache reset. A cached\n\t * `undefined` is a real answer (a merge commit, or a change that is empty after `paths`). Kept per worktree,\n\t * not per repository, since an ID depends on the attributes of the checkout it was read from. Sized above a range\n\t * read of a couple thousand commits, so one read doesn't evict its own ids before the next.\n\t */\n\tget patchIds(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.patchIds ??= new RepoPromiseCacheMap<string, string | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 5000,\n\t\t}));\n\t}\n\n\tget logShas(): RepoPromiseCacheMap<string, string[]> {\n\t\treturn (this._caches.logShas ??= new RepoPromiseCacheMap<string, string[]>({\n\t\t\tcreateTTL: 1000 * 60 * 5, // 5 minutes max age\n\t\t\taccessTTL: 1000 * 30, // 30 seconds if not accessed\n\t\t\tcapacity: 5, // Limit to 5 different ranges per repo\n\t\t}));\n\t}\n\n\tget pausedOperationStatus(): PromiseMap<RepoPath, GitPausedOperationStatus | undefined> {\n\t\treturn (this._caches.pausedOperationStatus ??= new PromiseMap<\n\t\t\tRepoPath,\n\t\t\tGitPausedOperationStatus | undefined\n\t\t>());\n\t}\n\n\tget resolvedRevisions(): RepoPromiseCacheMap<string, ResolvedRevision> {\n\t\treturn (this._caches.resolvedRevisions ??= new RepoPromiseCacheMap<string, ResolvedRevision>({\n\t\t\tcapacity: 100,\n\t\t}));\n\t}\n\n\tget refs(): PromiseMap<RepoPath, RefRecord[]> {\n\t\treturn (this._caches.refs ??= new PromiseMap<RepoPath, RefRecord[]>());\n\t}\n\n\tget refTips(): PromiseMap<RepoPath, GitRefTip[]> {\n\t\treturn (this._caches.refTips ??= new PromiseMap<RepoPath, GitRefTip[]>());\n\t}\n\n\tget reachability(): RepoPromiseCacheMap<string, GitCommitReachability | undefined> {\n\t\treturn (this._caches.reachability ??= new RepoPromiseCacheMap<string, GitCommitReachability | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 25, // Limit to 25 commits per repo\n\t\t}));\n\t}\n\n\tget remotes(): PromiseMap<RepoPath, GitRemote[]> {\n\t\treturn (this._caches.remotes ??= new PromiseMap<RepoPath, GitRemote[]>());\n\t}\n\n\tget stashes(): RepoPromiseCacheMap<string, GitStash> {\n\t\treturn (this._caches.stashes ??= new RepoPromiseCacheMap<string, GitStash>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget tags(): PromiseMap<RepoPath, PagedResult<GitTag>> {\n\t\treturn (this._caches.tags ??= new PromiseMap<RepoPath, PagedResult<GitTag>>());\n\t}\n\n\tget fileExistence(): RepoPromiseCacheMap<string, boolean> {\n\t\treturn (this._caches.fileExistence ??= new RepoPromiseCacheMap<string, boolean>({\n\t\t\tcreateTTL: 1000 * 10, // 10 seconds\n\t\t\tcapacity: 100,\n\t\t\texpireOnError: true,\n\t\t}));\n\t}\n\n\t// Key: repoPath (not the ignoreRevsFile path) so that per-repo cache resets (clearCaches with repoPath)\n\t// correctly evict the entry. The actual file path is used inside the factory closure in blame.ts.\n\tget ignoreRevsFile(): PromiseCache<string, boolean> {\n\t\treturn (this._caches.ignoreRevsFile ??= new PromiseCache<string, boolean>({\n\t\t\taccessTTL: 1000 * 60 * 60 * 2, // 2 hours\n\t\t\texpireOnError: true,\n\t\t}));\n\t}\n\n\tget trackedPaths(): RepoPromiseCacheMap<string, [string, string] | false> {\n\t\treturn (this._caches.trackedPaths ??= new RepoPromiseCacheMap<string, [string, string] | false>({\n\t\t\tcreateTTL: 1000 * 60, // 60 seconds\n\t\t\taccessTTL: 1000 * 30, // 30 seconds idle\n\t\t\tcapacity: 200,\n\t\t}));\n\t}\n\n\tget worktrees(): PromiseMap<RepoPath, GitWorktree[]> {\n\t\treturn (this._caches.worktrees ??= new PromiseMap<RepoPath, GitWorktree[]>());\n\t}\n\n\t@debug({ onlyExit: true })\n\tclearCaches(repoPath: string | undefined, ...types: CachedGitTypes[]): void {\n\t\tthis.clearCachesCore('share', repoPath, ...types);\n\t}\n\n\t/**\n\t * Hard-evicts the same cache keys {@link clearCaches} would clear for `repoPath`, but a shared\n\t * (commonPath-keyed) entry that is still in flight is deleted outright instead of soft-invalidated —\n\t * a caller after this call never joins a read that started before it. Use for a forced read/write\n\t * that must not be answered from pre-change work; `clearCaches` remains the right call whenever\n\t * letting an in-flight read complete and share its answer with new callers is fine.\n\t */\n\tevictCaches(repoPath: string, ...types: CachedGitTypes[]): void {\n\t\tthis.clearCachesCore('evict', repoPath, ...types);\n\t}\n\n\tprivate clearCachesCore(\n\t\tinFlight: 'share' | 'evict',\n\t\trepoPath: string | undefined,\n\t\t...types: CachedGitTypes[]\n\t): void {\n\t\tconst keysToClear = new Set<keyof AllCaches>();\n\n\t\tif (!types.length) {\n\t\t\t// Clear all caches\n\t\t\tfor (const key of Object.keys(this._caches)) {\n\t\t\t\tkeysToClear.add(key as keyof AllCaches);\n\t\t\t}\n\n\t\t\tinvalidateMemoized('providers');\n\t\t\tthis.incrementStatusGenerations(repoPath);\n\t\t} else {\n\t\t\t// Clear specific cache types\n\t\t\tif (types.includes('blame')) {\n\t\t\t\tkeysToClear.add('blame');\n\t\t\t}\n\t\t\tif (types.includes('diff')) {\n\t\t\t\tkeysToClear.add('diff');\n\t\t\t}\n\t\t\tif (types.includes('fileLog')) {\n\t\t\t\tkeysToClear.add('fileLog');\n\t\t\t}\n\n\t\t\t// Branch caches affected by HEAD/heads changes. `branchMergedStatus` is deliberately NOT\n\t\t\t// cleared here — it's content-keyed on the involved tip shas, so tip movement already\n\t\t\t// self-invalidates (a new key); evicting it here would only discard still-valid answers.\n\t\t\tif (types.includes('branch') || types.includes('branches')) {\n\t\t\t\tkeysToClear.add('branch');\n\t\t\t\tkeysToClear.add('branchOverviews');\n\t\t\t\t// `commit`/`commitCount` are keyed by symbolic ref or SHA — symbolic-ref entries\n\t\t\t\t// can drift when branches move; cascade-clear conservatively.\n\t\t\t\tkeysToClear.add('commit');\n\t\t\t\tkeysToClear.add('commitCount');\n\t\t\t\tkeysToClear.add('conflictDetection');\n\t\t\t\tkeysToClear.add('currentBranchReference');\n\t\t\t\tkeysToClear.add('leftRightCommitCount');\n\t\t\t\t// `mergeBase` keyed by ref-pairs — symbolic refs can move; cascade-clear.\n\t\t\t\tkeysToClear.add('mergeBase');\n\t\t\t\tkeysToClear.add('reachability');\n\t\t\t\tkeysToClear.add('resolvedRevisions');\n\t\t\t}\n\n\t\t\t// Shared branch caches (branch list, metadata). `baseBranchName` is deliberately NOT cleared\n\t\t\t// here — a branch's base is set at creation and only changes when its stored key changes\n\t\t\t// (`gkConfig`/`config` below) or the branch itself is created/renamed/deleted. Every op that\n\t\t\t// does one of those calls `deleteBaseBranchName` and moves or drops the branch's persisted\n\t\t\t// `branch.<ref>.gk-*` keys: `createBranch`/`deleteLocalBranch`/`renameBranch`, plus the two\n\t\t\t// paths that create a branch as a side effect (`checkout -b`, `worktree add -b`). Tip movement\n\t\t\t// can't change a base, so clearing on every commit only forced a `git reflog` re-derivation.\n\t\t\tif (types.includes('branch')) {\n\t\t\t\t// `'branch'` comes from a HEAD change — a checkout — which appends `checkout: moving from X\n\t\t\t\t// to Y` to the reflog, exactly the entry `getBaseBranchName` greps for when nothing is\n\t\t\t\t// stored. A base derived as \"none\" BEFORE that entry existed is cached with no TTL, so\n\t\t\t\t// without this it stays \"none\" for the session even though the answer now exists.\n\t\t\t\t//\n\t\t\t\t// Deliberately not under `'branches'`: a tip move can't change a branch's base, so re-deriving\n\t\t\t\t// on every commit would be pure cost. Checkouts are user-driven and rare by comparison.\n\t\t\t\tkeysToClear.add('baseBranchName');\n\t\t\t}\n\n\t\t\tif (types.includes('branches')) {\n\t\t\t\tkeysToClear.add('branchMetadataMap');\n\t\t\t\tkeysToClear.add('branches');\n\t\t\t\tkeysToClear.add('sharedBranches');\n\t\t\t\tkeysToClear.add('defaultBranchName');\n\t\t\t\tkeysToClear.add('initialCommitSha');\n\t\t\t\tkeysToClear.add('logShas');\n\t\t\t\tkeysToClear.add('refs');\n\t\t\t\tkeysToClear.add('refTips');\n\t\t\t\t// No change type clears `emptyTreeSha`: a repository's object format never changes. A full reset\n\t\t\t\t// (no types) still clears it, along with everything else\n\t\t\t}\n\n\t\t\tif (types.includes('config')) {\n\t\t\t\t// `getBaseBranchName` falls back to `branch.<ref>.vscode-merge-base` (written by VS Code's\n\t\t\t\t// built-in Git), which lives in `.git/config` — so a config change is the only signal that\n\t\t\t\t// source changed. Cheap: config events are rare.\n\t\t\t\tkeysToClear.add('baseBranchName');\n\t\t\t\tkeysToClear.add('configKeys');\n\t\t\t\tkeysToClear.add('configPatterns');\n\t\t\t\tkeysToClear.add('currentBranchReference');\n\t\t\t\tkeysToClear.add('currentUser');\n\t\t\t\t// `gitDir` is immutable repo topology (toplevel/git-dir/common-dir/superproject) — a\n\t\t\t\t// `.git/config` content change never relocates it, and it's owned by the repo lifecycle\n\t\t\t\t// (registerRepoPath/unregisterRepoPath). Clearing it here forced a redundant `git rev-parse`\n\t\t\t\t// re-spawn (gitDir is read by getGkConfigPath→getGitDir on every gk op), so leave it warm.\n\t\t\t}\n\n\t\t\tif (types.includes('contributors')) {\n\t\t\t\tkeysToClear.add('branchOverviews');\n\t\t\t\tkeysToClear.add('contributors');\n\t\t\t\tkeysToClear.add('contributorsLite');\n\t\t\t\tkeysToClear.add('contributorsStats');\n\t\t\t}\n\n\t\t\tif (types.includes('gitignore')) {\n\t\t\t\tkeysToClear.add('gitIgnore');\n\t\t\t}\n\n\t\t\tif (types.includes('gkConfig')) {\n\t\t\t\tkeysToClear.add('gkConfigMap');\n\t\t\t\t// Derived from `branch.<ref>.gk-merge-base`/`vscode-merge-base`; clear so external\n\t\t\t\t// gkConfig mutations don't leave stale base-branch resolutions cached.\n\t\t\t\tkeysToClear.add('baseBranchName');\n\t\t\t\t// Cached overviews are keyed by `${ref}|${mergeTarget}`; bulk gkConfig changes can\n\t\t\t\t// affect any of the merge-target sources (stored, base, default), so clear all.\n\t\t\t\tkeysToClear.add('branchOverviews');\n\t\t\t}\n\n\t\t\tif (types.includes('lastFetched')) {\n\t\t\t\tkeysToClear.add('lastFetched');\n\t\t\t}\n\n\t\t\tif (types.includes('providers')) {\n\t\t\t\tkeysToClear.add('remotes');\n\t\t\t\tkeysToClear.add('bestRemotes');\n\t\t\t\tinvalidateMemoized('providers');\n\t\t\t}\n\n\t\t\tif (types.includes('remotes')) {\n\t\t\t\tkeysToClear.add('remotes');\n\t\t\t\tkeysToClear.add('bestRemotes');\n\t\t\t\tkeysToClear.add('defaultBranchName');\n\t\t\t}\n\n\t\t\tif (types.includes('stashes')) {\n\t\t\t\tkeysToClear.add('stashes');\n\t\t\t}\n\t\t\tif (types.includes('status')) {\n\t\t\t\tkeysToClear.add('pausedOperationStatus');\n\t\t\t\t// A caller asserting \"status changed\" (the post-op hooks in `operations.ts`, a user-initiated\n\t\t\t\t// refresh) has to advance the clock too — otherwise a `git status` still in flight from before\n\t\t\t\t// the operation can satisfy the read that follows it.\n\t\t\t\tthis.incrementStatusGenerations(repoPath);\n\t\t\t}\n\t\t\tif (types.includes('tags')) {\n\t\t\t\tkeysToClear.add('tags');\n\t\t\t\tkeysToClear.add('refs');\n\t\t\t\tkeysToClear.add('refTips');\n\t\t\t\t// `commit`/`commitCount` can be keyed by a tag name (e.g. the tag node's load-more count),\n\t\t\t\t// which re-points on a force-moved or deleted-and-recreated tag — same drift the\n\t\t\t\t// `branch`/`branches` cascade above clears for.\n\t\t\t\tkeysToClear.add('commit');\n\t\t\t\tkeysToClear.add('commitCount');\n\t\t\t\t// Same drift for a tag-named rev, and a `getLogShas` excluding tags lists different commits once a tag moves\n\t\t\t\tkeysToClear.add('logShas');\n\t\t\t\t// Keyed by the revision as given, so a tag name resolves to wherever the tag pointed when first read\n\t\t\t\tkeysToClear.add('resolvedRevisions');\n\t\t\t}\n\n\t\t\tif (types.includes('tracking')) {\n\t\t\t\tkeysToClear.add('fileExistence');\n\t\t\t\tkeysToClear.add('trackedPaths');\n\t\t\t}\n\n\t\t\tif (types.includes('worktrees')) {\n\t\t\t\tkeysToClear.add('worktrees');\n\t\t\t}\n\n\t\t\t// Git results: cleared for any meaningful type change\n\t\t\tif (types.some(t => t !== 'gitignore' && t !== 'gkConfig' && t !== 'providers')) {\n\t\t\t\tkeysToClear.add('gitResults');\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of keysToClear) {\n\t\t\tconst cache = this._caches[key];\n\t\t\tif (cache == null) continue;\n\n\t\t\tif (repoPath == null) {\n\t\t\t\tcache.clear();\n\t\t\t} else if (sharedCacheKeys.has(key)) {\n\t\t\t\tthis.evictShared(key, repoPath, inFlight);\n\t\t\t} else {\n\t\t\t\tcache.delete(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Evicts a single shared (commonPath-keyed) cache entry for `repoPath` and its sibling worktrees.\n\t * When `inFlight` is `'share'` (the default), prefers `invalidate` where supported so in-flight work\n\t * is shared across new callers and self-evicts on settle rather than spawning a duplicate factory.\n\t * `invalidate` does the right thing per-entry: entries with a `CacheController` (created via\n\t * `getOrCreate`) are marked invalidated; entries without one (created via plain `.set()`, e.g.\n\t * per-worktree mapper results) are hard-deleted. Caches that don't support `invalidate` fall back to\n\t * `delete`.\n\t *\n\t * When `inFlight` is `'evict'`, always hard-deletes regardless of `invalidate` support — a new caller\n\t * must never join a read that started before this eviction (see {@link evictCaches}).\n\t */\n\tprivate evictShared(key: keyof AllCaches, repoPath: string, inFlight: 'share' | 'evict' = 'share'): void {\n\t\tconst cache = this._caches[key];\n\t\tif (cache == null) return;\n\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst invalidate =\n\t\t\tinFlight === 'share' ? (cache as { invalidate?: (k: string) => void }).invalidate : undefined;\n\t\tif (typeof invalidate === 'function') {\n\t\t\tinvalidate.call(cache, commonPath);\n\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\tinvalidate.call(cache, worktreePath);\n\t\t\t}\n\t\t} else {\n\t\t\tcache.delete(commonPath);\n\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\tcache.delete(worktreePath);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Monotonic per-worktree counter, advanced whenever anything that can change `git status` output is\n\t * observed. `git status` and its siblings are point-in-time reads of mutable state, so deduplicating them\n\t * on repoPath alone is unsound — a run that started before a commit would satisfy a caller that arrived\n\t * after it. Callers stamp their in-flight run with the generation it started in and refuse older joins.\n\t * Kept per exact worktree path (never spread to the common path) and advanced on `unregisterRepoPath` so a\n\t * read in flight from a prior registration can't be joined after a reopen.\n\t *\n\t * Note: a run that never settles wedges only its own generation's callers (a newer generation gets a fresh\n\t * key). `git.run` recovers via its per-command timeout (default 60s); a hung `git.stream` is caught by the\n\t * status provider's `raceWithTimeout` backstop (scaled to `advanced.git.timeout`; see\n\t * `dedupeByStatusGeneration`), which rejects a wedged read so waiters unblock and a later caller retries.\n\t */\n\tgetStatusGeneration(repoPath: string): number {\n\t\treturn this._statusGenerations.get(repoPath) ?? 0;\n\t}\n\n\t/** Advances the status clock — see {@link getStatusGeneration}. */\n\tincrementStatusGeneration(repoPath: string): void {\n\t\tthis._statusGenerations.set(repoPath, this.getStatusGeneration(repoPath) + 1);\n\t}\n\n\t/**\n\t * Working-tree changes ride their own channel (`Repository.onDidChangeWorkingTree`), not\n\t * `onRepositoryChanged` — an external `git restore <file>` may touch no `.git` path we classify — so\n\t * they have to advance the status clock separately or a discard would never invalidate an in-flight read.\n\t */\n\tonWorkingTreeChanged(repoPath: string): void {\n\t\tthis.incrementStatusGeneration(repoPath);\n\t}\n\n\t/** Advances the status clock for one worktree, or for every known worktree when `repoPath` is undefined. */\n\tprivate incrementStatusGenerations(repoPath: string | undefined): void {\n\t\tif (repoPath != null) {\n\t\t\tthis.incrementStatusGeneration(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\t// Union of registered repos and any path that already carries a generation — a secondary-worktree\n\t\t// path incremented via its own watcher may never have been registered, but still has in-flight reads to fence.\n\t\tconst paths = new Set([...this._commonPathRegistry.keys(), ...this._statusGenerations.keys()]);\n\t\tfor (const path of paths) {\n\t\t\tthis.incrementStatusGeneration(path);\n\t\t}\n\t}\n\n\tgetCommonPath(repoPath: string): string {\n\t\treturn this._commonPathRegistry.get(repoPath) ?? repoPath;\n\t}\n\n\tgetWorktreePaths(commonPath: string): string[] {\n\t\tconst worktrees = this._worktreesByCommonPath.get(commonPath);\n\t\treturn worktrees != null ? [...worktrees] : [];\n\t}\n\n\tisWorktree(repoPath: string): boolean {\n\t\tconst commonPath = this._commonPathRegistry.get(repoPath);\n\t\treturn commonPath != null && commonPath !== repoPath;\n\t}\n\n\t/** Whether `repoPath` is currently registered (via {@link registerRepoPath}, not yet unregistered). */\n\tisRegistered(repoPath: string): boolean {\n\t\treturn this._commonPathRegistry.has(repoPath);\n\t}\n\n\t/**\n\t * Monotonic per-path counter advanced whenever `repoPath` is unregistered (repo closed, worktree\n\t * removed). Lets an async post-read step — e.g. the gk-config reconcile — detect that its target was\n\t * closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered` check it doesn't\n\t * require the caller to have registered in the first place, so it stays correct for consumers of\n\t * this package that don't wire up the host's repo lifecycle.\n\t */\n\tgetCloseGeneration(repoPath: string): number {\n\t\treturn this._closeGenerations.get(repoPath) ?? 0;\n\t}\n\n\t/** Clears file-scoped caches (blame, diff, fileLog) for a specific path within a repo */\n\tclearForPath(repoPath: string, path: string, ...types: UriScopedCachedGitTypes[]): void {\n\t\tconst prefix = `${normalizePath(path)}:`;\n\t\tif (!types.length || types.includes('blame')) {\n\t\t\tthis._caches.blame?.deleteByKeyPrefix(repoPath, prefix);\n\t\t}\n\t\tif (!types.length || types.includes('diff')) {\n\t\t\tthis._caches.diff?.deleteByKeyPrefix(repoPath, prefix);\n\t\t}\n\t\tif (!types.length || types.includes('fileLog')) {\n\t\t\tthis._caches.fileLog?.deleteByKeyPrefix(repoPath, prefix);\n\t\t}\n\t}\n\n\tregisterRepoPath(repoPath: Uri, gitDir: GitDir): void {\n\t\tconst normalizedPath = getRepositoryOrWorktreePath(repoPath);\n\t\tconst commonPath = gitDir.commonUri != null ? getCommonRepositoryPath(gitDir.commonUri) : normalizedPath;\n\t\tthis._commonPathRegistry.set(normalizedPath, commonPath);\n\n\t\tlet worktrees = this._worktreesByCommonPath.get(commonPath);\n\t\tif (worktrees == null) {\n\t\t\tworktrees = new Set();\n\t\t\tthis._worktreesByCommonPath.set(commonPath, worktrees);\n\t\t}\n\t\tworktrees.add(normalizedPath);\n\t}\n\n\t/**\n\t * Symmetric companion to `registerRepoPath`. Clears cache entries specific to `repoPath`\n\t * and removes the path from the registry.\n\t *\n\t * Call this when a worktree is deleted or a repo is closed so stale registry entries\n\t * and derived cache entries don't persist.\n\t *\n\t * Targeted — does NOT cascade to sibling worktrees sharing the same commonPath. The\n\t * shared commonPath entry in each shared cache is only evicted when unregistering the\n\t * last remaining worktree for that commonPath (otherwise siblings still depend on it).\n\t *\n\t * Uses soft-invalidate where supported so any in-flight factory/mapper keeps its abort\n\t * wiring intact — a caller whose signal aborts after unregister can still propagate\n\t * cancellation into the underlying work rather than leaving it orphaned. Controller-backed\n\t * entries self-evict on settle; plain `.set()`-based entries hard-delete immediately.\n\t *\n\t * Cache eviction is a no-op if `repoPath` is not registered, but the status clock is advanced\n\t * unconditionally (a fresh registration must not let a post-reopen read join a pre-close one).\n\t */\n\t@debug({ onlyExit: true })\n\tunregisterRepoPath(repoPath: string): void {\n\t\t// Advance the status clock on close so a status read still in flight from this registration can't be\n\t\t// joined by a read issued after the path is reopened (which would otherwise reuse the same generation).\n\t\tthis.incrementStatusGeneration(repoPath);\n\t\t// Advance the close clock so an async step that captured it before its read (see `getCloseGeneration`)\n\t\t// can tell its target went away mid-flight.\n\t\tthis._closeGenerations.set(repoPath, this.getCloseGeneration(repoPath) + 1);\n\n\t\tconst commonPath = this._commonPathRegistry.get(repoPath) ?? repoPath;\n\t\tconst worktrees = this._worktreesByCommonPath.get(commonPath);\n\t\t// After removing repoPath, would the commonPath have any worktrees left?\n\t\tconst isLastWorktree = worktrees == null || worktrees.size <= 1;\n\n\t\t// Targeted per-repoPath cleanup: for per-worktree caches, clear this repoPath's\n\t\t// entries. For shared caches, clear this repoPath's mapper entry (if it's a worktree\n\t\t// distinct from commonPath); only evict the shared commonPath entry when this was the\n\t\t// last worktree — otherwise siblings still rely on the shared data.\n\t\tfor (const key of Object.keys(this._caches) as (keyof AllCaches)[]) {\n\t\t\tconst cache = this._caches[key];\n\t\t\tif (cache == null) continue;\n\n\t\t\t// Prefer `invalidate` so in-flight abort wiring survives until the factory settles;\n\t\t\t// fall back to `delete` for plain `Map`-typed caches that don't track promises.\n\t\t\tconst invalidate = (cache as { invalidate?: (k: string) => void }).invalidate;\n\t\t\tconst evict =\n\t\t\t\ttypeof invalidate === 'function'\n\t\t\t\t\t? (k: string) => invalidate.call(cache, k)\n\t\t\t\t\t: (k: string) => cache.delete(k);\n\n\t\t\tif (sharedCacheKeys.has(key)) {\n\t\t\t\tif (repoPath !== commonPath) {\n\t\t\t\t\tevict(repoPath);\n\t\t\t\t}\n\t\t\t\tif (isLastWorktree) {\n\t\t\t\t\tevict(commonPath);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tevict(repoPath);\n\t\t\t}\n\t\t}\n\n\t\t// Shared, commonPath-keyed like `gkConfigMap` — only evict once no worktree still depends on it.\n\t\tif (isLastWorktree) {\n\t\t\tthis._gkConfigMergeSnapshots.delete(commonPath);\n\t\t}\n\n\t\tthis._commonPathRegistry.delete(repoPath);\n\n\t\tif (worktrees != null) {\n\t\t\tworktrees.delete(repoPath);\n\t\t\tif (worktrees.size === 0) {\n\t\t\t\tthis._worktreesByCommonPath.delete(commonPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug({ onlyExit: true })\n\treset(): void {\n\t\t// Advance the close clock BEFORE dropping the registry it reads from. Advancing rather than\n\t\t// clearing is the point: an async step that captured a generation must see a mismatch and bail,\n\t\t// where a cleared map would hand it a fresh `0` that matches and let it repopulate what was just\n\t\t// torn down. Union of registered paths and any already carrying a generation, mirroring\n\t\t// `incrementStatusGenerations`.\n\t\tfor (const path of new Set([...this._commonPathRegistry.keys(), ...this._closeGenerations.keys()])) {\n\t\t\tthis._closeGenerations.set(path, this.getCloseGeneration(path) + 1);\n\t\t}\n\n\t\tthis._commonPathRegistry.clear();\n\t\tthis._worktreesByCommonPath.clear();\n\t\tthis._statusGenerations.clear();\n\t\tthis._gkConfigMergeSnapshots.clear();\n\t\tthis._gkConfigReconciler = undefined;\n\t\tthis._caches = createEmptyCaches();\n\t}\n\n\t/** Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}). */\n\t@debug({ onlyExit: true })\n\tonRepositoryChanged(repoPath: string, changes: Iterable<RepositoryChange>): void {\n\t\tconst changesSet = new Set(changes);\n\t\tif (changesSet.has('unknown') || changesSet.has('closed')) {\n\t\t\tthis.unregisterRepoPath(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.applyRepositoryChanges(repoPath, changesSet, 'share');\n\t}\n\n\t/**\n\t * Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a\n\t * `'gkConfig'` change, returning the cache types it cleared. `inFlight` is as {@link clearCaches}\n\t * (`'share'`) vs {@link evictCaches} (`'evict'`). `'unknown'` and `'closed'` map to nothing here: the\n\t * watcher unregisters the path on them, and an announced write resets everything instead.\n\t */\n\t@debug({ onlyExit: true })\n\tapplyRepositoryChanges(\n\t\trepoPath: string,\n\t\tchanges: Iterable<RepositoryChange>,\n\t\tinFlight: 'share' | 'evict',\n\t): CachedGitTypes[] {\n\t\tconst changesSet = new Set(changes);\n\n\t\tconst hasAny = (...c: RepositoryChange[]) => c.some(ch => changesSet.has(ch));\n\n\t\t// Advance the status clock (see {@link getStatusGeneration}) for changes that alter `git status` output but\n\t\t// aren't mapped to the `'status'` cache type below: files (index/head/heads), untracked set (ignores/config),\n\t\t// ahead/behind (remotes). Paused-op changes advance it too, but via `clearCaches('status')` (see below) —\n\t\t// listing them here as well would double-increment the clock for a single change.\n\t\tif (hasAny('index', 'head', 'heads', 'remotes', 'ignores', 'config')) {\n\t\t\tthis.incrementStatusGeneration(repoPath);\n\t\t}\n\n\t\tconst types = new Set<CachedGitTypes>();\n\n\t\tif (hasAny('head')) {\n\t\t\ttypes.add('branch');\n\t\t}\n\n\t\tif (hasAny('index', 'heads', 'pausedOp')) {\n\t\t\ttypes.add('blame');\n\t\t\ttypes.add('diff');\n\t\t\ttypes.add('fileLog');\n\t\t}\n\n\t\tif (hasAny('index')) {\n\t\t\ttypes.add('tracking');\n\t\t}\n\n\t\tif (hasAny('config')) {\n\t\t\ttypes.add('config');\n\t\t}\n\n\t\tif (hasAny('heads')) {\n\t\t\ttypes.add('branches');\n\t\t\ttypes.add('contributors');\n\t\t\ttypes.add('worktrees');\n\t\t}\n\n\t\tif (hasAny('remotes')) {\n\t\t\ttypes.add('branches');\n\t\t\ttypes.add('contributors');\n\t\t\ttypes.add('remotes');\n\t\t\ttypes.add('worktrees');\n\t\t}\n\n\t\tif (hasAny('ignores')) {\n\t\t\ttypes.add('gitignore');\n\t\t}\n\n\t\tif (hasAny('gkConfig')) {\n\t\t\t// Handled separately (not folded into `types`/`clearCaches` below) — a gk write is usually a\n\t\t\t// bookkeeping timestamp that can't affect `baseBranchName`/`branchOverviews`, so this reconciles\n\t\t\t// down to only the keys that actually changed instead of coarsely clearing both on every write.\n\t\t\tthis.handleGkConfigChanged(repoPath);\n\t\t}\n\n\t\tif (hasAny('lastFetched')) {\n\t\t\ttypes.add('lastFetched');\n\t\t}\n\n\t\tif (hasAny('remoteProviders')) {\n\t\t\ttypes.add('providers');\n\t\t}\n\n\t\tif (hasAny('cherryPick', 'merge', 'rebase', 'revert', 'pausedOp')) {\n\t\t\ttypes.add('branch');\n\t\t\ttypes.add('status');\n\t\t}\n\n\t\tif (hasAny('stash')) {\n\t\t\ttypes.add('stashes');\n\t\t}\n\n\t\tif (hasAny('tags')) {\n\t\t\ttypes.add('tags');\n\t\t}\n\n\t\tif (hasAny('worktrees')) {\n\t\t\ttypes.add('worktrees');\n\t\t}\n\n\t\tif (types.size) {\n\t\t\tthis.clearCachesCore(inFlight, repoPath, ...types);\n\t\t}\n\t\treturn [...types];\n\t}\n\n\t/**\n\t * Handles a watcher-observed `'gkConfig'` change. Always evicts the cached bulk map (forcing the\n\t * next read to hit disk). If a reconciler is registered (see {@link setGkConfigReconciler}),\n\t * defers to it instead of coarsely clearing `baseBranchName`/`branchOverviews` — it re-reads the\n\t * map and diffs it against the snapshot captured here (i.e. as it stood right before this change),\n\t * cascading only the refs whose merge-relevant keys actually changed. Falls back to the coarse\n\t * clear when no reconciler is registered (e.g. the GitHub provider) so nothing can go stale.\n\t */\n\tprivate handleGkConfigChanged(repoPath: string): void {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\t// Hard-delete rather than `evictShared`'s soft-invalidate: the reconcile below needs a\n\t\t// point-in-time read of the post-change file, and a soft-invalidated entry stays joinable — the\n\t\t// re-read would ride a bulk read that started before this change and diff it as unchanged.\n\t\t// Same reasoning as `refs.ts`'s `force: true` path and `deleteGkConfig`'s own hard delete.\n\t\tthis._caches.gkConfigMap?.delete(commonPath);\n\n\t\tif (this._gkConfigReconciler == null) {\n\t\t\tthis.clearCaches(repoPath, 'gkConfig');\n\t\t\treturn;\n\t\t}\n\n\t\tconst priorSnapshot = this._gkConfigMergeSnapshots.get(commonPath);\n\t\t// Fire-and-forget, but the outcome still decides whether the coarse clear is owed: a reconcile that\n\t\t// FAILED leaves every derived cache holding pre-change values with nothing else to correct them, so\n\t\t// it falls back to the blunt behavior that registering a reconciler replaced. Kept here rather than\n\t\t// in the reconciler so a bail path added later can't silently skip it — the return type makes each\n\t\t// one say what it did.\n\t\tvoid Promise.resolve(this._gkConfigReconciler(repoPath, priorSnapshot)).then(\n\t\t\toutcome => {\n\t\t\t\tif (outcome === 'failed') {\n\t\t\t\t\tthis.clearCaches(repoPath, 'gkConfig');\n\t\t\t\t}\n\t\t\t},\n\t\t\t// An exception escaping the reconciler is a failure by definition — and one its own `catch`\n\t\t\t// never saw, so nothing else will have cascaded.\n\t\t\t() => this.clearCaches(repoPath, 'gkConfig'),\n\t\t);\n\t}\n\n\t/** Hard-evicts the cached bulk `.git/gk/config` map so the next read hits disk. */\n\tdeleteGkConfigMap(repoPath: string): void {\n\t\tthis._caches.gkConfigMap?.delete(this.getCommonPath(repoPath));\n\t}\n\n\t/** The merge-relevant gk config snapshot currently serving as the reconcile baseline. */\n\tgetGkConfigMergeSnapshot(repoPath: string): ReadonlyMap<string, string> | undefined {\n\t\treturn this._gkConfigMergeSnapshots.get(this.getCommonPath(repoPath));\n\t}\n\n\tgetBranches(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<PagedResult<GitBranch>>,\n\t\tmapper: (\n\t\t\tbranches: PagedResult<GitBranch>,\n\t\t\ttargetRepoPath: string,\n\t\t\tcommonPath: string,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<PagedResult<GitBranch>>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitBranch>> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\t// Register this caller with the shared factory's aggregate so that invariant 3\n\t\t// (factory aborts iff every waiter has aborted) holds for same-`repoPath` cache hits too.\n\t\t// The returned wrapped promise is deliberately discarded — we use the raw cached inner\n\t\t// below to build the mapped entry. Swallow any rejection on this dangling reference so\n\t\t// it doesn't surface as an unhandled rejection; the real caller-facing promise (via\n\t\t// `branches.getOrCreate` below) is where caller cancellation flows to.\n\t\tconst registration = this.sharedBranches.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => {\n\t\t\t\tconst p = Promise.resolve(factory(commonPath, cacheable, signal));\n\t\t\t\t// On factory invalidation, propagate to the derived per-worktree mapper entries\n\t\t\t\t// via soft-invalidate — existing waiters on the mapper complete, and the entry\n\t\t\t\t// self-evicts on mapper settle so the next callers build fresh derived entries.\n\t\t\t\tvoid p\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (cacheable.invalidated) {\n\t\t\t\t\t\t\tthis.branches.invalidate(commonPath);\n\t\t\t\t\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\t\t\t\t\tthis.branches.invalidate(worktreePath);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t// Swallow the cleanup chain's rejection so a rejected factory (e.g. cancellation)\n\t\t\t\t\t// doesn't surface as an unhandled rejection; the caller-facing promise handles it.\n\t\t\t\t\t.catch(() => {});\n\t\t\t\treturn p;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t\tvoid registration.catch(() => {});\n\n\t\t// Build the per-`repoPath` mapped entry through `getOrCreate` so mapper internal git\n\t\t// work (e.g. `getCurrentBranchReferenceCore`) runs under a mapper-level aggregate signal\n\t\t// separate from the factory's. Subsequent same-`repoPath` cache hits register with this\n\t\t// aggregate too — invariant 2/3 hold at the mapper level.\n\t\treturn this.branches.getOrCreate(\n\t\t\trepoPath,\n\t\t\t(_cacheable, mapperSignal) => {\n\t\t\t\t// After `getOrCreate` above, `sharedBranches[commonPath]` holds the raw inner\n\t\t\t\t// factory promise. Fall back to `registration` in the paranoid case where a\n\t\t\t\t// synchronously-rejected factory got auto-evicted before we retrieve it.\n\t\t\t\tconst rawShared = this.sharedBranches.get(commonPath) ?? registration;\n\t\t\t\treturn Promise.resolve(rawShared).then(shared => mapper(shared, repoPath, commonPath, mapperSignal));\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate static readonly globalConfigKey = '';\n\n\tgetConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\tfactory: () => PromiseOrValue<string | undefined>,\n\t): Promise<string | undefined> {\n\t\tconst cacheKey = repoPath != null ? this.getCommonPath(repoPath) : Cache.globalConfigKey;\n\n\t\tconst result = this.configKeys.get(cacheKey, key);\n\t\tif (result != null) return result;\n\n\t\tconst factoryPromise = Promise.resolve(factory());\n\t\tthis.configKeys.set(cacheKey, key, factoryPromise);\n\t\treturn factoryPromise;\n\t}\n\n\tgetConfigRegex(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\tfactory: () => PromiseOrValue<Map<string, string>>,\n\t): Promise<Map<string, string>> {\n\t\tconst cacheKey = repoPath != null ? this.getCommonPath(repoPath) : Cache.globalConfigKey;\n\n\t\tconst result = this.configPatterns.get(cacheKey, pattern);\n\t\tif (result != null) return result;\n\n\t\tconst factoryPromise = Promise.resolve(factory());\n\t\tthis.configPatterns.set(cacheKey, pattern, factoryPromise);\n\t\treturn factoryPromise;\n\t}\n\n\tdeleteConfig(repoPath: string | undefined, key: string): void {\n\t\tconst cacheKey = repoPath != null ? this.getCommonPath(repoPath) : Cache.globalConfigKey;\n\t\tthis._caches.configKeys?.delete(cacheKey, key);\n\t\tthis._caches.configPatterns?.delete(cacheKey);\n\t}\n\n\t/**\n\t * The whole `.git/gk/config` is read once and cached as a single map per commonPath; per-key and\n\t * per-namespace gk lookups are served from it in-memory (see `getGkConfigMap` in the CLI config\n\t * sub-provider). Invalidated by `deleteGkConfig` (write) and, on a watcher `'gkConfig'` event, by\n\t * `handleGkConfigChanged` (reconciled precisely when a reconciler is registered, or the coarse\n\t * clear otherwise). The first fresh read seeds the merge-relevant snapshot used by\n\t * `reconcileGkConfigMap`; later refreshes of that snapshot are owned by the reconcile itself.\n\t */\n\tgetGkConfigMap(\n\t\trepoPath: string,\n\t\tfactory: (cacheable: CacheController) => PromiseOrValue<Map<string, string>>,\n\t): Promise<Map<string, string>> {\n\t\treturn this.getSharedSimple(this.gkConfigMap, repoPath, async (commonPath, cacheable) => {\n\t\t\tconst map = await factory(cacheable);\n\t\t\t// Seed the reconcile baseline on first observation only. Refreshes belong to\n\t\t\t// `reconcileGkConfigMap` (after it has cascaded) and `recordGkConfigWrite` (our own writes):\n\t\t\t// an incidental read that happens to land between an external write and the watcher event\n\t\t\t// would otherwise advance the baseline to the post-change value, so the reconcile would diff\n\t\t\t// that value against itself and silently drop the change.\n\t\t\tif (!this._gkConfigMergeSnapshots.has(commonPath)) {\n\t\t\t\tthis._gkConfigMergeSnapshots.set(commonPath, this.extractMergeRelevantGkConfig(map));\n\t\t\t}\n\t\t\treturn map;\n\t\t});\n\t}\n\n\t/** Extracts the subset of a gk config map whose keys participate in the `branchOverviews`/`baseBranchName` lineage. */\n\tprivate extractMergeRelevantGkConfig(map: ReadonlyMap<string, string>): Map<string, string> {\n\t\tconst subset = new Map<string, string>();\n\t\tfor (const [key, value] of map) {\n\t\t\tif (branchOverviewGkConfigKeysRegex.test(key)) {\n\t\t\t\tsubset.set(key, value);\n\t\t\t}\n\t\t}\n\t\treturn subset;\n\t}\n\n\t/**\n\t * Clears the cached `.git/gk/config` map and invalidates the derived caches\n\t * (`baseBranchName`/`branchOverviews`) for the written key's ref.\n\t *\n\t * @param options.skipInvalidation Downstream caches the caller wants preserved despite this\n\t * write. Use when the value being written is exactly what was just resolved — e.g. the Tier 2\n\t * `storeMergeTargetBranchName` self-write inside `getBranchContributionsOverview` (skip\n\t * `'branchOverviews'`) or the Tier 3 `storeBaseBranchName` self-write inside `getBaseBranchName`\n\t * (skip both `'baseBranchName'` and `'branchOverviews'`). The bulk `gkConfigMap` map always\n\t * invalidates so subsequent reads see the new value.\n\t */\n\tdeleteGkConfig(\n\t\trepoPath: string,\n\t\tkey: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): void {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tthis._caches.gkConfigMap?.delete(commonPath);\n\t\tthis.cascadeGkConfigKeyChange(commonPath, key, options?.skipInvalidation);\n\t}\n\n\t/**\n\t * Keeps the merge-relevant gk config snapshot in sync with OUR OWN writes, so the next\n\t * watcher-triggered `reconcileGkConfigMap` diffs a self-write as unchanged rather than as an\n\t * external change (which would otherwise defeat `skipInvalidation`). No-ops for keys outside the\n\t * merge-relevant subset, and if no snapshot exists yet for this repo — nothing to keep in sync;\n\t * the next real read (`getGkConfigMap`) populates one from scratch.\n\t */\n\trecordGkConfigWrite(repoPath: string, key: string, value: string | undefined): void {\n\t\tif (!branchOverviewGkConfigKeysRegex.test(key)) return;\n\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst snapshot = this._gkConfigMergeSnapshots.get(commonPath);\n\t\tif (snapshot == null) return;\n\n\t\t// Copy-on-write: a reconcile in flight is holding this map as its `priorSnapshot` baseline, so\n\t\t// mutating it in place would silently move that baseline mid-diff.\n\t\tconst next = new Map(snapshot);\n\t\tif (value == null) {\n\t\t\tnext.delete(key);\n\t\t} else {\n\t\t\tnext.set(key, value);\n\t\t}\n\t\tthis._gkConfigMergeSnapshots.set(commonPath, next);\n\t}\n\n\t/**\n\t * Registers the reconciler invoked by {@link handleGkConfigChanged} on a watcher-observed\n\t * `'gkConfig'` change. Only one reconciler is kept — later registrations replace earlier ones,\n\t * which is harmless since every CLI config sub-provider sharing this `Cache` reconciles the same\n\t * underlying `.git/gk/config` file identically.\n\t */\n\tsetGkConfigReconciler(\n\t\treconciler: (\n\t\t\trepoPath: string,\n\t\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\t) => PromiseOrValue<GkReconcileOutcome>,\n\t): void {\n\t\tthis._gkConfigReconciler = reconciler;\n\t}\n\n\t/**\n\t * Diffs a freshly-read gk config map's merge-relevant subset against `priorSnapshot` (captured by\n\t * `handleGkConfigChanged` before the reconcile started, so it reflects the pre-change state even\n\t * though this call's own re-read already raced ahead and refreshed the live snapshot), cascading\n\t * `baseBranchName`/`branchOverviews` for every ref whose merge-relevant key actually changed.\n\t * `priorSnapshot` of `undefined` (never observed before this reconcile) is treated as \"everything\n\t * may have changed\" — a full coarse clear, same as the pre-existing watcher behavior. Returns\n\t * whether anything changed (i.e. whether a follow-up repository-changed event is warranted).\n\t */\n\treconcileGkConfigMap(\n\t\trepoPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\tfreshMap: ReadonlyMap<string, string>,\n\t): boolean {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst newSubset = this.extractMergeRelevantGkConfig(freshMap);\n\t\tthis._gkConfigMergeSnapshots.set(commonPath, newSubset);\n\n\t\tif (priorSnapshot == null) {\n\t\t\tthis.evictShared('baseBranchName', repoPath);\n\t\t\tthis.evictShared('branchOverviews', repoPath);\n\t\t\treturn true;\n\t\t}\n\n\t\tlet changed = false;\n\t\tfor (const key of new Set([...priorSnapshot.keys(), ...newSubset.keys()])) {\n\t\t\tif (priorSnapshot.get(key) !== newSubset.get(key)) {\n\t\t\t\tchanged = true;\n\t\t\t\tthis.cascadeGkConfigKeyChange(commonPath, key);\n\t\t\t}\n\t\t}\n\t\treturn changed;\n\t}\n\n\t/**\n\t * Shared per-ref cascade for a changed `branch.<ref>.gk-...` key: invalidates `baseBranchName` (for\n\t * `gk-merge-base`) and `branchOverviews` (for any merge-relevant key), honoring `skipInvalidation`.\n\t * Used by both a direct write (`deleteGkConfig`) and a reconciled external change\n\t * (`reconcileGkConfigMap`). No-ops for keys outside the merge-relevant subset.\n\t */\n\tprivate cascadeGkConfigKeyChange(\n\t\tcommonPath: string,\n\t\tkey: string,\n\t\tskip?: readonly GkConfigInvalidationTarget[],\n\t): void {\n\t\tconst refMatch = key.match(branchOverviewGkConfigKeysRegex);\n\t\tif (refMatch == null) return;\n\n\t\tconst ref = refMatch[1];\n\n\t\t// `getBaseBranchName` reads `branch.<ref>.gk-merge-base` and caches the resolved value\n\t\t// per-ref. A change to that key must invalidate the cached base or Tier 3 of\n\t\t// `getBranchContributionsOverview` will resolve `mergeTarget` against the pre-change value.\n\t\tif (key.endsWith('.gk-merge-base') && !skip?.includes('baseBranchName')) {\n\t\t\tthis._caches.baseBranchName?.delete(commonPath, ref);\n\t\t}\n\n\t\tif (skip?.includes('branchOverviews')) return;\n\n\t\t// When the change affects a branch's merge-target/base lineage, invalidate that branch's\n\t\t// cached overviews so subsequent reads pick up the new stored value rather than stale data.\n\t\t// `getBranchContributionsOverview` keys `branchOverviews` by `${ref}|${mergeTarget}`, so\n\t\t// invalidate every entry for the affected ref regardless of which target it resolved to.\n\t\t// Uses `invalidateByKeyPrefix` (not `deleteByKeyPrefix`) so an in-flight factory is still\n\t\t// shared with new callers instead of triggering a duplicate fetch.\n\t\t//\n\t\t// Sibling worktrees get their own bucket, not just the shared one: `getSharedOrCreateWithKey`\n\t\t// stores a per-worktree *mapped* entry under that worktree's own path, and prefix-invalidation\n\t\t// only reaches one bucket. The in-flight case self-propagates on settle, but an already-settled\n\t\t// overview would otherwise survive here — which the coarse `evictShared` path this replaced did\n\t\t// clear, since it iterated the worktrees.\n\t\tthis._caches.branchOverviews?.invalidateByKeyPrefix(commonPath, `${ref}|`);\n\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\tthis._caches.branchOverviews?.invalidateByKeyPrefix(worktreePath, `${ref}|`);\n\t\t}\n\t}\n\n\tasync getBranchOverview(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<BranchContributionsOverview | undefined>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<BranchContributionsOverview | undefined> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.branchOverviews,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) =>\n\t\t\t\tdata == null\n\t\t\t\t\t? data\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\trepoPath: newRepoPath,\n\t\t\t\t\t\t\tcontributors: data.contributors.map(c => c.withRepoPath(newRepoPath)),\n\t\t\t\t\t\t},\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync getContributors(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitContributorsResult>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitContributorsResult> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.contributors,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => ({\n\t\t\t\t...data,\n\t\t\t\tcontributors: data.contributors.map(c => c.withRepoPath(newRepoPath)),\n\t\t\t}),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync getContributorsLite(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitContributor[]>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitContributor[]> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.contributorsLite,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => data.map(c => c.withRepoPath(newRepoPath)),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tgetContributorsStats(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitContributorsStats | undefined>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitContributorsStats | undefined> {\n\t\treturn this.getSharedSimpleWithKey(this.contributorsStats, repoPath, cacheKey, factory, options);\n\t}\n\n\tgetBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<string | undefined>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\treturn this.getSharedSimpleWithKey(this.baseBranchName, repoPath, ref, factory, {\n\t\t\t// A bounded ceiling, because the eviction signals can't cover every way a base changes. The\n\t\t\t// `'branches'` cascade deliberately doesn't clear this — a tip move can't change a base, and\n\t\t\t// re-deriving per commit is the cost this exists to avoid — but that leaves a hole: a branch\n\t\t\t// deleted and recreated OUTSIDE GitLens, and never checked out, emits only `heads`. A base\n\t\t\t// derived as \"none\" before that would otherwise stay \"none\" for the session.\n\t\t\t//\n\t\t\t// `createTTL`, NOT `accessTTL`: the sliding variant resets on every read, so a branch card\n\t\t\t// polling this entry would hold it alive forever and never re-derive — the exact case the\n\t\t\t// ceiling exists for. Absolute from creation bounds staleness regardless of read frequency.\n\t\t\tcreateTTL: baseBranchNameTTL,\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t/**\n\t * Clears the cached base branch for `ref`. Call from ops that create/rename/delete a branch — the\n\t * `'branches'` cascade no longer clears these, since tip movement can't change a branch's base.\n\t *\n\t * Only clears the cache. A branch's base is *persisted* as `branch.<ref>.gk-merge-base` and read back\n\t * before the reflog fallback, so an op that ends a branch's identity under a name must drop or move\n\t * that key too (`removeGkConfigBranchSection`/`renameGkConfigBranchSection`) — otherwise the\n\t * re-derivation this triggers just reads the stale value straight back.\n\t */\n\tdeleteBaseBranchName(repoPath: string, ref: string): void {\n\t\tthis._caches.baseBranchName?.delete(this.getCommonPath(repoPath), ref);\n\t}\n\n\tgetBranchMergedStatus(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitBranchMergedStatus>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchMergedStatus> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.branchMergedStatus,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => {\n\t\t\t\tif (!data.merged) return data;\n\t\t\t\tif (data.localBranchOnly == null) return data;\n\n\t\t\t\tconst lbo = data.localBranchOnly;\n\t\t\t\treturn {\n\t\t\t\t\t...data,\n\t\t\t\t\tlocalBranchOnly: createReference(lbo.ref, newRepoPath, {\n\t\t\t\t\t\tid: getBranchId(newRepoPath, lbo.remote, lbo.name),\n\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\tname: lbo.name,\n\t\t\t\t\t\tremote: lbo.remote,\n\t\t\t\t\t\tupstream: lbo.upstream,\n\t\t\t\t\t\tsha: lbo.sha,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tgetBranchMetadataMap(\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string) => PromiseOrValue<Map<string, BranchMetadata>>,\n\t): Promise<Map<string, BranchMetadata>> {\n\t\treturn this.getSharedSimple(this.branchMetadataMap, repoPath, factory);\n\t}\n\n\tgetDefaultBranchName(\n\t\trepoPath: string,\n\t\tremote: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<string | undefined>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\treturn this.getSharedSimpleWithKey(this.defaultBranchName, repoPath, remote, factory, {\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t/** Clears the cached default branch for one `remote` key (the networked lookup or its `:local` variant). */\n\tdeleteDefaultBranchName(repoPath: string, remote: string): void {\n\t\tthis._caches.defaultBranchName?.delete(this.getCommonPath(repoPath), remote);\n\t}\n\n\tgetInitialCommitSha(\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string) => PromiseOrValue<string | undefined>,\n\t): Promise<string | undefined> {\n\t\treturn this.getSharedSimple(this.initialCommitSha, repoPath, factory);\n\t}\n\n\t/** A rejected factory is never cached (`PromiseMap` evicts on rejection) — a failed read retries next time. */\n\tgetEmptyTreeSha(repoPath: string, factory: (commonPath: string) => PromiseOrValue<string>): Promise<string> {\n\t\treturn this.getSharedSimple(this.emptyTreeSha, repoPath, factory);\n\t}\n\n\tgetLastFetchedTimestamp(\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string) => PromiseOrValue<number | undefined>,\n\t): Promise<number | undefined> {\n\t\treturn this.getSharedSimple(this.lastFetched, repoPath, factory);\n\t}\n\n\tgetRefs(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<RefRecord[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RefRecord[]> {\n\t\t// Raw ref records are repoPath-agnostic (no per-worktree binding to remap), so we key only\n\t\t// by commonPath and skip the per-worktree mapper that `getBranches`/`getTags` need.\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\treturn this.refs.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => Promise.resolve(factory(commonPath, cacheable, signal)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tgetRefTips(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitRefTip[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRefTip[]> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\treturn this.refTips.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => Promise.resolve(factory(commonPath, cacheable, signal)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tasync getRemotes(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitRemote[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote[]> {\n\t\treturn this.getSharedOrCreate(\n\t\t\tthis.remotes,\n\t\t\trepoPath,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => data.map(r => r.withRepoPath(newRepoPath)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tasync getStash(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitStash>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitStash> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.stashes,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => ({\n\t\t\t\trepoPath: newRepoPath,\n\t\t\t\tstashes: new Map(\n\t\t\t\t\tArray.from(data.stashes.entries(), ([sha, s]) => [\n\t\t\t\t\t\tsha,\n\t\t\t\t\t\ts.withRepoPath<GitStashCommit>(newRepoPath),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t}),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync getTags(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<PagedResult<GitTag>>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitTag>> {\n\t\treturn this.getSharedOrCreate(\n\t\t\tthis.tags,\n\t\t\trepoPath,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => ({ ...data, values: data.values.map(t => t.withRepoPath(newRepoPath)) }),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tasync getWorktrees(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitWorktree[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree[]> {\n\t\treturn this.getSharedOrCreate(\n\t\t\tthis.worktrees,\n\t\t\trepoPath,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => data.map(w => w.withRepoPath(newRepoPath)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getSharedOrCreate<T>(\n\t\tcache: PromiseMap<string, T>,\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<T>,\n\t\tmapper: (data: T, repoPath: string) => T,\n\t\tcancellation?: AbortSignal,\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\t// Always register this caller with the shared factory's aggregate so same-`repoPath` and\n\t\t// worktree-distinct concurrent callers both contribute — invariant 3 (factory aborts iff\n\t\t// every waiter aborts) holds uniformly. The wrapped return is our caller-facing promise\n\t\t// for the commonPath-keyed branch; the per-worktree branch uses `raceWithSignal` below.\n\t\tconst sharedPromise = cache.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => {\n\t\t\t\tconst p = Promise.resolve(factory(commonPath, cacheable, signal));\n\t\t\t\t// On factory invalidation (without rejection), propagate to the derived per-worktree\n\t\t\t\t// mapper entries so they don't persist past the shared factory's settle. Mapper\n\t\t\t\t// entries cached via `cache.set()` have no controller, so `invalidate` hard-deletes.\n\t\t\t\tvoid p\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (cacheable.invalidated) {\n\t\t\t\t\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\t\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\t\t\t\t\tcache.invalidate(worktreePath);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t// Swallow the cleanup chain's rejection so a rejected factory (e.g. cancellation)\n\t\t\t\t\t// doesn't surface as an unhandled rejection; the caller-facing promise handles it.\n\t\t\t\t\t.catch(() => {});\n\t\t\t\treturn p;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t\t// Swallow any rejection on the registration wrapper so it isn't surfaced as an unhandled\n\t\t// rejection when we discard it below (existing-mapper path). The real caller-facing\n\t\t// promise is the returned value.\n\t\tvoid sharedPromise.catch(() => {});\n\n\t\tif (commonPath !== repoPath) {\n\t\t\t// Reuse the cached mapped entry for this worktree if present; otherwise derive it off\n\t\t\t// the raw inner shared promise so subsequent cache hits don't inherit the first\n\t\t\t// caller's signal wrap.\n\t\t\tconst existing = cache.get(repoPath);\n\t\t\tif (existing != null) {\n\t\t\t\treturn cancellation != null ? raceWithSignal(existing, cancellation) : existing;\n\t\t\t}\n\n\t\t\tconst rawShared = cache.get(commonPath) ?? sharedPromise;\n\t\t\tconst mappedPromise = Promise.resolve(rawShared).then(data => mapper(data, repoPath));\n\t\t\tcache.set(repoPath, mappedPromise);\n\t\t\treturn cancellation != null ? raceWithSignal(mappedPromise, cancellation) : mappedPromise;\n\t\t}\n\n\t\treturn sharedPromise;\n\t}\n\n\tprivate async getSharedOrCreateWithKey<T>(\n\t\tcache: RepoPromiseCacheMap<string, T>,\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<T>,\n\t\tmapper: (data: T, repoPath: string) => T,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst cancellation = options?.cancellation;\n\n\t\t// Always register with the shared factory's aggregate (see `getSharedOrCreate` comment).\n\t\tconst sharedPromise = cache.getOrCreate(\n\t\t\tcommonPath,\n\t\t\tcacheKey,\n\t\t\t(cacheable, signal) => {\n\t\t\t\tconst p = Promise.resolve(factory(commonPath, cacheable, signal));\n\t\t\t\t// On factory invalidation (without rejection), propagate to the derived per-worktree\n\t\t\t\t// mapper entries for this `cacheKey` so they don't persist past the shared factory's\n\t\t\t\t// settle. Mapper entries cached via `cache.set()` have no controller, so `invalidate`\n\t\t\t\t// hard-deletes.\n\t\t\t\tvoid p\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (cacheable.invalidated) {\n\t\t\t\t\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\t\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\t\t\t\t\tcache.invalidate(worktreePath, cacheKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t// Swallow the cleanup chain's rejection so a rejected factory (e.g. cancellation)\n\t\t\t\t\t// doesn't surface as an unhandled rejection; the caller-facing promise handles it.\n\t\t\t\t\t.catch(() => {});\n\t\t\t\treturn p;\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t\t// Swallow any rejection on the registration wrapper so it isn't surfaced as an unhandled\n\t\t// rejection when we discard it below (existing-mapper path).\n\t\tvoid sharedPromise.catch(() => {});\n\n\t\tif (commonPath !== repoPath) {\n\t\t\tconst existing = cache.get(repoPath, cacheKey);\n\t\t\tif (existing != null) {\n\t\t\t\treturn cancellation != null ? raceWithSignal(existing, cancellation) : existing;\n\t\t\t}\n\n\t\t\tconst rawShared = cache.get(commonPath, cacheKey) ?? sharedPromise;\n\t\t\tconst mappedPromise = Promise.resolve(rawShared).then(data => mapper(data, repoPath));\n\t\t\tcache.set(repoPath, cacheKey, mappedPromise, options);\n\t\t\treturn cancellation != null ? raceWithSignal(mappedPromise, cancellation) : mappedPromise;\n\t\t}\n\n\t\treturn sharedPromise;\n\t}\n\n\tprivate async getSharedSimple<T>(\n\t\tcache: PromiseMap<string, T> | PromiseCache<string, T>,\n\t\trepoPath: string,\n\t\t// `cacheable` is forwarded so a factory can refuse the entry when the read FAILED rather than\n\t\t// genuinely produced nothing — see `getSharedSimpleWithKey` for why that distinction matters.\n\t\tfactory: (commonPath: string, cacheable: CacheController) => PromiseOrValue<T>,\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\t// `PromiseMap.getOrCreate(key, factory, cancellation?)` and\n\t\t// `PromiseCache.getOrCreate(key, factory, options?)` have different 3rd-argument shapes,\n\t\t// so we dispatch on cache type. Both register a `CacheController` so `invalidate` works.\n\t\tif (cache instanceof PromiseCache) {\n\t\t\treturn cache.getOrCreate(commonPath, cacheable => Promise.resolve(factory(commonPath, cacheable)));\n\t\t}\n\t\treturn cache.getOrCreate(commonPath, cacheable => Promise.resolve(factory(commonPath, cacheable)));\n\t}\n\n\tprivate async getSharedSimpleWithKey<T>(\n\t\tcache: RepoPromiseCacheMap<string, T>,\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\t// `cacheable` is forwarded so a factory can distinguish \"the answer is genuinely nothing\" from \"the\n\t\t// read failed\": callers here set no TTL by default, so a failure resolved as `undefined` would\n\t\t// otherwise be served as a real answer until something explicitly evicts it.\n\t\tfactory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<T>,\n\t\toptions?: { accessTTL?: number; createTTL?: number; cancellation?: AbortSignal },\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\treturn cache.getOrCreate(\n\t\t\tcommonPath,\n\t\t\tcacheKey,\n\t\t\t(cacheable, signal) => Promise.resolve(factory(commonPath, cacheable, signal)),\n\t\t\toptions,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;AA0CA,MAAM,0BAAqD;CAAC;CAAS;CAAQ;AAAS;AACtF,SAAgB,2BAA2B,OAAqD;CAC/F,OAAO,MAAM,OAAM,MAAK,wBAAwB,SAAS,CAA4B,CAAC;AACvF;;;;;;AAsCA,MAAM,oBAAoB;;;;;AAM1B,MAAM,sBAAsB;AAE5B,eAAsB,2BAA2B,aA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,WAAA,SAAA,IAAA;AAoBxB,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,uBAAA,IAAA;AAiBxB,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,0BAAA,IAAA"}
1
+ {"version":3,"file":"cache.js","names":[],"sources":["../../../git/src/cache.ts"],"sourcesContent":["import { exhaustiveArray } from '@gitlens/utils/array.js';\nimport { raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { invalidateMemoized } from '@gitlens/utils/decorators/memoize.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { getBranchId } from '@gitlens/utils/gitRefs.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport { normalizePath } from '@gitlens/utils/path.js';\nimport type { PromiseOrValue } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { PromiseCache, PromiseMap, RepoPromiseCacheMap } from '@gitlens/utils/promiseCache.js';\nimport type { ResourceUsage } from '@gitlens/utils/resourceUsage.js';\nimport type { Uri } from '@gitlens/utils/uri.js';\nimport type { ProgressiveGitBlame } from './models/blame.js';\nimport type { BranchMetadata, GitBranch } from './models/branch.js';\nimport type { GitCommit, GitStashCommit } from './models/commit.js';\nimport type { GitContributor, GitContributorsStats } from './models/contributor.js';\nimport type { ParsedGitDiffHunks } from './models/diff.js';\nimport type { GitLog } from './models/log.js';\nimport type { ConflictDetectionResult } from './models/mergeConflicts.js';\nimport type { GitPausedOperationStatus } from './models/pausedOperationStatus.js';\nimport type { GitBranchReference, GitRefTip, RefRecord } from './models/reference.js';\nimport type { GitRemote } from './models/remote.js';\nimport type { RemoteProvider } from './models/remoteProvider.js';\nimport type { GitDir, RepositoryChange } from './models/repository.js';\nimport type { GitStash } from './models/stash.js';\nimport type { GitTag } from './models/tag.js';\nimport type { GitUser } from './models/user.js';\nimport type { GitWorktree } from './models/worktree.js';\nimport type { BranchContributionsOverview, GitBranchMergedStatus } from './providers/branches.js';\nimport type { GitCommitReachability, LeftRightCommitCountResult } from './providers/commits.js';\nimport type { GitContributorsResult } from './providers/contributors.js';\nimport type { ResolvedRevision } from './providers/revision.js';\nimport type { GitResult } from './run.types.js';\nimport { createReference } from './utils/reference.utils.js';\nimport { getCommonRepositoryPath, getRepositoryOrWorktreePath } from './utils/repository.utils.js';\nimport type { GitIgnoreFilter } from './watching/gitIgnoreFilter.js';\n\ntype RepoPath = string;\n\n/** Cache types that are keyed by file path within a repo — support per-file clearing */\nexport type UriScopedCachedGitTypes = 'blame' | 'diff' | 'fileLog';\n\nconst uriScopedCachedGitTypes: UriScopedCachedGitTypes[] = ['blame', 'diff', 'fileLog'];\nexport function areUriScopedCachedGitTypes(types: string[]): types is UriScopedCachedGitTypes[] {\n\treturn types.every(t => uriScopedCachedGitTypes.includes(t as UriScopedCachedGitTypes));\n}\n\nexport type CachedGitTypes =\n\t| UriScopedCachedGitTypes\n\t| 'branch'\n\t| 'branches'\n\t| 'config'\n\t| 'contributors'\n\t| 'gitignore'\n\t| 'gkConfig'\n\t| 'lastFetched'\n\t| 'providers'\n\t| 'remotes'\n\t| 'stashes'\n\t| 'status'\n\t| 'tags'\n\t| 'tracking'\n\t| 'worktrees';\n\n/**\n * What a gk-config reconcile did, so `Cache` knows whether the coarse fallback is still owed.\n *\n * `'deferred'` is NOT a failure — a pass already in flight folds the change into its trailing pass — and\n * must not trigger the fallback, or a burst of gk writes would coarse-clear on every one, which is exactly\n * the churn the key-aware reconcile replaced.\n */\nexport type GkReconcileOutcome = 'reconciled' | 'deferred' | 'failed';\n\n/** Fired by {@link Cache.onDidChangeMergeTargets} */\nexport interface MergeTargetsChangeEvent {\n\t/**\n\t * The repository's common path (the main worktree's, once registered). Merge keys live in the shared\n\t * `.git/gk/config`, so this fires once per change for the whole repository, not once per worktree.\n\t */\n\treadonly repoPath: string;\n\t/**\n\t * Branches whose merge-relevant keys (`gk-merge-base`, `gk-merge-target`, `gk-merge-target-user`,\n\t * `gk-target-base`) changed. `undefined` when it can't be told, so any branch's may have: the coarse fallback\n\t * (no reconciler, or a failed reconcile), or a change with no earlier snapshot to diff against.\n\t */\n\treadonly refs: ReadonlySet<string> | undefined;\n}\n\nexport type ConflictDetectionCacheKey =\n\t| `apply:${string}:${string}:${string}`\n\t| `merge:${string}:${string}`\n\t| `reapply:${string}:${string}`;\n\n/**\n * Ceiling on how long a derived branch base is trusted. Long enough that repeated reads during normal use\n * are served from cache, short enough that a base that changed by a route with no eviction signal (an\n * external delete-and-recreate of a branch that is never checked out) self-heals without a reload.\n */\nconst baseBranchNameTTL = 5 * 60 * 1000; // 5 minutes\n\n/**\n * Completed blame graphs retain several objects and substrings per line. Keep normal files hot, but let large\n * documents be owned by their active tracked-document snapshot instead of retaining a second long-lived owner.\n */\nconst maxCachedBlameLines = 5000;\n\nexport async function shouldEvictBlameCacheEntry(progressive: ProgressiveGitBlame | undefined): Promise<boolean> {\n\tif (progressive == null) return false;\n\n\ttry {\n\t\tconst blame = await progressive.completed;\n\t\treturn blame.lines.length > maxCachedBlameLines;\n\t} catch {\n\t\t// The provider factory resolves as soon as streaming starts, so a later stream failure must also be retried.\n\t\treturn true;\n\t}\n}\n\n/**\n * gkConfig keys that participate in the `branchOverviews` cache's mergeTarget/mergeBase lineage.\n * Capture group 1 is the ref name (which may itself contain `.`/`/`).\n */\nconst branchOverviewGkConfigKeysRegex = /^branch\\.(.+)\\.(?:gk-merge-(?:base|target(?:-user)?)|gk-target-base)$/;\n\n/**\n * Downstream caches that `deleteGkConfig` may invalidate when a `branch.<ref>.gk-...` key changes.\n * Callers performing a \"self-write\" (where the value being written matches what they just resolved,\n * so the about-to-be-evicted entry is exactly the entry they want to preserve) can opt out by\n * naming the targets to skip via `skipInvalidation`.\n */\nexport type GkConfigInvalidationTarget = 'branchOverviews' | 'baseBranchName';\n\n/** Per-worktree caches — cleared by repoPath directly */\ninterface Caches {\n\tbestRemotes: PromiseMap<RepoPath, GitRemote<RemoteProvider>[]> | undefined;\n\tblame: RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined> | undefined;\n\tbranch: PromiseMap<RepoPath, GitBranch | undefined> | undefined;\n\tcommit: RepoPromiseCacheMap<string, GitCommit | undefined> | undefined;\n\tcommitCount: RepoPromiseCacheMap<string, number | undefined> | undefined;\n\tconflictDetection: RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult> | undefined;\n\tcurrentBranchReference: PromiseCache<RepoPath, GitBranchReference | undefined> | undefined;\n\tcurrentUser: Map<RepoPath, GitUser | null> | undefined;\n\tdiff: RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined> | undefined;\n\tfileExistence: RepoPromiseCacheMap<string, boolean> | undefined;\n\tfileLog: RepoPromiseCacheMap<string, GitLog | undefined> | undefined;\n\tgitDir: Map<RepoPath, GitDir> | undefined;\n\tgitIgnore: Map<RepoPath, GitIgnoreFilter> | undefined;\n\tignoreRevsFile: PromiseCache<string, boolean> | undefined;\n\tleftRightCommitCount: RepoPromiseCacheMap<string, LeftRightCommitCountResult | undefined> | undefined;\n\tmergeBase: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tpatchIds: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tpausedOperationStatus: PromiseMap<RepoPath, GitPausedOperationStatus | undefined> | undefined;\n\treachability: RepoPromiseCacheMap<string, GitCommitReachability | undefined> | undefined;\n\tresolvedRevisions: RepoPromiseCacheMap<string, ResolvedRevision> | undefined;\n\ttrackedPaths: RepoPromiseCacheMap<string, [string, string] | false> | undefined;\n}\n\n/** Shared caches — cleared via commonPath + all worktree paths */\ninterface SharedCaches {\n\tbaseBranchName: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tbranchMergedStatus: RepoPromiseCacheMap<string, GitBranchMergedStatus> | undefined;\n\tbranchMetadataMap: PromiseMap<RepoPath, Map<string, BranchMetadata>> | undefined;\n\tbranchOverviews: RepoPromiseCacheMap<string, BranchContributionsOverview | undefined> | undefined;\n\tbranches: PromiseMap<RepoPath, PagedResult<GitBranch>> | undefined;\n\tconfigKeys: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\tconfigPatterns: RepoPromiseCacheMap<string, Map<string, string>> | undefined;\n\tcontributors: RepoPromiseCacheMap<string, GitContributorsResult> | undefined;\n\tcontributorsLite: RepoPromiseCacheMap<string, GitContributor[]> | undefined;\n\tcontributorsStats: RepoPromiseCacheMap<string, GitContributorsStats | undefined> | undefined;\n\tdefaultBranchName: RepoPromiseCacheMap<string, string | undefined> | undefined;\n\t/** The empty tree's id — a property of the repository's object format, which never changes for its lifetime. */\n\temptyTreeSha: PromiseMap<RepoPath, string> | undefined;\n\tgitResults: RepoPromiseCacheMap<string, GitResult> | undefined;\n\tgkConfigMap: PromiseMap<RepoPath, Map<string, string>> | undefined;\n\tinitialCommitSha: PromiseMap<RepoPath, string | undefined> | undefined;\n\t/** Keyed by commonPath — `FETCH_HEAD` lives in the common git dir, shared across worktrees. */\n\tlastFetched: PromiseCache<RepoPath, number | undefined> | undefined;\n\tlogShas: RepoPromiseCacheMap<string, string[]> | undefined;\n\trefs: PromiseMap<RepoPath, RefRecord[]> | undefined;\n\trefTips: PromiseMap<RepoPath, GitRefTip[]> | undefined;\n\tremotes: PromiseMap<RepoPath, GitRemote[]> | undefined;\n\tsharedBranches: PromiseMap<RepoPath, PagedResult<GitBranch>> | undefined;\n\tstashes: RepoPromiseCacheMap<string, GitStash> | undefined;\n\ttags: PromiseMap<RepoPath, PagedResult<GitTag>> | undefined;\n\tworktrees: PromiseMap<RepoPath, GitWorktree[]> | undefined;\n}\n\ntype AllCaches = Caches & SharedCaches;\n\n/** Compile-time enforced: adding a key to SharedCaches without listing it here is a type error */\nconst sharedCacheKeys: ReadonlySet<keyof AllCaches> = new Set(\n\texhaustiveArray<keyof SharedCaches>()([\n\t\t'baseBranchName',\n\t\t'branchMergedStatus',\n\t\t'branchMetadataMap',\n\t\t'branchOverviews',\n\t\t'branches',\n\t\t'configKeys',\n\t\t'configPatterns',\n\t\t'contributors',\n\t\t'contributorsLite',\n\t\t'contributorsStats',\n\t\t'defaultBranchName',\n\t\t'emptyTreeSha',\n\t\t'gitResults',\n\t\t'gkConfigMap',\n\t\t'initialCommitSha',\n\t\t'lastFetched',\n\t\t'logShas',\n\t\t'refs',\n\t\t'refTips',\n\t\t'remotes',\n\t\t'sharedBranches',\n\t\t'stashes',\n\t\t'tags',\n\t\t'worktrees',\n\t]),\n);\n\nfunction createEmptyCaches(): AllCaches {\n\treturn {\n\t\tbaseBranchName: undefined,\n\t\tbestRemotes: undefined,\n\t\tblame: undefined,\n\t\tbranch: undefined,\n\t\tbranchMergedStatus: undefined,\n\t\tbranchMetadataMap: undefined,\n\t\tbranchOverviews: undefined,\n\t\tbranches: undefined,\n\t\tcommit: undefined,\n\t\tcommitCount: undefined,\n\t\tfileExistence: undefined,\n\t\tignoreRevsFile: undefined,\n\t\tleftRightCommitCount: undefined,\n\t\tmergeBase: undefined,\n\t\tpatchIds: undefined,\n\t\tconfigKeys: undefined,\n\t\tconfigPatterns: undefined,\n\t\tconflictDetection: undefined,\n\t\tdiff: undefined,\n\t\tfileLog: undefined,\n\t\tcontributors: undefined,\n\t\tcontributorsLite: undefined,\n\t\tcontributorsStats: undefined,\n\t\tcurrentBranchReference: undefined,\n\t\tcurrentUser: undefined,\n\t\tdefaultBranchName: undefined,\n\t\temptyTreeSha: undefined,\n\t\tgitDir: undefined,\n\t\tgitIgnore: undefined,\n\t\tgitResults: undefined,\n\t\tgkConfigMap: undefined,\n\t\tinitialCommitSha: undefined,\n\t\tlastFetched: undefined,\n\t\tlogShas: undefined,\n\t\tpausedOperationStatus: undefined,\n\t\tresolvedRevisions: undefined,\n\t\treachability: undefined,\n\t\trefs: undefined,\n\t\trefTips: undefined,\n\t\tremotes: undefined,\n\t\tsharedBranches: undefined,\n\t\tstashes: undefined,\n\t\ttags: undefined,\n\t\ttrackedPaths: undefined,\n\t\tworktrees: undefined,\n\t};\n}\n\nexport class Cache implements Disposable {\n\tprivate _caches: AllCaches = createEmptyCaches();\n\tprivate _commonPathRegistry = new Map<RepoPath, string>();\n\t/** Reverse index: commonPath → set of worktree repoPaths that share it */\n\tprivate _worktreesByCommonPath = new Map<string, Set<RepoPath>>();\n\t/** Monotonic per-worktree \"status clock\" — see {@link getStatusGeneration}. */\n\tprivate _statusGenerations = new Map<RepoPath, number>();\n\t/** Monotonic per-path \"close clock\" — see {@link getCloseGeneration}. */\n\tprivate _closeGenerations = new Map<RepoPath, number>();\n\n\t/**\n\t * Per-commonPath snapshot of the merge-relevant subset of `.git/gk/config` (keys matching\n\t * {@link branchOverviewGkConfigKeysRegex}), used by {@link reconcileGkConfigMap} to diff a watcher\n\t * `'gkConfig'` event down to only the keys that actually changed, instead of coarsely re-deriving\n\t * `baseBranchName`/`branchOverviews` on every gk write. Absent means \"never observed\".\n\t */\n\tprivate _gkConfigMergeSnapshots = new Map<string, Map<string, string>>();\n\n\tprivate readonly _onDidChangeMergeTargets = new Emitter<MergeTargetsChangeEvent>();\n\t/**\n\t * Fires when an external `.git/gk/config` write changed a branch's merge-relevant keys — never for a write that\n\t * only touched other keys (activity timestamps), and never for core's own writes, which\n\t * {@link recordGkConfigWrite} folds into the snapshot before the watcher reports them. Fires after the derived\n\t * caches were cleared, so a listener's re-read sees the new values.\n\t */\n\tget onDidChangeMergeTargets(): Event<MergeTargetsChangeEvent> {\n\t\treturn this._onDidChangeMergeTargets.event;\n\t}\n\n\t/**\n\t * Reconciler registered by the CLI config sub-provider (see {@link setGkConfigReconciler}),\n\t * invoked on a watcher-observed `'gkConfig'` change instead of the coarse `clearCaches(repoPath,\n\t * 'gkConfig')` cascade. `undefined` (e.g. the GitHub provider, which has no `.git/gk/config`)\n\t * falls back to the coarse clear.\n\t */\n\tprivate _gkConfigReconciler:\n\t\t| ((\n\t\t\t\trepoPath: string,\n\t\t\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\t ) => PromiseOrValue<GkReconcileOutcome>)\n\t\t| undefined;\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tthis.reset();\n\t\tthis._onDidChangeMergeTargets.dispose();\n\t}\n\n\t/** Resource usage retained by instantiated sub-caches and their bookkeeping maps. */\n\tgetResourceUsage(): ResourceUsage {\n\t\tconst usage: ResourceUsage = {};\n\t\tfor (const [name, cache] of Object.entries(this._caches)) {\n\t\t\tif (cache != null) {\n\t\t\t\tusage[`cache.${name}.entries.count`] =\n\t\t\t\t\tcache instanceof RepoPromiseCacheMap ? cache.entryCount : cache.size;\n\t\t\t}\n\t\t}\n\t\tusage['cache.commonPathRegistry.entries.count'] = this._commonPathRegistry.size;\n\t\tusage['cache.worktreesByCommonPath.entries.count'] = this._worktreesByCommonPath.size;\n\t\tusage['cache.statusGenerations.entries.count'] = this._statusGenerations.size;\n\t\tusage['cache.closeGenerations.entries.count'] = this._closeGenerations.size;\n\t\tusage['cache.gkConfigMergeSnapshots.entries.count'] = this._gkConfigMergeSnapshots.size;\n\t\treturn usage;\n\t}\n\n\tget bestRemotes(): PromiseMap<RepoPath, GitRemote<RemoteProvider>[]> {\n\t\treturn (this._caches.bestRemotes ??= new PromiseMap<RepoPath, GitRemote<RemoteProvider>[]>());\n\t}\n\n\tget blame(): RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined> {\n\t\treturn (this._caches.blame ??= new RepoPromiseCacheMap<string, ProgressiveGitBlame | undefined>({\n\t\t\tcreateTTL: 1000 * 60 * 10, // 10 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tget diff(): RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined> {\n\t\treturn (this._caches.diff ??= new RepoPromiseCacheMap<string, ParsedGitDiffHunks | undefined>({\n\t\t\tcreateTTL: 1000 * 60 * 10, // 10 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tget fileLog(): RepoPromiseCacheMap<string, GitLog | undefined> {\n\t\treturn (this._caches.fileLog ??= new RepoPromiseCacheMap<string, GitLog | undefined>({\n\t\t\tcreateTTL: 1000 * 60 * 10, // 10 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tprivate get baseBranchName(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.baseBranchName ??= new RepoPromiseCacheMap<string, string | undefined>());\n\t}\n\n\tget branch(): PromiseMap<RepoPath, GitBranch | undefined> {\n\t\treturn (this._caches.branch ??= new PromiseMap<RepoPath, GitBranch | undefined>());\n\t}\n\n\tget branchMergedStatus(): RepoPromiseCacheMap<string, GitBranchMergedStatus> {\n\t\treturn (this._caches.branchMergedStatus ??= new RepoPromiseCacheMap<string, GitBranchMergedStatus>({\n\t\t\tcreateTTL: 1000 * 60 * 30, // 30 minutes — content-keyed on tip shas, so this is just a backstop\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 100, // Limit to 100 branch-pairs per repo\n\t\t}));\n\t}\n\n\tprivate get branchMetadataMap(): PromiseMap<RepoPath, Map<string, BranchMetadata>> {\n\t\treturn (this._caches.branchMetadataMap ??= new PromiseMap<RepoPath, Map<string, BranchMetadata>>());\n\t}\n\n\tprivate get branchOverviews(): RepoPromiseCacheMap<string, BranchContributionsOverview | undefined> {\n\t\treturn (this._caches.branchOverviews ??= new RepoPromiseCacheMap<\n\t\t\tstring,\n\t\t\tBranchContributionsOverview | undefined\n\t\t>(\n\t\t\t{ accessTTL: 1000 * 60 * 60 }, // 60 minutes\n\t\t));\n\t}\n\n\tget branches(): PromiseMap<RepoPath, PagedResult<GitBranch>> {\n\t\treturn (this._caches.branches ??= new PromiseMap<RepoPath, PagedResult<GitBranch>>());\n\t}\n\n\t/**\n\t * Internal cache for raw shared branch data (keyed by commonPath)\n\t * Separate from branches cache because branches need to be mapped for each worktree\n\t */\n\tprivate get sharedBranches(): PromiseMap<RepoPath, PagedResult<GitBranch>> {\n\t\treturn (this._caches.sharedBranches ??= new PromiseMap<RepoPath, PagedResult<GitBranch>>());\n\t}\n\n\tprivate get configKeys(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.configKeys ??= new RepoPromiseCacheMap<string, string | undefined>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds - ensures global config changes are picked up\n\t\t}));\n\t}\n\n\tprivate get configPatterns(): RepoPromiseCacheMap<string, Map<string, string>> {\n\t\treturn (this._caches.configPatterns ??= new RepoPromiseCacheMap<string, Map<string, string>>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds - ensures global config changes are picked up\n\t\t}));\n\t}\n\n\tprivate get gkConfigMap(): PromiseMap<RepoPath, Map<string, string>> {\n\t\treturn (this._caches.gkConfigMap ??= new PromiseMap<RepoPath, Map<string, string>>());\n\t}\n\n\tget currentBranchReference(): PromiseCache<RepoPath, GitBranchReference | undefined> {\n\t\treturn (this._caches.currentBranchReference ??= new PromiseCache<RepoPath, GitBranchReference | undefined>());\n\t}\n\n\tsetCurrentBranchReferenceIfAbsent(worktreePath: string, reference: GitBranchReference | undefined): void {\n\t\tif (this.currentBranchReference.get(worktreePath) == null) {\n\t\t\tthis.currentBranchReference.set(worktreePath, Promise.resolve(reference));\n\t\t}\n\t}\n\n\tget conflictDetection(): RepoPromiseCacheMap<ConflictDetectionCacheKey, ConflictDetectionResult> {\n\t\treturn (this._caches.conflictDetection ??= new RepoPromiseCacheMap<\n\t\t\tConflictDetectionCacheKey,\n\t\t\tConflictDetectionResult\n\t\t>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds\n\t\t}));\n\t}\n\n\tget contributors(): RepoPromiseCacheMap<string, GitContributorsResult> {\n\t\treturn (this._caches.contributors ??= new RepoPromiseCacheMap<string, GitContributorsResult>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget contributorsLite(): RepoPromiseCacheMap<string, GitContributor[]> {\n\t\treturn (this._caches.contributorsLite ??= new RepoPromiseCacheMap<string, GitContributor[]>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget contributorsStats(): RepoPromiseCacheMap<string, GitContributorsStats | undefined> {\n\t\treturn (this._caches.contributorsStats ??= new RepoPromiseCacheMap<string, GitContributorsStats | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget currentUser(): Map<RepoPath, GitUser | null> {\n\t\treturn (this._caches.currentUser ??= new Map<RepoPath, GitUser | null>());\n\t}\n\n\tget defaultBranchName(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.defaultBranchName ??= new RepoPromiseCacheMap<string, string | undefined>());\n\t}\n\n\tget emptyTreeSha(): PromiseMap<RepoPath, string> {\n\t\treturn (this._caches.emptyTreeSha ??= new PromiseMap<RepoPath, string>());\n\t}\n\n\tget gitDir(): Map<RepoPath, GitDir> {\n\t\treturn (this._caches.gitDir ??= new Map<RepoPath, GitDir>());\n\t}\n\n\tget gitIgnore(): Map<RepoPath, GitIgnoreFilter> {\n\t\treturn (this._caches.gitIgnore ??= new Map<RepoPath, GitIgnoreFilter>());\n\t}\n\n\tget gitResults(): RepoPromiseCacheMap<RepoPath, GitResult> {\n\t\treturn (this._caches.gitResults ??= new RepoPromiseCacheMap<RepoPath, GitResult>({ capacity: 200 }));\n\t}\n\n\tget initialCommitSha(): PromiseMap<RepoPath, string | undefined> {\n\t\treturn (this._caches.initialCommitSha ??= new PromiseMap<RepoPath, string | undefined>());\n\t}\n\n\tget lastFetched(): PromiseCache<RepoPath, number | undefined> {\n\t\treturn (this._caches.lastFetched ??= new PromiseCache<RepoPath, number | undefined>({\n\t\t\tcreateTTL: 1000 * 30, // 30 seconds\n\t\t}));\n\t}\n\n\tget leftRightCommitCount(): RepoPromiseCacheMap<string, LeftRightCommitCountResult | undefined> {\n\t\treturn (this._caches.leftRightCommitCount ??= new RepoPromiseCacheMap<\n\t\t\tstring,\n\t\t\tLeftRightCommitCountResult | undefined\n\t\t>({\n\t\t\tcreateTTL: 1000 * 60 * 5, // 5 minutes max age — invalidated sooner on branch/remote changes\n\t\t\tcapacity: 50, // Limit to 50 ref-pairs per repo\n\t\t}));\n\t}\n\n\tget commit(): RepoPromiseCacheMap<string, GitCommit | undefined> {\n\t\treturn (this._caches.commit ??= new RepoPromiseCacheMap<string, GitCommit | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 100, // Limit to 100 commits per repo\n\t\t}));\n\t}\n\n\tget commitCount(): RepoPromiseCacheMap<string, number | undefined> {\n\t\treturn (this._caches.commitCount ??= new RepoPromiseCacheMap<string, number | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\tget mergeBase(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.mergeBase ??= new RepoPromiseCacheMap<string, string | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 50,\n\t\t}));\n\t}\n\n\t/**\n\t * Patch IDs keyed by full commit sha (plus `paths` and `verbatim`). A commit's content is immutable, so no\n\t * ref or worktree event can make an entry stale and nothing clears it short of a full cache reset. A cached\n\t * `undefined` is a real answer (a merge commit, or a change that is empty after `paths`). Kept per worktree,\n\t * not per repository, since an ID depends on the attributes of the checkout it was read from. Sized above a range\n\t * read of a couple thousand commits, so one read doesn't evict its own ids before the next.\n\t */\n\tget patchIds(): RepoPromiseCacheMap<string, string | undefined> {\n\t\treturn (this._caches.patchIds ??= new RepoPromiseCacheMap<string, string | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 5000,\n\t\t}));\n\t}\n\n\tget logShas(): RepoPromiseCacheMap<string, string[]> {\n\t\treturn (this._caches.logShas ??= new RepoPromiseCacheMap<string, string[]>({\n\t\t\tcreateTTL: 1000 * 60 * 5, // 5 minutes max age\n\t\t\taccessTTL: 1000 * 30, // 30 seconds if not accessed\n\t\t\tcapacity: 5, // Limit to 5 different ranges per repo\n\t\t}));\n\t}\n\n\tget pausedOperationStatus(): PromiseMap<RepoPath, GitPausedOperationStatus | undefined> {\n\t\treturn (this._caches.pausedOperationStatus ??= new PromiseMap<\n\t\t\tRepoPath,\n\t\t\tGitPausedOperationStatus | undefined\n\t\t>());\n\t}\n\n\tget resolvedRevisions(): RepoPromiseCacheMap<string, ResolvedRevision> {\n\t\treturn (this._caches.resolvedRevisions ??= new RepoPromiseCacheMap<string, ResolvedRevision>({\n\t\t\tcapacity: 100,\n\t\t}));\n\t}\n\n\tget refs(): PromiseMap<RepoPath, RefRecord[]> {\n\t\treturn (this._caches.refs ??= new PromiseMap<RepoPath, RefRecord[]>());\n\t}\n\n\tget refTips(): PromiseMap<RepoPath, GitRefTip[]> {\n\t\treturn (this._caches.refTips ??= new PromiseMap<RepoPath, GitRefTip[]>());\n\t}\n\n\tget reachability(): RepoPromiseCacheMap<string, GitCommitReachability | undefined> {\n\t\treturn (this._caches.reachability ??= new RepoPromiseCacheMap<string, GitCommitReachability | undefined>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t\tcapacity: 25, // Limit to 25 commits per repo\n\t\t}));\n\t}\n\n\tget remotes(): PromiseMap<RepoPath, GitRemote[]> {\n\t\treturn (this._caches.remotes ??= new PromiseMap<RepoPath, GitRemote[]>());\n\t}\n\n\tget stashes(): RepoPromiseCacheMap<string, GitStash> {\n\t\treturn (this._caches.stashes ??= new RepoPromiseCacheMap<string, GitStash>({\n\t\t\taccessTTL: 1000 * 60 * 60, // 60 minutes\n\t\t}));\n\t}\n\n\tget tags(): PromiseMap<RepoPath, PagedResult<GitTag>> {\n\t\treturn (this._caches.tags ??= new PromiseMap<RepoPath, PagedResult<GitTag>>());\n\t}\n\n\tget fileExistence(): RepoPromiseCacheMap<string, boolean> {\n\t\treturn (this._caches.fileExistence ??= new RepoPromiseCacheMap<string, boolean>({\n\t\t\tcreateTTL: 1000 * 10, // 10 seconds\n\t\t\tcapacity: 100,\n\t\t\texpireOnError: true,\n\t\t}));\n\t}\n\n\t// Key: repoPath (not the ignoreRevsFile path) so that per-repo cache resets (clearCaches with repoPath)\n\t// correctly evict the entry. The actual file path is used inside the factory closure in blame.ts.\n\tget ignoreRevsFile(): PromiseCache<string, boolean> {\n\t\treturn (this._caches.ignoreRevsFile ??= new PromiseCache<string, boolean>({\n\t\t\taccessTTL: 1000 * 60 * 60 * 2, // 2 hours\n\t\t\texpireOnError: true,\n\t\t}));\n\t}\n\n\tget trackedPaths(): RepoPromiseCacheMap<string, [string, string] | false> {\n\t\treturn (this._caches.trackedPaths ??= new RepoPromiseCacheMap<string, [string, string] | false>({\n\t\t\tcreateTTL: 1000 * 60, // 60 seconds\n\t\t\taccessTTL: 1000 * 30, // 30 seconds idle\n\t\t\tcapacity: 200,\n\t\t}));\n\t}\n\n\tget worktrees(): PromiseMap<RepoPath, GitWorktree[]> {\n\t\treturn (this._caches.worktrees ??= new PromiseMap<RepoPath, GitWorktree[]>());\n\t}\n\n\t@debug({ onlyExit: true })\n\tclearCaches(repoPath: string | undefined, ...types: CachedGitTypes[]): void {\n\t\tthis.clearCachesCore('share', repoPath, ...types);\n\t}\n\n\t/**\n\t * Hard-evicts the same cache keys {@link clearCaches} would clear for `repoPath`, but a shared\n\t * (commonPath-keyed) entry that is still in flight is deleted outright instead of soft-invalidated —\n\t * a caller after this call never joins a read that started before it. Use for a forced read/write\n\t * that must not be answered from pre-change work; `clearCaches` remains the right call whenever\n\t * letting an in-flight read complete and share its answer with new callers is fine.\n\t */\n\tevictCaches(repoPath: string, ...types: CachedGitTypes[]): void {\n\t\tthis.clearCachesCore('evict', repoPath, ...types);\n\t}\n\n\tprivate clearCachesCore(\n\t\tinFlight: 'share' | 'evict',\n\t\trepoPath: string | undefined,\n\t\t...types: CachedGitTypes[]\n\t): void {\n\t\tconst keysToClear = new Set<keyof AllCaches>();\n\n\t\tif (!types.length) {\n\t\t\t// Clear all caches\n\t\t\tfor (const key of Object.keys(this._caches)) {\n\t\t\t\tkeysToClear.add(key as keyof AllCaches);\n\t\t\t}\n\n\t\t\tinvalidateMemoized('providers');\n\t\t\tthis.incrementStatusGenerations(repoPath);\n\t\t} else {\n\t\t\t// Clear specific cache types\n\t\t\tif (types.includes('blame')) {\n\t\t\t\tkeysToClear.add('blame');\n\t\t\t}\n\t\t\tif (types.includes('diff')) {\n\t\t\t\tkeysToClear.add('diff');\n\t\t\t}\n\t\t\tif (types.includes('fileLog')) {\n\t\t\t\tkeysToClear.add('fileLog');\n\t\t\t}\n\n\t\t\t// Branch caches affected by HEAD/heads changes. `branchMergedStatus` is deliberately NOT\n\t\t\t// cleared here — it's content-keyed on the involved tip shas, so tip movement already\n\t\t\t// self-invalidates (a new key); evicting it here would only discard still-valid answers.\n\t\t\tif (types.includes('branch') || types.includes('branches')) {\n\t\t\t\tkeysToClear.add('branch');\n\t\t\t\tkeysToClear.add('branchOverviews');\n\t\t\t\t// `commit`/`commitCount` are keyed by symbolic ref or SHA — symbolic-ref entries\n\t\t\t\t// can drift when branches move; cascade-clear conservatively.\n\t\t\t\tkeysToClear.add('commit');\n\t\t\t\tkeysToClear.add('commitCount');\n\t\t\t\tkeysToClear.add('conflictDetection');\n\t\t\t\tkeysToClear.add('currentBranchReference');\n\t\t\t\tkeysToClear.add('leftRightCommitCount');\n\t\t\t\t// `mergeBase` keyed by ref-pairs — symbolic refs can move; cascade-clear.\n\t\t\t\tkeysToClear.add('mergeBase');\n\t\t\t\tkeysToClear.add('reachability');\n\t\t\t\tkeysToClear.add('resolvedRevisions');\n\t\t\t}\n\n\t\t\t// Shared branch caches (branch list, metadata). `baseBranchName` is deliberately NOT cleared\n\t\t\t// here — a branch's base is set at creation and only changes when its stored key changes\n\t\t\t// (`gkConfig`/`config` below) or the branch itself is created/renamed/deleted. Every op that\n\t\t\t// does one of those calls `deleteBaseBranchName` and moves or drops the branch's persisted\n\t\t\t// `branch.<ref>.gk-*` keys: `createBranch`/`deleteLocalBranch`/`renameBranch`, plus the two\n\t\t\t// paths that create a branch as a side effect (`checkout -b`, `worktree add -b`). Tip movement\n\t\t\t// can't change a base, so clearing on every commit only forced a `git reflog` re-derivation.\n\t\t\tif (types.includes('branch')) {\n\t\t\t\t// `'branch'` comes from a HEAD change — a checkout — which appends `checkout: moving from X\n\t\t\t\t// to Y` to the reflog, exactly the entry `getBaseBranchName` greps for when nothing is\n\t\t\t\t// stored. A base derived as \"none\" BEFORE that entry existed is cached with no TTL, so\n\t\t\t\t// without this it stays \"none\" for the session even though the answer now exists.\n\t\t\t\t//\n\t\t\t\t// Deliberately not under `'branches'`: a tip move can't change a branch's base, so re-deriving\n\t\t\t\t// on every commit would be pure cost. Checkouts are user-driven and rare by comparison.\n\t\t\t\tkeysToClear.add('baseBranchName');\n\t\t\t}\n\n\t\t\tif (types.includes('branches')) {\n\t\t\t\tkeysToClear.add('branchMetadataMap');\n\t\t\t\tkeysToClear.add('branches');\n\t\t\t\tkeysToClear.add('sharedBranches');\n\t\t\t\tkeysToClear.add('defaultBranchName');\n\t\t\t\tkeysToClear.add('initialCommitSha');\n\t\t\t\tkeysToClear.add('logShas');\n\t\t\t\tkeysToClear.add('refs');\n\t\t\t\tkeysToClear.add('refTips');\n\t\t\t\t// No change type clears `emptyTreeSha`: a repository's object format never changes. A full reset\n\t\t\t\t// (no types) still clears it, along with everything else\n\t\t\t}\n\n\t\t\tif (types.includes('config')) {\n\t\t\t\t// `getBaseBranchName` falls back to `branch.<ref>.vscode-merge-base` (written by VS Code's\n\t\t\t\t// built-in Git), which lives in `.git/config` — so a config change is the only signal that\n\t\t\t\t// source changed. Cheap: config events are rare.\n\t\t\t\tkeysToClear.add('baseBranchName');\n\t\t\t\tkeysToClear.add('configKeys');\n\t\t\t\tkeysToClear.add('configPatterns');\n\t\t\t\tkeysToClear.add('currentBranchReference');\n\t\t\t\tkeysToClear.add('currentUser');\n\t\t\t\t// `gitDir` is immutable repo topology (toplevel/git-dir/common-dir/superproject) — a\n\t\t\t\t// `.git/config` content change never relocates it, and it's owned by the repo lifecycle\n\t\t\t\t// (registerRepoPath/unregisterRepoPath). Clearing it here forced a redundant `git rev-parse`\n\t\t\t\t// re-spawn (gitDir is read by getGkConfigPath→getGitDir on every gk op), so leave it warm.\n\t\t\t}\n\n\t\t\tif (types.includes('contributors')) {\n\t\t\t\tkeysToClear.add('branchOverviews');\n\t\t\t\tkeysToClear.add('contributors');\n\t\t\t\tkeysToClear.add('contributorsLite');\n\t\t\t\tkeysToClear.add('contributorsStats');\n\t\t\t}\n\n\t\t\tif (types.includes('gitignore')) {\n\t\t\t\tkeysToClear.add('gitIgnore');\n\t\t\t}\n\n\t\t\tif (types.includes('gkConfig')) {\n\t\t\t\tkeysToClear.add('gkConfigMap');\n\t\t\t\t// Derived from `branch.<ref>.gk-merge-base`/`vscode-merge-base`; clear so external\n\t\t\t\t// gkConfig mutations don't leave stale base-branch resolutions cached.\n\t\t\t\tkeysToClear.add('baseBranchName');\n\t\t\t\t// Cached overviews are keyed by `${ref}|${mergeTarget}`; bulk gkConfig changes can\n\t\t\t\t// affect any of the merge-target sources (stored, base, default), so clear all.\n\t\t\t\tkeysToClear.add('branchOverviews');\n\t\t\t}\n\n\t\t\tif (types.includes('lastFetched')) {\n\t\t\t\tkeysToClear.add('lastFetched');\n\t\t\t}\n\n\t\t\tif (types.includes('providers')) {\n\t\t\t\tkeysToClear.add('remotes');\n\t\t\t\tkeysToClear.add('bestRemotes');\n\t\t\t\tinvalidateMemoized('providers');\n\t\t\t}\n\n\t\t\tif (types.includes('remotes')) {\n\t\t\t\tkeysToClear.add('remotes');\n\t\t\t\tkeysToClear.add('bestRemotes');\n\t\t\t\tkeysToClear.add('defaultBranchName');\n\t\t\t}\n\n\t\t\tif (types.includes('stashes')) {\n\t\t\t\tkeysToClear.add('stashes');\n\t\t\t}\n\t\t\tif (types.includes('status')) {\n\t\t\t\tkeysToClear.add('pausedOperationStatus');\n\t\t\t\t// A caller asserting \"status changed\" (the post-op hooks in `operations.ts`, a user-initiated\n\t\t\t\t// refresh) has to advance the clock too — otherwise a `git status` still in flight from before\n\t\t\t\t// the operation can satisfy the read that follows it.\n\t\t\t\tthis.incrementStatusGenerations(repoPath);\n\t\t\t}\n\t\t\tif (types.includes('tags')) {\n\t\t\t\tkeysToClear.add('tags');\n\t\t\t\tkeysToClear.add('refs');\n\t\t\t\tkeysToClear.add('refTips');\n\t\t\t\t// `commit`/`commitCount` can be keyed by a tag name (e.g. the tag node's load-more count),\n\t\t\t\t// which re-points on a force-moved or deleted-and-recreated tag — same drift the\n\t\t\t\t// `branch`/`branches` cascade above clears for.\n\t\t\t\tkeysToClear.add('commit');\n\t\t\t\tkeysToClear.add('commitCount');\n\t\t\t\t// Same drift for a tag-named rev, and a `getLogShas` excluding tags lists different commits once a tag moves\n\t\t\t\tkeysToClear.add('logShas');\n\t\t\t\t// Keyed by the revision as given, so a tag name resolves to wherever the tag pointed when first read\n\t\t\t\tkeysToClear.add('resolvedRevisions');\n\t\t\t}\n\n\t\t\tif (types.includes('tracking')) {\n\t\t\t\tkeysToClear.add('fileExistence');\n\t\t\t\tkeysToClear.add('trackedPaths');\n\t\t\t}\n\n\t\t\tif (types.includes('worktrees')) {\n\t\t\t\tkeysToClear.add('worktrees');\n\t\t\t}\n\n\t\t\t// Git results: cleared for any meaningful type change\n\t\t\tif (types.some(t => t !== 'gitignore' && t !== 'gkConfig' && t !== 'providers')) {\n\t\t\t\tkeysToClear.add('gitResults');\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of keysToClear) {\n\t\t\tconst cache = this._caches[key];\n\t\t\tif (cache == null) continue;\n\n\t\t\tif (repoPath == null) {\n\t\t\t\tcache.clear();\n\t\t\t} else if (sharedCacheKeys.has(key)) {\n\t\t\t\tthis.evictShared(key, repoPath, inFlight);\n\t\t\t} else {\n\t\t\t\tcache.delete(repoPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Evicts a single shared (commonPath-keyed) cache entry for `repoPath` and its sibling worktrees.\n\t * When `inFlight` is `'share'` (the default), prefers `invalidate` where supported so in-flight work\n\t * is shared across new callers and self-evicts on settle rather than spawning a duplicate factory.\n\t * `invalidate` does the right thing per-entry: entries with a `CacheController` (created via\n\t * `getOrCreate`) are marked invalidated; entries without one (created via plain `.set()`, e.g.\n\t * per-worktree mapper results) are hard-deleted. Caches that don't support `invalidate` fall back to\n\t * `delete`.\n\t *\n\t * When `inFlight` is `'evict'`, always hard-deletes regardless of `invalidate` support — a new caller\n\t * must never join a read that started before this eviction (see {@link evictCaches}).\n\t */\n\tprivate evictShared(key: keyof AllCaches, repoPath: string, inFlight: 'share' | 'evict' = 'share'): void {\n\t\tconst cache = this._caches[key];\n\t\tif (cache == null) return;\n\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst invalidate =\n\t\t\tinFlight === 'share' ? (cache as { invalidate?: (k: string) => void }).invalidate : undefined;\n\t\tif (typeof invalidate === 'function') {\n\t\t\tinvalidate.call(cache, commonPath);\n\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\tinvalidate.call(cache, worktreePath);\n\t\t\t}\n\t\t} else {\n\t\t\tcache.delete(commonPath);\n\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\tcache.delete(worktreePath);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Monotonic per-worktree counter, advanced whenever anything that can change `git status` output is\n\t * observed. `git status` and its siblings are point-in-time reads of mutable state, so deduplicating them\n\t * on repoPath alone is unsound — a run that started before a commit would satisfy a caller that arrived\n\t * after it. Callers stamp their in-flight run with the generation it started in and refuse older joins.\n\t * Kept per exact worktree path (never spread to the common path) and advanced on `unregisterRepoPath` so a\n\t * read in flight from a prior registration can't be joined after a reopen.\n\t *\n\t * Note: a run that never settles wedges only its own generation's callers (a newer generation gets a fresh\n\t * key). `git.run` recovers via its per-command timeout (default 60s); a hung `git.stream` is caught by the\n\t * status provider's `raceWithTimeout` backstop (scaled to `advanced.git.timeout`; see\n\t * `dedupeByStatusGeneration`), which rejects a wedged read so waiters unblock and a later caller retries.\n\t */\n\tgetStatusGeneration(repoPath: string): number {\n\t\treturn this._statusGenerations.get(repoPath) ?? 0;\n\t}\n\n\t/** Advances the status clock — see {@link getStatusGeneration}. */\n\tincrementStatusGeneration(repoPath: string): void {\n\t\tthis._statusGenerations.set(repoPath, this.getStatusGeneration(repoPath) + 1);\n\t}\n\n\t/**\n\t * Working-tree changes ride their own channel (`Repository.onDidChangeWorkingTree`), not\n\t * `onRepositoryChanged` — an external `git restore <file>` may touch no `.git` path we classify — so\n\t * they have to advance the status clock separately or a discard would never invalidate an in-flight read.\n\t */\n\tonWorkingTreeChanged(repoPath: string): void {\n\t\tthis.incrementStatusGeneration(repoPath);\n\t}\n\n\t/** Advances the status clock for one worktree, or for every known worktree when `repoPath` is undefined. */\n\tprivate incrementStatusGenerations(repoPath: string | undefined): void {\n\t\tif (repoPath != null) {\n\t\t\tthis.incrementStatusGeneration(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\t// Union of registered repos and any path that already carries a generation — a secondary-worktree\n\t\t// path incremented via its own watcher may never have been registered, but still has in-flight reads to fence.\n\t\tconst paths = new Set([...this._commonPathRegistry.keys(), ...this._statusGenerations.keys()]);\n\t\tfor (const path of paths) {\n\t\t\tthis.incrementStatusGeneration(path);\n\t\t}\n\t}\n\n\tgetCommonPath(repoPath: string): string {\n\t\treturn this._commonPathRegistry.get(repoPath) ?? repoPath;\n\t}\n\n\tgetWorktreePaths(commonPath: string): string[] {\n\t\tconst worktrees = this._worktreesByCommonPath.get(commonPath);\n\t\treturn worktrees != null ? [...worktrees] : [];\n\t}\n\n\tisWorktree(repoPath: string): boolean {\n\t\tconst commonPath = this._commonPathRegistry.get(repoPath);\n\t\treturn commonPath != null && commonPath !== repoPath;\n\t}\n\n\t/** Whether `repoPath` is currently registered (via {@link registerRepoPath}, not yet unregistered). */\n\tisRegistered(repoPath: string): boolean {\n\t\treturn this._commonPathRegistry.has(repoPath);\n\t}\n\n\t/**\n\t * Monotonic per-path counter advanced whenever `repoPath` is unregistered (repo closed, worktree\n\t * removed). Lets an async post-read step — e.g. the gk-config reconcile — detect that its target was\n\t * closed (and possibly reopened) mid-flight and bail. Unlike an `isRegistered` check it doesn't\n\t * require the caller to have registered in the first place, so it stays correct for consumers of\n\t * this package that don't wire up the host's repo lifecycle.\n\t */\n\tgetCloseGeneration(repoPath: string): number {\n\t\treturn this._closeGenerations.get(repoPath) ?? 0;\n\t}\n\n\t/** Clears file-scoped caches (blame, diff, fileLog) for a specific path within a repo */\n\tclearForPath(repoPath: string, path: string, ...types: UriScopedCachedGitTypes[]): void {\n\t\tconst prefix = `${normalizePath(path)}:`;\n\t\tif (!types.length || types.includes('blame')) {\n\t\t\tthis._caches.blame?.deleteByKeyPrefix(repoPath, prefix);\n\t\t}\n\t\tif (!types.length || types.includes('diff')) {\n\t\t\tthis._caches.diff?.deleteByKeyPrefix(repoPath, prefix);\n\t\t}\n\t\tif (!types.length || types.includes('fileLog')) {\n\t\t\tthis._caches.fileLog?.deleteByKeyPrefix(repoPath, prefix);\n\t\t}\n\t}\n\n\tregisterRepoPath(repoPath: Uri, gitDir: GitDir): void {\n\t\tconst normalizedPath = getRepositoryOrWorktreePath(repoPath);\n\t\tconst commonPath = gitDir.commonUri != null ? getCommonRepositoryPath(gitDir.commonUri) : normalizedPath;\n\t\tthis._commonPathRegistry.set(normalizedPath, commonPath);\n\n\t\tlet worktrees = this._worktreesByCommonPath.get(commonPath);\n\t\tif (worktrees == null) {\n\t\t\tworktrees = new Set();\n\t\t\tthis._worktreesByCommonPath.set(commonPath, worktrees);\n\t\t}\n\t\tworktrees.add(normalizedPath);\n\t}\n\n\t/**\n\t * Symmetric companion to `registerRepoPath`. Clears cache entries specific to `repoPath`\n\t * and removes the path from the registry.\n\t *\n\t * Call this when a worktree is deleted or a repo is closed so stale registry entries\n\t * and derived cache entries don't persist.\n\t *\n\t * Targeted — does NOT cascade to sibling worktrees sharing the same commonPath. The\n\t * shared commonPath entry in each shared cache is only evicted when unregistering the\n\t * last remaining worktree for that commonPath (otherwise siblings still depend on it).\n\t *\n\t * Uses soft-invalidate where supported so any in-flight factory/mapper keeps its abort\n\t * wiring intact — a caller whose signal aborts after unregister can still propagate\n\t * cancellation into the underlying work rather than leaving it orphaned. Controller-backed\n\t * entries self-evict on settle; plain `.set()`-based entries hard-delete immediately.\n\t *\n\t * Cache eviction is a no-op if `repoPath` is not registered, but the status clock is advanced\n\t * unconditionally (a fresh registration must not let a post-reopen read join a pre-close one).\n\t */\n\t@debug({ onlyExit: true })\n\tunregisterRepoPath(repoPath: string): void {\n\t\t// Advance the status clock on close so a status read still in flight from this registration can't be\n\t\t// joined by a read issued after the path is reopened (which would otherwise reuse the same generation).\n\t\tthis.incrementStatusGeneration(repoPath);\n\t\t// Advance the close clock so an async step that captured it before its read (see `getCloseGeneration`)\n\t\t// can tell its target went away mid-flight.\n\t\tthis._closeGenerations.set(repoPath, this.getCloseGeneration(repoPath) + 1);\n\n\t\tconst commonPath = this._commonPathRegistry.get(repoPath) ?? repoPath;\n\t\tconst worktrees = this._worktreesByCommonPath.get(commonPath);\n\t\t// After removing repoPath, would the commonPath have any worktrees left?\n\t\tconst isLastWorktree = worktrees == null || worktrees.size <= 1;\n\n\t\t// Targeted per-repoPath cleanup: for per-worktree caches, clear this repoPath's\n\t\t// entries. For shared caches, clear this repoPath's mapper entry (if it's a worktree\n\t\t// distinct from commonPath); only evict the shared commonPath entry when this was the\n\t\t// last worktree — otherwise siblings still rely on the shared data.\n\t\tfor (const key of Object.keys(this._caches) as (keyof AllCaches)[]) {\n\t\t\tconst cache = this._caches[key];\n\t\t\tif (cache == null) continue;\n\n\t\t\t// Prefer `invalidate` so in-flight abort wiring survives until the factory settles;\n\t\t\t// fall back to `delete` for plain `Map`-typed caches that don't track promises.\n\t\t\tconst invalidate = (cache as { invalidate?: (k: string) => void }).invalidate;\n\t\t\tconst evict =\n\t\t\t\ttypeof invalidate === 'function'\n\t\t\t\t\t? (k: string) => invalidate.call(cache, k)\n\t\t\t\t\t: (k: string) => cache.delete(k);\n\n\t\t\tif (sharedCacheKeys.has(key)) {\n\t\t\t\tif (repoPath !== commonPath) {\n\t\t\t\t\tevict(repoPath);\n\t\t\t\t}\n\t\t\t\tif (isLastWorktree) {\n\t\t\t\t\tevict(commonPath);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tevict(repoPath);\n\t\t\t}\n\t\t}\n\n\t\t// Shared, commonPath-keyed like `gkConfigMap` — only evict once no worktree still depends on it.\n\t\tif (isLastWorktree) {\n\t\t\tthis._gkConfigMergeSnapshots.delete(commonPath);\n\t\t}\n\n\t\tthis._commonPathRegistry.delete(repoPath);\n\n\t\tif (worktrees != null) {\n\t\t\tworktrees.delete(repoPath);\n\t\t\tif (worktrees.size === 0) {\n\t\t\t\tthis._worktreesByCommonPath.delete(commonPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t@debug({ onlyExit: true })\n\treset(): void {\n\t\t// Advance the close clock BEFORE dropping the registry it reads from. Advancing rather than\n\t\t// clearing is the point: an async step that captured a generation must see a mismatch and bail,\n\t\t// where a cleared map would hand it a fresh `0` that matches and let it repopulate what was just\n\t\t// torn down. Union of registered paths and any already carrying a generation, mirroring\n\t\t// `incrementStatusGenerations`.\n\t\tfor (const path of new Set([...this._commonPathRegistry.keys(), ...this._closeGenerations.keys()])) {\n\t\t\tthis._closeGenerations.set(path, this.getCloseGeneration(path) + 1);\n\t\t}\n\n\t\tthis._commonPathRegistry.clear();\n\t\tthis._worktreesByCommonPath.clear();\n\t\tthis._statusGenerations.clear();\n\t\tthis._gkConfigMergeSnapshots.clear();\n\t\tthis._gkConfigReconciler = undefined;\n\t\tthis._caches = createEmptyCaches();\n\t}\n\n\t/** Applies a watcher-observed change, sharing reads still in flight (see {@link applyRepositoryChanges}). */\n\t@debug({ onlyExit: true })\n\tonRepositoryChanged(repoPath: string, changes: Iterable<RepositoryChange>): void {\n\t\tconst changesSet = new Set(changes);\n\t\tif (changesSet.has('unknown') || changesSet.has('closed')) {\n\t\t\tthis.unregisterRepoPath(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.applyRepositoryChanges(repoPath, changesSet, 'share');\n\t}\n\n\t/**\n\t * Clears what `changes` can have made stale for `repoPath`, advances its status clock, and reconciles a\n\t * `'gkConfig'` change, returning the cache types it cleared. `inFlight` is as {@link clearCaches}\n\t * (`'share'`) vs {@link evictCaches} (`'evict'`). `'unknown'` and `'closed'` map to nothing here: the\n\t * watcher unregisters the path on them, and an announced write resets everything instead.\n\t */\n\t@debug({ onlyExit: true })\n\tapplyRepositoryChanges(\n\t\trepoPath: string,\n\t\tchanges: Iterable<RepositoryChange>,\n\t\tinFlight: 'share' | 'evict',\n\t): CachedGitTypes[] {\n\t\tconst changesSet = new Set(changes);\n\n\t\tconst hasAny = (...c: RepositoryChange[]) => c.some(ch => changesSet.has(ch));\n\n\t\t// Advance the status clock (see {@link getStatusGeneration}) for changes that alter `git status` output but\n\t\t// aren't mapped to the `'status'` cache type below: files (index/head/heads), untracked set (ignores/config),\n\t\t// ahead/behind (remotes). Paused-op changes advance it too, but via `clearCaches('status')` (see below) —\n\t\t// listing them here as well would double-increment the clock for a single change.\n\t\tif (hasAny('index', 'head', 'heads', 'remotes', 'ignores', 'config')) {\n\t\t\tthis.incrementStatusGeneration(repoPath);\n\t\t}\n\n\t\tconst types = new Set<CachedGitTypes>();\n\n\t\tif (hasAny('head')) {\n\t\t\ttypes.add('branch');\n\t\t}\n\n\t\tif (hasAny('index', 'heads', 'pausedOp')) {\n\t\t\ttypes.add('blame');\n\t\t\ttypes.add('diff');\n\t\t\ttypes.add('fileLog');\n\t\t}\n\n\t\tif (hasAny('index')) {\n\t\t\ttypes.add('tracking');\n\t\t}\n\n\t\tif (hasAny('config')) {\n\t\t\ttypes.add('config');\n\t\t}\n\n\t\tif (hasAny('heads')) {\n\t\t\ttypes.add('branches');\n\t\t\ttypes.add('contributors');\n\t\t\ttypes.add('worktrees');\n\t\t}\n\n\t\tif (hasAny('remotes')) {\n\t\t\ttypes.add('branches');\n\t\t\ttypes.add('contributors');\n\t\t\ttypes.add('remotes');\n\t\t\ttypes.add('worktrees');\n\t\t}\n\n\t\tif (hasAny('ignores')) {\n\t\t\ttypes.add('gitignore');\n\t\t}\n\n\t\tif (hasAny('gkConfig')) {\n\t\t\t// Handled separately (not folded into `types`/`clearCaches` below) — a gk write is usually a\n\t\t\t// bookkeeping timestamp that can't affect `baseBranchName`/`branchOverviews`, so this reconciles\n\t\t\t// down to only the keys that actually changed instead of coarsely clearing both on every write.\n\t\t\tthis.handleGkConfigChanged(repoPath);\n\t\t}\n\n\t\tif (hasAny('lastFetched')) {\n\t\t\ttypes.add('lastFetched');\n\t\t}\n\n\t\tif (hasAny('remoteProviders')) {\n\t\t\ttypes.add('providers');\n\t\t}\n\n\t\tif (hasAny('cherryPick', 'merge', 'rebase', 'revert', 'pausedOp')) {\n\t\t\ttypes.add('branch');\n\t\t\ttypes.add('status');\n\t\t}\n\n\t\tif (hasAny('stash')) {\n\t\t\ttypes.add('stashes');\n\t\t}\n\n\t\tif (hasAny('tags')) {\n\t\t\ttypes.add('tags');\n\t\t}\n\n\t\tif (hasAny('worktrees')) {\n\t\t\ttypes.add('worktrees');\n\t\t}\n\n\t\tif (types.size) {\n\t\t\tthis.clearCachesCore(inFlight, repoPath, ...types);\n\t\t}\n\t\treturn [...types];\n\t}\n\n\t/**\n\t * Handles a watcher-observed `'gkConfig'` change. Always evicts the cached bulk map (forcing the\n\t * next read to hit disk). If a reconciler is registered (see {@link setGkConfigReconciler}),\n\t * defers to it instead of coarsely clearing `baseBranchName`/`branchOverviews` — it re-reads the\n\t * map and diffs it against the snapshot captured here (i.e. as it stood right before this change),\n\t * cascading only the refs whose merge-relevant keys actually changed. Falls back to the coarse\n\t * clear when no reconciler is registered (e.g. the GitHub provider) so nothing can go stale.\n\t */\n\tprivate handleGkConfigChanged(repoPath: string): void {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\t// Hard-delete rather than `evictShared`'s soft-invalidate: the reconcile below needs a\n\t\t// point-in-time read of the post-change file, and a soft-invalidated entry stays joinable — the\n\t\t// re-read would ride a bulk read that started before this change and diff it as unchanged.\n\t\t// Same reasoning as `refs.ts`'s `force: true` path and `deleteGkConfig`'s own hard delete.\n\t\tthis._caches.gkConfigMap?.delete(commonPath);\n\n\t\tif (this._gkConfigReconciler == null) {\n\t\t\tthis.clearGkConfigCoarsely(repoPath);\n\t\t\treturn;\n\t\t}\n\n\t\tconst priorSnapshot = this._gkConfigMergeSnapshots.get(commonPath);\n\t\t// Fire-and-forget, but the outcome still decides whether the coarse clear is owed: a reconcile that\n\t\t// FAILED leaves every derived cache holding pre-change values with nothing else to correct them, so\n\t\t// it falls back to the blunt behavior that registering a reconciler replaced. Kept here rather than\n\t\t// in the reconciler so a bail path added later can't silently skip it — the return type makes each\n\t\t// one say what it did.\n\t\tvoid Promise.resolve(this._gkConfigReconciler(repoPath, priorSnapshot)).then(\n\t\t\toutcome => {\n\t\t\t\tif (outcome === 'failed') {\n\t\t\t\t\tthis.clearGkConfigCoarsely(repoPath);\n\t\t\t\t}\n\t\t\t},\n\t\t\t// An exception escaping the reconciler is a failure by definition — and one its own `catch`\n\t\t\t// never saw, so nothing else will have cascaded.\n\t\t\t() => this.clearGkConfigCoarsely(repoPath),\n\t\t);\n\t}\n\n\t/** The coarse fallback: every derived merge cache is cleared, so any branch's merge targets may have changed */\n\tprivate clearGkConfigCoarsely(repoPath: string): void {\n\t\tthis.clearCaches(repoPath, 'gkConfig');\n\t\tthis._onDidChangeMergeTargets.fire({ repoPath: this.getCommonPath(repoPath), refs: undefined });\n\t}\n\n\t/** Hard-evicts the cached bulk `.git/gk/config` map so the next read hits disk. */\n\tdeleteGkConfigMap(repoPath: string): void {\n\t\tthis._caches.gkConfigMap?.delete(this.getCommonPath(repoPath));\n\t}\n\n\t/** The merge-relevant gk config snapshot currently serving as the reconcile baseline. */\n\tgetGkConfigMergeSnapshot(repoPath: string): ReadonlyMap<string, string> | undefined {\n\t\treturn this._gkConfigMergeSnapshots.get(this.getCommonPath(repoPath));\n\t}\n\n\tgetBranches(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<PagedResult<GitBranch>>,\n\t\tmapper: (\n\t\t\tbranches: PagedResult<GitBranch>,\n\t\t\ttargetRepoPath: string,\n\t\t\tcommonPath: string,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<PagedResult<GitBranch>>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitBranch>> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\t// Register this caller with the shared factory's aggregate so that invariant 3\n\t\t// (factory aborts iff every waiter has aborted) holds for same-`repoPath` cache hits too.\n\t\t// The returned wrapped promise is deliberately discarded — we use the raw cached inner\n\t\t// below to build the mapped entry. Swallow any rejection on this dangling reference so\n\t\t// it doesn't surface as an unhandled rejection; the real caller-facing promise (via\n\t\t// `branches.getOrCreate` below) is where caller cancellation flows to.\n\t\tconst registration = this.sharedBranches.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => {\n\t\t\t\tconst p = Promise.resolve(factory(commonPath, cacheable, signal));\n\t\t\t\t// On factory invalidation, propagate to the derived per-worktree mapper entries\n\t\t\t\t// via soft-invalidate — existing waiters on the mapper complete, and the entry\n\t\t\t\t// self-evicts on mapper settle so the next callers build fresh derived entries.\n\t\t\t\tvoid p\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (cacheable.invalidated) {\n\t\t\t\t\t\t\tthis.branches.invalidate(commonPath);\n\t\t\t\t\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\t\t\t\t\tthis.branches.invalidate(worktreePath);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t// Swallow the cleanup chain's rejection so a rejected factory (e.g. cancellation)\n\t\t\t\t\t// doesn't surface as an unhandled rejection; the caller-facing promise handles it.\n\t\t\t\t\t.catch(() => {});\n\t\t\t\treturn p;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t\tvoid registration.catch(() => {});\n\n\t\t// Build the per-`repoPath` mapped entry through `getOrCreate` so mapper internal git\n\t\t// work (e.g. `getCurrentBranchReferenceCore`) runs under a mapper-level aggregate signal\n\t\t// separate from the factory's. Subsequent same-`repoPath` cache hits register with this\n\t\t// aggregate too — invariant 2/3 hold at the mapper level.\n\t\treturn this.branches.getOrCreate(\n\t\t\trepoPath,\n\t\t\t(_cacheable, mapperSignal) => {\n\t\t\t\t// After `getOrCreate` above, `sharedBranches[commonPath]` holds the raw inner\n\t\t\t\t// factory promise. Fall back to `registration` in the paranoid case where a\n\t\t\t\t// synchronously-rejected factory got auto-evicted before we retrieve it.\n\t\t\t\tconst rawShared = this.sharedBranches.get(commonPath) ?? registration;\n\t\t\t\treturn Promise.resolve(rawShared).then(shared => mapper(shared, repoPath, commonPath, mapperSignal));\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate static readonly globalConfigKey = '';\n\n\tgetConfig(\n\t\trepoPath: string | undefined,\n\t\tkey: string,\n\t\tfactory: () => PromiseOrValue<string | undefined>,\n\t): Promise<string | undefined> {\n\t\tconst cacheKey = repoPath != null ? this.getCommonPath(repoPath) : Cache.globalConfigKey;\n\n\t\tconst result = this.configKeys.get(cacheKey, key);\n\t\tif (result != null) return result;\n\n\t\tconst factoryPromise = Promise.resolve(factory());\n\t\tthis.configKeys.set(cacheKey, key, factoryPromise);\n\t\treturn factoryPromise;\n\t}\n\n\tgetConfigRegex(\n\t\trepoPath: string | undefined,\n\t\tpattern: string,\n\t\tfactory: () => PromiseOrValue<Map<string, string>>,\n\t): Promise<Map<string, string>> {\n\t\tconst cacheKey = repoPath != null ? this.getCommonPath(repoPath) : Cache.globalConfigKey;\n\n\t\tconst result = this.configPatterns.get(cacheKey, pattern);\n\t\tif (result != null) return result;\n\n\t\tconst factoryPromise = Promise.resolve(factory());\n\t\tthis.configPatterns.set(cacheKey, pattern, factoryPromise);\n\t\treturn factoryPromise;\n\t}\n\n\tdeleteConfig(repoPath: string | undefined, key: string): void {\n\t\tconst cacheKey = repoPath != null ? this.getCommonPath(repoPath) : Cache.globalConfigKey;\n\t\tthis._caches.configKeys?.delete(cacheKey, key);\n\t\tthis._caches.configPatterns?.delete(cacheKey);\n\t}\n\n\t/**\n\t * The whole `.git/gk/config` is read once and cached as a single map per commonPath; per-key and\n\t * per-namespace gk lookups are served from it in-memory (see `getGkConfigMap` in the CLI config\n\t * sub-provider). Invalidated by `deleteGkConfig` (write) and, on a watcher `'gkConfig'` event, by\n\t * `handleGkConfigChanged` (reconciled precisely when a reconciler is registered, or the coarse\n\t * clear otherwise). The first fresh read seeds the merge-relevant snapshot used by\n\t * `reconcileGkConfigMap`; later refreshes of that snapshot are owned by the reconcile itself.\n\t */\n\tgetGkConfigMap(\n\t\trepoPath: string,\n\t\tfactory: (cacheable: CacheController) => PromiseOrValue<Map<string, string>>,\n\t): Promise<Map<string, string>> {\n\t\treturn this.getSharedSimple(this.gkConfigMap, repoPath, async (commonPath, cacheable) => {\n\t\t\tconst map = await factory(cacheable);\n\t\t\t// Seed the reconcile baseline on first observation only. Refreshes belong to\n\t\t\t// `reconcileGkConfigMap` (after it has cascaded) and `recordGkConfigWrite` (our own writes):\n\t\t\t// an incidental read that happens to land between an external write and the watcher event\n\t\t\t// would otherwise advance the baseline to the post-change value, so the reconcile would diff\n\t\t\t// that value against itself and silently drop the change.\n\t\t\tif (!this._gkConfigMergeSnapshots.has(commonPath)) {\n\t\t\t\tthis._gkConfigMergeSnapshots.set(commonPath, this.extractMergeRelevantGkConfig(map));\n\t\t\t}\n\t\t\treturn map;\n\t\t});\n\t}\n\n\t/** Extracts the subset of a gk config map whose keys participate in the `branchOverviews`/`baseBranchName` lineage. */\n\tprivate extractMergeRelevantGkConfig(map: ReadonlyMap<string, string>): Map<string, string> {\n\t\tconst subset = new Map<string, string>();\n\t\tfor (const [key, value] of map) {\n\t\t\tif (branchOverviewGkConfigKeysRegex.test(key)) {\n\t\t\t\tsubset.set(key, value);\n\t\t\t}\n\t\t}\n\t\treturn subset;\n\t}\n\n\t/**\n\t * Clears the cached `.git/gk/config` map and invalidates the derived caches\n\t * (`baseBranchName`/`branchOverviews`) for the written key's ref.\n\t *\n\t * @param options.skipInvalidation Downstream caches the caller wants preserved despite this\n\t * write. Use when the value being written is exactly what was just resolved — e.g. the Tier 2\n\t * `storeMergeTargetBranchName` self-write inside `getBranchContributionsOverview` (skip\n\t * `'branchOverviews'`) or the Tier 3 `storeBaseBranchName` self-write inside `getBaseBranchName`\n\t * (skip both `'baseBranchName'` and `'branchOverviews'`). The bulk `gkConfigMap` map always\n\t * invalidates so subsequent reads see the new value.\n\t */\n\tdeleteGkConfig(\n\t\trepoPath: string,\n\t\tkey: string,\n\t\toptions?: { skipInvalidation?: readonly GkConfigInvalidationTarget[] },\n\t): void {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tthis._caches.gkConfigMap?.delete(commonPath);\n\t\tthis.cascadeGkConfigKeyChange(commonPath, key, options?.skipInvalidation);\n\t}\n\n\t/**\n\t * Keeps the merge-relevant gk config snapshot in sync with OUR OWN writes, so the next\n\t * watcher-triggered `reconcileGkConfigMap` diffs a self-write as unchanged rather than as an\n\t * external change (which would otherwise defeat `skipInvalidation`). No-ops for keys outside the\n\t * merge-relevant subset, and if no snapshot exists yet for this repo — nothing to keep in sync;\n\t * the next real read (`getGkConfigMap`) populates one from scratch.\n\t */\n\trecordGkConfigWrite(repoPath: string, key: string, value: string | undefined): void {\n\t\tif (!branchOverviewGkConfigKeysRegex.test(key)) return;\n\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst snapshot = this._gkConfigMergeSnapshots.get(commonPath);\n\t\tif (snapshot == null) return;\n\n\t\t// Copy-on-write: a reconcile in flight is holding this map as its `priorSnapshot` baseline, so\n\t\t// mutating it in place would silently move that baseline mid-diff.\n\t\tconst next = new Map(snapshot);\n\t\tif (value == null) {\n\t\t\tnext.delete(key);\n\t\t} else {\n\t\t\tnext.set(key, value);\n\t\t}\n\t\tthis._gkConfigMergeSnapshots.set(commonPath, next);\n\t}\n\n\t/**\n\t * {@link recordGkConfigWrite} for a whole `branch.<ref>` section: our own `--remove-section` (a branch delete) or\n\t * `--rename-section` (a branch rename, to `renamedTo`), so the reconcile that follows doesn't report it as an\n\t * external merge-target change.\n\t */\n\trecordGkConfigSectionWrite(repoPath: string, ref: string, renamedTo?: string): void {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst snapshot = this._gkConfigMergeSnapshots.get(commonPath);\n\t\tif (snapshot == null) return;\n\n\t\tconst prefixLength = `branch.${ref}.`.length;\n\t\t// Copy-on-write, as in `recordGkConfigWrite`\n\t\tconst next = new Map<string, string>();\n\t\tfor (const [key, value] of snapshot) {\n\t\t\t// Matched on the captured ref, not a `branch.<ref>.` prefix, which would also take a dotted sibling\n\t\t\t// (`branch.feature.x.*` for `feature`) that `--remove-section`/`--rename-section` leaves in place\n\t\t\tif (branchOverviewGkConfigKeysRegex.exec(key)?.[1] !== ref) {\n\t\t\t\tnext.set(key, value);\n\t\t\t} else if (renamedTo != null) {\n\t\t\t\tnext.set(`branch.${renamedTo}.${key.substring(prefixLength)}`, value);\n\t\t\t}\n\t\t}\n\t\tthis._gkConfigMergeSnapshots.set(commonPath, next);\n\t}\n\n\t/**\n\t * Registers the reconciler invoked by {@link handleGkConfigChanged} on a watcher-observed\n\t * `'gkConfig'` change. Only one reconciler is kept — later registrations replace earlier ones,\n\t * which is harmless since every CLI config sub-provider sharing this `Cache` reconciles the same\n\t * underlying `.git/gk/config` file identically.\n\t */\n\tsetGkConfigReconciler(\n\t\treconciler: (\n\t\t\trepoPath: string,\n\t\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\t) => PromiseOrValue<GkReconcileOutcome>,\n\t): void {\n\t\tthis._gkConfigReconciler = reconciler;\n\t}\n\n\t/**\n\t * Diffs a freshly-read gk config map's merge-relevant subset against `priorSnapshot` (captured by\n\t * `handleGkConfigChanged` before the reconcile started, so it reflects the pre-change state even\n\t * though this call's own re-read already raced ahead and refreshed the live snapshot), cascading\n\t * `baseBranchName`/`branchOverviews` for every ref whose merge-relevant key actually changed, then firing\n\t * {@link onDidChangeMergeTargets} naming those refs.\n\t * `priorSnapshot` of `undefined` (never observed before this reconcile) is treated as \"everything\n\t * may have changed\" — a full coarse clear, same as the pre-existing watcher behavior. Returns\n\t * whether anything changed (i.e. whether a follow-up repository-changed event is warranted).\n\t */\n\treconcileGkConfigMap(\n\t\trepoPath: string,\n\t\tpriorSnapshot: ReadonlyMap<string, string> | undefined,\n\t\tfreshMap: ReadonlyMap<string, string>,\n\t): boolean {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst newSubset = this.extractMergeRelevantGkConfig(freshMap);\n\t\tthis._gkConfigMergeSnapshots.set(commonPath, newSubset);\n\n\t\tif (priorSnapshot == null) {\n\t\t\tthis.evictShared('baseBranchName', repoPath);\n\t\t\tthis.evictShared('branchOverviews', repoPath);\n\t\t\tthis._onDidChangeMergeTargets.fire({ repoPath: commonPath, refs: undefined });\n\t\t\treturn true;\n\t\t}\n\n\t\tlet refs: Set<string> | undefined;\n\t\tfor (const key of new Set([...priorSnapshot.keys(), ...newSubset.keys()])) {\n\t\t\tif (priorSnapshot.get(key) !== newSubset.get(key)) {\n\t\t\t\tthis.cascadeGkConfigKeyChange(commonPath, key);\n\n\t\t\t\tconst ref = branchOverviewGkConfigKeysRegex.exec(key)?.[1];\n\t\t\t\tif (ref != null) {\n\t\t\t\t\t(refs ??= new Set()).add(ref);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (refs == null) return false;\n\n\t\tthis._onDidChangeMergeTargets.fire({ repoPath: commonPath, refs: refs });\n\t\treturn true;\n\t}\n\n\t/**\n\t * Shared per-ref cascade for a changed `branch.<ref>.gk-...` key: invalidates `baseBranchName` (for\n\t * `gk-merge-base`) and `branchOverviews` (for any merge-relevant key), honoring `skipInvalidation`.\n\t * Used by both a direct write (`deleteGkConfig`) and a reconciled external change\n\t * (`reconcileGkConfigMap`). No-ops for keys outside the merge-relevant subset.\n\t */\n\tprivate cascadeGkConfigKeyChange(\n\t\tcommonPath: string,\n\t\tkey: string,\n\t\tskip?: readonly GkConfigInvalidationTarget[],\n\t): void {\n\t\tconst refMatch = key.match(branchOverviewGkConfigKeysRegex);\n\t\tif (refMatch == null) return;\n\n\t\tconst ref = refMatch[1];\n\n\t\t// `getBaseBranchName` reads `branch.<ref>.gk-merge-base` and caches the resolved value\n\t\t// per-ref. A change to that key must invalidate the cached base or Tier 3 of\n\t\t// `getBranchContributionsOverview` will resolve `mergeTarget` against the pre-change value.\n\t\tif (key.endsWith('.gk-merge-base') && !skip?.includes('baseBranchName')) {\n\t\t\tthis._caches.baseBranchName?.delete(commonPath, ref);\n\t\t}\n\n\t\tif (skip?.includes('branchOverviews')) return;\n\n\t\t// When the change affects a branch's merge-target/base lineage, invalidate that branch's\n\t\t// cached overviews so subsequent reads pick up the new stored value rather than stale data.\n\t\t// `getBranchContributionsOverview` keys `branchOverviews` by `${ref}|${mergeTarget}`, so\n\t\t// invalidate every entry for the affected ref regardless of which target it resolved to.\n\t\t// Uses `invalidateByKeyPrefix` (not `deleteByKeyPrefix`) so an in-flight factory is still\n\t\t// shared with new callers instead of triggering a duplicate fetch.\n\t\t//\n\t\t// Sibling worktrees get their own bucket, not just the shared one: `getSharedOrCreateWithKey`\n\t\t// stores a per-worktree *mapped* entry under that worktree's own path, and prefix-invalidation\n\t\t// only reaches one bucket. The in-flight case self-propagates on settle, but an already-settled\n\t\t// overview would otherwise survive here — which the coarse `evictShared` path this replaced did\n\t\t// clear, since it iterated the worktrees.\n\t\tthis._caches.branchOverviews?.invalidateByKeyPrefix(commonPath, `${ref}|`);\n\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\tthis._caches.branchOverviews?.invalidateByKeyPrefix(worktreePath, `${ref}|`);\n\t\t}\n\t}\n\n\tasync getBranchOverview(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<BranchContributionsOverview | undefined>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<BranchContributionsOverview | undefined> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.branchOverviews,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) =>\n\t\t\t\tdata == null\n\t\t\t\t\t? data\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\trepoPath: newRepoPath,\n\t\t\t\t\t\t\tcontributors: data.contributors.map(c => c.withRepoPath(newRepoPath)),\n\t\t\t\t\t\t},\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync getContributors(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitContributorsResult>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitContributorsResult> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.contributors,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => ({\n\t\t\t\t...data,\n\t\t\t\tcontributors: data.contributors.map(c => c.withRepoPath(newRepoPath)),\n\t\t\t}),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync getContributorsLite(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitContributor[]>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitContributor[]> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.contributorsLite,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => data.map(c => c.withRepoPath(newRepoPath)),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tgetContributorsStats(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitContributorsStats | undefined>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitContributorsStats | undefined> {\n\t\treturn this.getSharedSimpleWithKey(this.contributorsStats, repoPath, cacheKey, factory, options);\n\t}\n\n\tgetBaseBranchName(\n\t\trepoPath: string,\n\t\tref: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<string | undefined>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\treturn this.getSharedSimpleWithKey(this.baseBranchName, repoPath, ref, factory, {\n\t\t\t// A bounded ceiling, because the eviction signals can't cover every way a base changes. The\n\t\t\t// `'branches'` cascade deliberately doesn't clear this — a tip move can't change a base, and\n\t\t\t// re-deriving per commit is the cost this exists to avoid — but that leaves a hole: a branch\n\t\t\t// deleted and recreated OUTSIDE GitLens, and never checked out, emits only `heads`. A base\n\t\t\t// derived as \"none\" before that would otherwise stay \"none\" for the session.\n\t\t\t//\n\t\t\t// `createTTL`, NOT `accessTTL`: the sliding variant resets on every read, so a branch card\n\t\t\t// polling this entry would hold it alive forever and never re-derive — the exact case the\n\t\t\t// ceiling exists for. Absolute from creation bounds staleness regardless of read frequency.\n\t\t\tcreateTTL: baseBranchNameTTL,\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t/**\n\t * Clears the cached base branch for `ref`. Call from ops that create/rename/delete a branch — the\n\t * `'branches'` cascade no longer clears these, since tip movement can't change a branch's base.\n\t *\n\t * Only clears the cache. A branch's base is *persisted* as `branch.<ref>.gk-merge-base` and read back\n\t * before the reflog fallback, so an op that ends a branch's identity under a name must drop or move\n\t * that key too (`removeGkConfigBranchSection`/`renameGkConfigBranchSection`) — otherwise the\n\t * re-derivation this triggers just reads the stale value straight back.\n\t */\n\tdeleteBaseBranchName(repoPath: string, ref: string): void {\n\t\tthis._caches.baseBranchName?.delete(this.getCommonPath(repoPath), ref);\n\t}\n\n\tgetBranchMergedStatus(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitBranchMergedStatus>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitBranchMergedStatus> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.branchMergedStatus,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => {\n\t\t\t\tif (!data.merged) return data;\n\t\t\t\tif (data.localBranchOnly == null) return data;\n\n\t\t\t\tconst lbo = data.localBranchOnly;\n\t\t\t\treturn {\n\t\t\t\t\t...data,\n\t\t\t\t\tlocalBranchOnly: createReference(lbo.ref, newRepoPath, {\n\t\t\t\t\t\tid: getBranchId(newRepoPath, lbo.remote, lbo.name),\n\t\t\t\t\t\trefType: 'branch',\n\t\t\t\t\t\tname: lbo.name,\n\t\t\t\t\t\tremote: lbo.remote,\n\t\t\t\t\t\tupstream: lbo.upstream,\n\t\t\t\t\t\tsha: lbo.sha,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t},\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tgetBranchMetadataMap(\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string) => PromiseOrValue<Map<string, BranchMetadata>>,\n\t): Promise<Map<string, BranchMetadata>> {\n\t\treturn this.getSharedSimple(this.branchMetadataMap, repoPath, factory);\n\t}\n\n\tgetDefaultBranchName(\n\t\trepoPath: string,\n\t\tremote: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<string | undefined>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string | undefined> {\n\t\treturn this.getSharedSimpleWithKey(this.defaultBranchName, repoPath, remote, factory, {\n\t\t\tcancellation: cancellation,\n\t\t});\n\t}\n\n\t/** Clears the cached default branch for one `remote` key (the networked lookup or its `:local` variant). */\n\tdeleteDefaultBranchName(repoPath: string, remote: string): void {\n\t\tthis._caches.defaultBranchName?.delete(this.getCommonPath(repoPath), remote);\n\t}\n\n\tgetInitialCommitSha(\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string) => PromiseOrValue<string | undefined>,\n\t): Promise<string | undefined> {\n\t\treturn this.getSharedSimple(this.initialCommitSha, repoPath, factory);\n\t}\n\n\t/** A rejected factory is never cached (`PromiseMap` evicts on rejection) — a failed read retries next time. */\n\tgetEmptyTreeSha(repoPath: string, factory: (commonPath: string) => PromiseOrValue<string>): Promise<string> {\n\t\treturn this.getSharedSimple(this.emptyTreeSha, repoPath, factory);\n\t}\n\n\tgetLastFetchedTimestamp(\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string) => PromiseOrValue<number | undefined>,\n\t): Promise<number | undefined> {\n\t\treturn this.getSharedSimple(this.lastFetched, repoPath, factory);\n\t}\n\n\tgetRefs(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<RefRecord[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RefRecord[]> {\n\t\t// Raw ref records are repoPath-agnostic (no per-worktree binding to remap), so we key only\n\t\t// by commonPath and skip the per-worktree mapper that `getBranches`/`getTags` need.\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\treturn this.refs.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => Promise.resolve(factory(commonPath, cacheable, signal)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tgetRefTips(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitRefTip[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRefTip[]> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\treturn this.refTips.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => Promise.resolve(factory(commonPath, cacheable, signal)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tasync getRemotes(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitRemote[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote[]> {\n\t\treturn this.getSharedOrCreate(\n\t\t\tthis.remotes,\n\t\t\trepoPath,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => data.map(r => r.withRepoPath(newRepoPath)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tasync getStash(\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitStash>,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<GitStash> {\n\t\treturn this.getSharedOrCreateWithKey(\n\t\t\tthis.stashes,\n\t\t\trepoPath,\n\t\t\tcacheKey,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => ({\n\t\t\t\trepoPath: newRepoPath,\n\t\t\t\tstashes: new Map(\n\t\t\t\t\tArray.from(data.stashes.entries(), ([sha, s]) => [\n\t\t\t\t\t\tsha,\n\t\t\t\t\t\ts.withRepoPath<GitStashCommit>(newRepoPath),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t}),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync getTags(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<PagedResult<GitTag>>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PagedResult<GitTag>> {\n\t\treturn this.getSharedOrCreate(\n\t\t\tthis.tags,\n\t\t\trepoPath,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => ({ ...data, values: data.values.map(t => t.withRepoPath(newRepoPath)) }),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tasync getWorktrees(\n\t\trepoPath: string,\n\t\tfactory: (\n\t\t\tcommonPath: string,\n\t\t\tcacheable: CacheController,\n\t\t\tcancellation?: AbortSignal,\n\t\t) => PromiseOrValue<GitWorktree[]>,\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitWorktree[]> {\n\t\treturn this.getSharedOrCreate(\n\t\t\tthis.worktrees,\n\t\t\trepoPath,\n\t\t\tfactory,\n\t\t\t(data, newRepoPath) => data.map(w => w.withRepoPath(newRepoPath)),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getSharedOrCreate<T>(\n\t\tcache: PromiseMap<string, T>,\n\t\trepoPath: string,\n\t\tfactory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<T>,\n\t\tmapper: (data: T, repoPath: string) => T,\n\t\tcancellation?: AbortSignal,\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\t// Always register this caller with the shared factory's aggregate so same-`repoPath` and\n\t\t// worktree-distinct concurrent callers both contribute — invariant 3 (factory aborts iff\n\t\t// every waiter aborts) holds uniformly. The wrapped return is our caller-facing promise\n\t\t// for the commonPath-keyed branch; the per-worktree branch uses `raceWithSignal` below.\n\t\tconst sharedPromise = cache.getOrCreate(\n\t\t\tcommonPath,\n\t\t\t(cacheable, signal) => {\n\t\t\t\tconst p = Promise.resolve(factory(commonPath, cacheable, signal));\n\t\t\t\t// On factory invalidation (without rejection), propagate to the derived per-worktree\n\t\t\t\t// mapper entries so they don't persist past the shared factory's settle. Mapper\n\t\t\t\t// entries cached via `cache.set()` have no controller, so `invalidate` hard-deletes.\n\t\t\t\tvoid p\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (cacheable.invalidated) {\n\t\t\t\t\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\t\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\t\t\t\t\tcache.invalidate(worktreePath);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t// Swallow the cleanup chain's rejection so a rejected factory (e.g. cancellation)\n\t\t\t\t\t// doesn't surface as an unhandled rejection; the caller-facing promise handles it.\n\t\t\t\t\t.catch(() => {});\n\t\t\t\treturn p;\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t\t// Swallow any rejection on the registration wrapper so it isn't surfaced as an unhandled\n\t\t// rejection when we discard it below (existing-mapper path). The real caller-facing\n\t\t// promise is the returned value.\n\t\tvoid sharedPromise.catch(() => {});\n\n\t\tif (commonPath !== repoPath) {\n\t\t\t// Reuse the cached mapped entry for this worktree if present; otherwise derive it off\n\t\t\t// the raw inner shared promise so subsequent cache hits don't inherit the first\n\t\t\t// caller's signal wrap.\n\t\t\tconst existing = cache.get(repoPath);\n\t\t\tif (existing != null) {\n\t\t\t\treturn cancellation != null ? raceWithSignal(existing, cancellation) : existing;\n\t\t\t}\n\n\t\t\tconst rawShared = cache.get(commonPath) ?? sharedPromise;\n\t\t\tconst mappedPromise = Promise.resolve(rawShared).then(data => mapper(data, repoPath));\n\t\t\tcache.set(repoPath, mappedPromise);\n\t\t\treturn cancellation != null ? raceWithSignal(mappedPromise, cancellation) : mappedPromise;\n\t\t}\n\n\t\treturn sharedPromise;\n\t}\n\n\tprivate async getSharedOrCreateWithKey<T>(\n\t\tcache: RepoPromiseCacheMap<string, T>,\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\tfactory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<T>,\n\t\tmapper: (data: T, repoPath: string) => T,\n\t\toptions?: { accessTTL?: number; cancellation?: AbortSignal },\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\t\tconst cancellation = options?.cancellation;\n\n\t\t// Always register with the shared factory's aggregate (see `getSharedOrCreate` comment).\n\t\tconst sharedPromise = cache.getOrCreate(\n\t\t\tcommonPath,\n\t\t\tcacheKey,\n\t\t\t(cacheable, signal) => {\n\t\t\t\tconst p = Promise.resolve(factory(commonPath, cacheable, signal));\n\t\t\t\t// On factory invalidation (without rejection), propagate to the derived per-worktree\n\t\t\t\t// mapper entries for this `cacheKey` so they don't persist past the shared factory's\n\t\t\t\t// settle. Mapper entries cached via `cache.set()` have no controller, so `invalidate`\n\t\t\t\t// hard-deletes.\n\t\t\t\tvoid p\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (cacheable.invalidated) {\n\t\t\t\t\t\t\tfor (const worktreePath of this.getWorktreePaths(commonPath)) {\n\t\t\t\t\t\t\t\tif (worktreePath === commonPath) continue;\n\n\t\t\t\t\t\t\t\tcache.invalidate(worktreePath, cacheKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t// Swallow the cleanup chain's rejection so a rejected factory (e.g. cancellation)\n\t\t\t\t\t// doesn't surface as an unhandled rejection; the caller-facing promise handles it.\n\t\t\t\t\t.catch(() => {});\n\t\t\t\treturn p;\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t\t// Swallow any rejection on the registration wrapper so it isn't surfaced as an unhandled\n\t\t// rejection when we discard it below (existing-mapper path).\n\t\tvoid sharedPromise.catch(() => {});\n\n\t\tif (commonPath !== repoPath) {\n\t\t\tconst existing = cache.get(repoPath, cacheKey);\n\t\t\tif (existing != null) {\n\t\t\t\treturn cancellation != null ? raceWithSignal(existing, cancellation) : existing;\n\t\t\t}\n\n\t\t\tconst rawShared = cache.get(commonPath, cacheKey) ?? sharedPromise;\n\t\t\tconst mappedPromise = Promise.resolve(rawShared).then(data => mapper(data, repoPath));\n\t\t\tcache.set(repoPath, cacheKey, mappedPromise, options);\n\t\t\treturn cancellation != null ? raceWithSignal(mappedPromise, cancellation) : mappedPromise;\n\t\t}\n\n\t\treturn sharedPromise;\n\t}\n\n\tprivate async getSharedSimple<T>(\n\t\tcache: PromiseMap<string, T> | PromiseCache<string, T>,\n\t\trepoPath: string,\n\t\t// `cacheable` is forwarded so a factory can refuse the entry when the read FAILED rather than\n\t\t// genuinely produced nothing — see `getSharedSimpleWithKey` for why that distinction matters.\n\t\tfactory: (commonPath: string, cacheable: CacheController) => PromiseOrValue<T>,\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\t// `PromiseMap.getOrCreate(key, factory, cancellation?)` and\n\t\t// `PromiseCache.getOrCreate(key, factory, options?)` have different 3rd-argument shapes,\n\t\t// so we dispatch on cache type. Both register a `CacheController` so `invalidate` works.\n\t\tif (cache instanceof PromiseCache) {\n\t\t\treturn cache.getOrCreate(commonPath, cacheable => Promise.resolve(factory(commonPath, cacheable)));\n\t\t}\n\t\treturn cache.getOrCreate(commonPath, cacheable => Promise.resolve(factory(commonPath, cacheable)));\n\t}\n\n\tprivate async getSharedSimpleWithKey<T>(\n\t\tcache: RepoPromiseCacheMap<string, T>,\n\t\trepoPath: string,\n\t\tcacheKey: string,\n\t\t// `cacheable` is forwarded so a factory can distinguish \"the answer is genuinely nothing\" from \"the\n\t\t// read failed\": callers here set no TTL by default, so a failure resolved as `undefined` would\n\t\t// otherwise be served as a real answer until something explicitly evicts it.\n\t\tfactory: (commonPath: string, cacheable: CacheController, cancellation?: AbortSignal) => PromiseOrValue<T>,\n\t\toptions?: { accessTTL?: number; createTTL?: number; cancellation?: AbortSignal },\n\t): Promise<T> {\n\t\tconst commonPath = this.getCommonPath(repoPath);\n\n\t\treturn cache.getOrCreate(\n\t\t\tcommonPath,\n\t\t\tcacheKey,\n\t\t\t(cacheable, signal) => Promise.resolve(factory(commonPath, cacheable, signal)),\n\t\t\toptions,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,MAAM,0BAAqD;CAAC;CAAS;CAAQ;AAAS;AACtF,SAAgB,2BAA2B,OAAqD;CAC/F,OAAO,MAAM,OAAM,MAAK,wBAAwB,SAAS,CAA4B,CAAC;AACvF;;;;;;AAqDA,MAAM,oBAAoB;;;;;AAM1B,MAAM,sBAAsB;AAE5B,eAAsB,2BAA2B,aAAgE;CAChH,IAAI,eAAe,MAAM,OAAO;CAEhC,IAAI;EAEH,QAAO,MADa,YAAY,UAAA,CACnB,MAAM,SAAS;CAC7B,QAAQ;EAEP,OAAO;CACR;AACD;;;;;AAMA,MAAM,kCAAkC;;AAoExC,MAAM,kBAAgD,IAAI,IACzD,gBAAoC,CAAC,CAAC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAA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AM,aAAa,KAAK,cAAc,QAAQ;EAK9C,IAAI,iBAAiB,cACpB,OAAO,MAAM,YAAY,aAAY,cAAa,QAAQ,QAAQ,QAAQ,YAAY,SAAS,CAAC,CAAC;EAElG,OAAO,MAAM,YAAY,aAAY,cAAa,QAAQ,QAAQ,QAAQ,YAAY,SAAS,CAAC,CAAC;CAClG;CAEA,MAAc,uBACb,OACA,UACA,UAIA,SACA,SACa;EACb,MAAM,aAAa,KAAK,cAAc,QAAQ;EAE9C,OAAO,MAAM,YACZ,YACA,WACC,WAAW,WAAW,QAAQ,QAAQ,QAAQ,YAAY,WAAW,MAAM,CAAC,GAC7E,OACD;CACD;AACD;AA52CE,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,eAAA,IAAA;AAqWxB,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,sBAAA,IAAA;AAyDxB,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,SAAA,IAAA;AAoBxB,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,uBAAA,IAAA;AAiBxB,WAAA,CAAA,MAAM,EAAE,UAAU,KAAK,CAAC,CAAA,GAAA,MAAA,WAAA,0BAAA,IAAA"}
@@ -1,5 +1,5 @@
1
- import { Uri } from "../utils/uri.js";
2
1
  import { Event } from "../utils/event.js";
2
+ import { Uri } from "../utils/uri.js";
3
3
  import { SearchQuery } from "./models/search.js";
4
4
  import { SigningErrorReason } from "./errors.js";
5
5
  import { RepositoryChange } from "./models/repository.js";
@@ -1,6 +1,6 @@
1
- import { Uri } from "../../utils/uri.js";
2
1
  import { UnifiedDisposable } from "../../utils/disposable.js";
3
2
  import { Event } from "../../utils/event.js";
3
+ import { Uri } from "../../utils/uri.js";
4
4
  import { GitProviderDescriptor } from "../providers/types.js";
5
5
  import { WorkingTreeChangeEvent } from "../watching/changeEvent.js";
6
6
  import { RepositorySubscription } from "../watching/watchSession.js";
@@ -63,7 +63,8 @@ export declare class RepositoryWorkingTreeChangeEvent {
63
63
  /** Whether paths were dropped, so {@link paths} can't be used to rule anything out. */
64
64
  incomplete: boolean);
65
65
  /**
66
- * Whether `uri` — or anything beneath it, when it's a folder — changed in this batch.
66
+ * Whether `uri` — or anything beneath it, when it's a folder, or a folder containing it — changed in this batch.
67
+ * A changed folder stands for everything beneath it (a watcher can miss the files of a just-created folder).
67
68
  *
68
69
  * Conservative: `true` whenever the batch is incomplete, since a miss would then prove nothing. Matches
69
70
  * on paths rather than URIs so nothing has to be allocated to answer.
@@ -3,11 +3,11 @@ import { exhaustiveArray } from "../../utils/array.js";
3
3
  import { getScopedCounter } from "../../utils/counter.js";
4
4
  import { trace } from "../../utils/decorators/log.js";
5
5
  import { memoize } from "../../utils/decorators/memoize.js";
6
+ import { createDisposable } from "../../utils/disposable.js";
7
+ import { Emitter } from "../../utils/event.js";
6
8
  import { basename, isDescendant, normalizePath } from "../../utils/path.js";
7
9
  import { getCommonRepositoryUri } from "../utils/repository.utils.js";
8
10
  import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
9
- import { createDisposable } from "../../utils/disposable.js";
10
- import { Emitter } from "../../utils/event.js";
11
11
  import { md5 } from "../../utils/crypto.js";
12
12
  import { RepositoryChangeEvent } from "./repositoryChangeEvent.js";
13
13
  //#region ../git/src/models/repository.ts
@@ -72,7 +72,8 @@ var RepositoryWorkingTreeChangeEvent = class {
72
72
  this.incomplete = incomplete;
73
73
  }
74
74
  /**
75
- * Whether `uri` — or anything beneath it, when it's a folder — changed in this batch.
75
+ * Whether `uri` — or anything beneath it, when it's a folder, or a folder containing it — changed in this batch.
76
+ * A changed folder stands for everything beneath it (a watcher can miss the files of a just-created folder).
76
77
  *
77
78
  * Conservative: `true` whenever the batch is incomplete, since a miss would then prove nothing. Matches
78
79
  * on paths rather than URIs so nothing has to be allocated to answer.
@@ -80,7 +81,7 @@ var RepositoryWorkingTreeChangeEvent = class {
80
81
  changed(uri) {
81
82
  if (this.incomplete) return true;
82
83
  const path = uri.fsPath;
83
- return some(this.paths, (p) => p === path || isDescendant(p, path));
84
+ return some(this.paths, (p) => p === path || isDescendant(p, path) || isDescendant(path, p));
84
85
  }
85
86
  toString() {
86
87
  if (this.incomplete) return `{ repository: ${this.repository.name ?? ""}, paths: incomplete }`;