gitx.do 0.1.0 → 0.1.2

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 (344) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +15 -415
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +31 -483
  17. package/dist/index.js.map +1 -1
  18. package/package.json +13 -21
  19. package/dist/cli/commands/add.d.ts +0 -174
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -131
  22. package/dist/cli/commands/add.js.map +0 -1
  23. package/dist/cli/commands/blame.d.ts +0 -259
  24. package/dist/cli/commands/blame.d.ts.map +0 -1
  25. package/dist/cli/commands/blame.js +0 -609
  26. package/dist/cli/commands/blame.js.map +0 -1
  27. package/dist/cli/commands/branch.d.ts +0 -249
  28. package/dist/cli/commands/branch.d.ts.map +0 -1
  29. package/dist/cli/commands/branch.js +0 -693
  30. package/dist/cli/commands/branch.js.map +0 -1
  31. package/dist/cli/commands/commit.d.ts +0 -182
  32. package/dist/cli/commands/commit.d.ts.map +0 -1
  33. package/dist/cli/commands/commit.js +0 -437
  34. package/dist/cli/commands/commit.js.map +0 -1
  35. package/dist/cli/commands/diff.d.ts +0 -464
  36. package/dist/cli/commands/diff.d.ts.map +0 -1
  37. package/dist/cli/commands/diff.js +0 -958
  38. package/dist/cli/commands/diff.js.map +0 -1
  39. package/dist/cli/commands/log.d.ts +0 -239
  40. package/dist/cli/commands/log.d.ts.map +0 -1
  41. package/dist/cli/commands/log.js +0 -535
  42. package/dist/cli/commands/log.js.map +0 -1
  43. package/dist/cli/commands/merge.d.ts +0 -106
  44. package/dist/cli/commands/merge.d.ts.map +0 -1
  45. package/dist/cli/commands/merge.js +0 -55
  46. package/dist/cli/commands/merge.js.map +0 -1
  47. package/dist/cli/commands/review.d.ts +0 -457
  48. package/dist/cli/commands/review.d.ts.map +0 -1
  49. package/dist/cli/commands/review.js +0 -533
  50. package/dist/cli/commands/review.js.map +0 -1
  51. package/dist/cli/commands/status.d.ts +0 -269
  52. package/dist/cli/commands/status.d.ts.map +0 -1
  53. package/dist/cli/commands/status.js +0 -493
  54. package/dist/cli/commands/status.js.map +0 -1
  55. package/dist/cli/commands/web.d.ts +0 -199
  56. package/dist/cli/commands/web.d.ts.map +0 -1
  57. package/dist/cli/commands/web.js +0 -696
  58. package/dist/cli/commands/web.js.map +0 -1
  59. package/dist/cli/fs-adapter.d.ts +0 -656
  60. package/dist/cli/fs-adapter.d.ts.map +0 -1
  61. package/dist/cli/fs-adapter.js +0 -1179
  62. package/dist/cli/fs-adapter.js.map +0 -1
  63. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  64. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  65. package/dist/cli/fsx-cli-adapter.js +0 -619
  66. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  67. package/dist/cli/index.d.ts +0 -387
  68. package/dist/cli/index.d.ts.map +0 -1
  69. package/dist/cli/index.js +0 -523
  70. package/dist/cli/index.js.map +0 -1
  71. package/dist/cli/ui/components/DiffView.d.ts +0 -7
  72. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  73. package/dist/cli/ui/components/DiffView.js +0 -11
  74. package/dist/cli/ui/components/DiffView.js.map +0 -1
  75. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -6
  76. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  77. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  78. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  79. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -9
  80. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  81. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  82. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  83. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -6
  84. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  85. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  86. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  87. package/dist/cli/ui/components/NavigationList.d.ts +0 -9
  88. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  89. package/dist/cli/ui/components/NavigationList.js +0 -11
  90. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  91. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -8
  92. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  93. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  94. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  95. package/dist/cli/ui/components/index.d.ts +0 -7
  96. package/dist/cli/ui/components/index.d.ts.map +0 -1
  97. package/dist/cli/ui/components/index.js +0 -9
  98. package/dist/cli/ui/components/index.js.map +0 -1
  99. package/dist/cli/ui/terminal-ui.d.ts +0 -52
  100. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  101. package/dist/cli/ui/terminal-ui.js +0 -121
  102. package/dist/cli/ui/terminal-ui.js.map +0 -1
  103. package/dist/do/BashModule.d.ts +0 -871
  104. package/dist/do/BashModule.d.ts.map +0 -1
  105. package/dist/do/BashModule.js +0 -1143
  106. package/dist/do/BashModule.js.map +0 -1
  107. package/dist/do/FsModule.d.ts +0 -601
  108. package/dist/do/FsModule.d.ts.map +0 -1
  109. package/dist/do/FsModule.js +0 -1120
  110. package/dist/do/FsModule.js.map +0 -1
  111. package/dist/do/GitModule.d.ts +0 -635
  112. package/dist/do/GitModule.d.ts.map +0 -1
  113. package/dist/do/GitModule.js +0 -781
  114. package/dist/do/GitModule.js.map +0 -1
  115. package/dist/do/GitRepoDO.d.ts +0 -281
  116. package/dist/do/GitRepoDO.d.ts.map +0 -1
  117. package/dist/do/GitRepoDO.js +0 -479
  118. package/dist/do/GitRepoDO.js.map +0 -1
  119. package/dist/do/bash-ast.d.ts +0 -246
  120. package/dist/do/bash-ast.d.ts.map +0 -1
  121. package/dist/do/bash-ast.js +0 -888
  122. package/dist/do/bash-ast.js.map +0 -1
  123. package/dist/do/container-executor.d.ts +0 -491
  124. package/dist/do/container-executor.d.ts.map +0 -1
  125. package/dist/do/container-executor.js +0 -730
  126. package/dist/do/container-executor.js.map +0 -1
  127. package/dist/do/index.d.ts +0 -53
  128. package/dist/do/index.d.ts.map +0 -1
  129. package/dist/do/index.js +0 -91
  130. package/dist/do/index.js.map +0 -1
  131. package/dist/do/tiered-storage.d.ts +0 -403
  132. package/dist/do/tiered-storage.d.ts.map +0 -1
  133. package/dist/do/tiered-storage.js +0 -689
  134. package/dist/do/tiered-storage.js.map +0 -1
  135. package/dist/do/withBash.d.ts +0 -231
  136. package/dist/do/withBash.d.ts.map +0 -1
  137. package/dist/do/withBash.js +0 -244
  138. package/dist/do/withBash.js.map +0 -1
  139. package/dist/do/withFs.d.ts +0 -237
  140. package/dist/do/withFs.d.ts.map +0 -1
  141. package/dist/do/withFs.js +0 -387
  142. package/dist/do/withFs.js.map +0 -1
  143. package/dist/do/withGit.d.ts +0 -180
  144. package/dist/do/withGit.d.ts.map +0 -1
  145. package/dist/do/withGit.js +0 -271
  146. package/dist/do/withGit.js.map +0 -1
  147. package/dist/durable-object/object-store.d.ts +0 -633
  148. package/dist/durable-object/object-store.d.ts.map +0 -1
  149. package/dist/durable-object/object-store.js +0 -1161
  150. package/dist/durable-object/object-store.js.map +0 -1
  151. package/dist/durable-object/schema.d.ts.map +0 -1
  152. package/dist/durable-object/schema.js.map +0 -1
  153. package/dist/durable-object/wal.d.ts +0 -416
  154. package/dist/durable-object/wal.d.ts.map +0 -1
  155. package/dist/durable-object/wal.js +0 -445
  156. package/dist/durable-object/wal.js.map +0 -1
  157. package/dist/mcp/adapter.d.ts +0 -772
  158. package/dist/mcp/adapter.d.ts.map +0 -1
  159. package/dist/mcp/adapter.js +0 -895
  160. package/dist/mcp/adapter.js.map +0 -1
  161. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  162. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  163. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  164. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  165. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  166. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  167. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  168. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  169. package/dist/mcp/sandbox/template.d.ts +0 -17
  170. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/template.js +0 -71
  172. package/dist/mcp/sandbox/template.js.map +0 -1
  173. package/dist/mcp/sandbox.d.ts +0 -764
  174. package/dist/mcp/sandbox.d.ts.map +0 -1
  175. package/dist/mcp/sandbox.js +0 -1362
  176. package/dist/mcp/sandbox.js.map +0 -1
  177. package/dist/mcp/sdk-adapter.d.ts +0 -835
  178. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  179. package/dist/mcp/sdk-adapter.js +0 -974
  180. package/dist/mcp/sdk-adapter.js.map +0 -1
  181. package/dist/mcp/tools/do.d.ts +0 -32
  182. package/dist/mcp/tools/do.d.ts.map +0 -1
  183. package/dist/mcp/tools/do.js +0 -115
  184. package/dist/mcp/tools/do.js.map +0 -1
  185. package/dist/mcp/tools.d.ts +0 -548
  186. package/dist/mcp/tools.d.ts.map +0 -1
  187. package/dist/mcp/tools.js +0 -1934
  188. package/dist/mcp/tools.js.map +0 -1
  189. package/dist/ops/blame.d.ts +0 -551
  190. package/dist/ops/blame.d.ts.map +0 -1
  191. package/dist/ops/blame.js +0 -1037
  192. package/dist/ops/blame.js.map +0 -1
  193. package/dist/ops/branch.d.ts +0 -766
  194. package/dist/ops/branch.d.ts.map +0 -1
  195. package/dist/ops/branch.js +0 -950
  196. package/dist/ops/branch.js.map +0 -1
  197. package/dist/ops/commit-traversal.d.ts +0 -349
  198. package/dist/ops/commit-traversal.d.ts.map +0 -1
  199. package/dist/ops/commit-traversal.js +0 -821
  200. package/dist/ops/commit-traversal.js.map +0 -1
  201. package/dist/ops/commit.d.ts +0 -555
  202. package/dist/ops/commit.d.ts.map +0 -1
  203. package/dist/ops/commit.js +0 -826
  204. package/dist/ops/commit.js.map +0 -1
  205. package/dist/ops/merge-base.d.ts +0 -397
  206. package/dist/ops/merge-base.d.ts.map +0 -1
  207. package/dist/ops/merge-base.js +0 -691
  208. package/dist/ops/merge-base.js.map +0 -1
  209. package/dist/ops/merge.d.ts +0 -855
  210. package/dist/ops/merge.d.ts.map +0 -1
  211. package/dist/ops/merge.js +0 -1551
  212. package/dist/ops/merge.js.map +0 -1
  213. package/dist/ops/tag.d.ts +0 -247
  214. package/dist/ops/tag.d.ts.map +0 -1
  215. package/dist/ops/tag.js +0 -649
  216. package/dist/ops/tag.js.map +0 -1
  217. package/dist/ops/tree-builder.d.ts +0 -178
  218. package/dist/ops/tree-builder.d.ts.map +0 -1
  219. package/dist/ops/tree-builder.js +0 -271
  220. package/dist/ops/tree-builder.js.map +0 -1
  221. package/dist/ops/tree-diff.d.ts +0 -291
  222. package/dist/ops/tree-diff.d.ts.map +0 -1
  223. package/dist/ops/tree-diff.js +0 -705
  224. package/dist/ops/tree-diff.js.map +0 -1
  225. package/dist/pack/delta.d.ts +0 -248
  226. package/dist/pack/delta.d.ts.map +0 -1
  227. package/dist/pack/delta.js +0 -736
  228. package/dist/pack/delta.js.map +0 -1
  229. package/dist/pack/format.d.ts +0 -446
  230. package/dist/pack/format.d.ts.map +0 -1
  231. package/dist/pack/format.js +0 -572
  232. package/dist/pack/format.js.map +0 -1
  233. package/dist/pack/full-generation.d.ts +0 -612
  234. package/dist/pack/full-generation.d.ts.map +0 -1
  235. package/dist/pack/full-generation.js +0 -1378
  236. package/dist/pack/full-generation.js.map +0 -1
  237. package/dist/pack/generation.d.ts +0 -441
  238. package/dist/pack/generation.d.ts.map +0 -1
  239. package/dist/pack/generation.js +0 -707
  240. package/dist/pack/generation.js.map +0 -1
  241. package/dist/pack/index.d.ts +0 -502
  242. package/dist/pack/index.d.ts.map +0 -1
  243. package/dist/pack/index.js +0 -833
  244. package/dist/pack/index.js.map +0 -1
  245. package/dist/refs/branch.d.ts +0 -668
  246. package/dist/refs/branch.d.ts.map +0 -1
  247. package/dist/refs/branch.js +0 -897
  248. package/dist/refs/branch.js.map +0 -1
  249. package/dist/refs/storage.d.ts +0 -833
  250. package/dist/refs/storage.d.ts.map +0 -1
  251. package/dist/refs/storage.js +0 -1023
  252. package/dist/refs/storage.js.map +0 -1
  253. package/dist/refs/tag.d.ts +0 -860
  254. package/dist/refs/tag.d.ts.map +0 -1
  255. package/dist/refs/tag.js +0 -996
  256. package/dist/refs/tag.js.map +0 -1
  257. package/dist/storage/backend.d.ts +0 -425
  258. package/dist/storage/backend.d.ts.map +0 -1
  259. package/dist/storage/backend.js +0 -41
  260. package/dist/storage/backend.js.map +0 -1
  261. package/dist/storage/fsx-adapter.d.ts +0 -204
  262. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  263. package/dist/storage/fsx-adapter.js +0 -470
  264. package/dist/storage/fsx-adapter.js.map +0 -1
  265. package/dist/storage/lru-cache.d.ts +0 -691
  266. package/dist/storage/lru-cache.d.ts.map +0 -1
  267. package/dist/storage/lru-cache.js +0 -813
  268. package/dist/storage/lru-cache.js.map +0 -1
  269. package/dist/storage/object-index.d.ts +0 -585
  270. package/dist/storage/object-index.d.ts.map +0 -1
  271. package/dist/storage/object-index.js +0 -532
  272. package/dist/storage/object-index.js.map +0 -1
  273. package/dist/storage/r2-pack.d.ts +0 -1257
  274. package/dist/storage/r2-pack.d.ts.map +0 -1
  275. package/dist/storage/r2-pack.js +0 -1770
  276. package/dist/storage/r2-pack.js.map +0 -1
  277. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  278. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  279. package/dist/tiered/cdc-pipeline.js +0 -1880
  280. package/dist/tiered/cdc-pipeline.js.map +0 -1
  281. package/dist/tiered/migration.d.ts +0 -1104
  282. package/dist/tiered/migration.d.ts.map +0 -1
  283. package/dist/tiered/migration.js +0 -1214
  284. package/dist/tiered/migration.js.map +0 -1
  285. package/dist/tiered/parquet-writer.d.ts +0 -1145
  286. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  287. package/dist/tiered/parquet-writer.js +0 -1183
  288. package/dist/tiered/parquet-writer.js.map +0 -1
  289. package/dist/tiered/read-path.d.ts +0 -835
  290. package/dist/tiered/read-path.d.ts.map +0 -1
  291. package/dist/tiered/read-path.js +0 -487
  292. package/dist/tiered/read-path.js.map +0 -1
  293. package/dist/types/capability.d.ts +0 -1385
  294. package/dist/types/capability.d.ts.map +0 -1
  295. package/dist/types/capability.js +0 -36
  296. package/dist/types/capability.js.map +0 -1
  297. package/dist/types/index.d.ts +0 -13
  298. package/dist/types/index.d.ts.map +0 -1
  299. package/dist/types/index.js +0 -18
  300. package/dist/types/index.js.map +0 -1
  301. package/dist/types/objects.d.ts +0 -692
  302. package/dist/types/objects.d.ts.map +0 -1
  303. package/dist/types/objects.js +0 -837
  304. package/dist/types/objects.js.map +0 -1
  305. package/dist/types/storage.d.ts +0 -603
  306. package/dist/types/storage.d.ts.map +0 -1
  307. package/dist/types/storage.js +0 -191
  308. package/dist/types/storage.js.map +0 -1
  309. package/dist/types/worker-loader.d.ts +0 -60
  310. package/dist/types/worker-loader.d.ts.map +0 -1
  311. package/dist/types/worker-loader.js +0 -62
  312. package/dist/types/worker-loader.js.map +0 -1
  313. package/dist/utils/hash.d.ts +0 -197
  314. package/dist/utils/hash.d.ts.map +0 -1
  315. package/dist/utils/hash.js +0 -268
  316. package/dist/utils/hash.js.map +0 -1
  317. package/dist/utils/sha1.d.ts +0 -290
  318. package/dist/utils/sha1.d.ts.map +0 -1
  319. package/dist/utils/sha1.js +0 -582
  320. package/dist/utils/sha1.js.map +0 -1
  321. package/dist/wire/capabilities.d.ts +0 -1044
  322. package/dist/wire/capabilities.d.ts.map +0 -1
  323. package/dist/wire/capabilities.js +0 -941
  324. package/dist/wire/capabilities.js.map +0 -1
  325. package/dist/wire/path-security.d.ts +0 -157
  326. package/dist/wire/path-security.d.ts.map +0 -1
  327. package/dist/wire/path-security.js +0 -307
  328. package/dist/wire/path-security.js.map +0 -1
  329. package/dist/wire/pkt-line.d.ts +0 -345
  330. package/dist/wire/pkt-line.d.ts.map +0 -1
  331. package/dist/wire/pkt-line.js +0 -381
  332. package/dist/wire/pkt-line.js.map +0 -1
  333. package/dist/wire/receive-pack.d.ts +0 -1059
  334. package/dist/wire/receive-pack.d.ts.map +0 -1
  335. package/dist/wire/receive-pack.js +0 -1414
  336. package/dist/wire/receive-pack.js.map +0 -1
  337. package/dist/wire/smart-http.d.ts +0 -799
  338. package/dist/wire/smart-http.d.ts.map +0 -1
  339. package/dist/wire/smart-http.js +0 -945
  340. package/dist/wire/smart-http.js.map +0 -1
  341. package/dist/wire/upload-pack.d.ts +0 -727
  342. package/dist/wire/upload-pack.d.ts.map +0 -1
  343. package/dist/wire/upload-pack.js +0 -1138
  344. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,1104 +0,0 @@
1
- /**
2
- * @fileoverview Tier Migration Module (Hot -> Warm)
3
- *
4
- * This module handles the migration of Git objects between storage tiers in the
5
- * gitdo tiered storage architecture. It provides comprehensive functionality for:
6
- *
7
- * ## Storage Tiers
8
- *
9
- * - **Hot**: SQLite in Durable Object storage - fastest access, limited capacity
10
- * - **Warm/R2**: Packed objects in R2 object storage - medium latency, larger capacity
11
- *
12
- * ## Key Features
13
- *
14
- * - **Policy-based Migration**: Configurable policies based on age, access frequency, and size
15
- * - **Access Tracking**: Monitors object access patterns to inform migration decisions
16
- * - **Atomic Operations**: Ensures data integrity during migration with rollback support
17
- * - **Concurrent Access Handling**: Safe reads/writes during in-progress migrations
18
- * - **Checksum Verification**: Optional integrity verification after migration
19
- * - **Batch Migration**: Efficient bulk migration with configurable concurrency
20
- *
21
- * ## Migration Process
22
- *
23
- * 1. Acquire distributed lock on the object
24
- * 2. Copy data from hot tier to warm tier
25
- * 3. Verify data integrity (optional checksum verification)
26
- * 4. Update object location index
27
- * 5. Delete from hot tier
28
- * 6. Release lock
29
- *
30
- * If any step fails, the migration is rolled back automatically.
31
- *
32
- * @module tiered/migration
33
- *
34
- * @example
35
- * ```typescript
36
- * // Create a migrator
37
- * const migrator = new TierMigrator(storage);
38
- *
39
- * // Define migration policy
40
- * const policy: MigrationPolicy = {
41
- * maxAgeInHot: 24 * 60 * 60 * 1000, // 24 hours
42
- * minAccessCount: 5,
43
- * maxHotSize: 100 * 1024 * 1024 // 100MB
44
- * };
45
- *
46
- * // Find candidates and migrate
47
- * const candidates = await migrator.findMigrationCandidates(policy);
48
- * for (const sha of candidates) {
49
- * await migrator.migrate(sha, 'hot', 'r2', { verifyChecksum: true });
50
- * }
51
- * ```
52
- */
53
- import { StorageTier } from '../storage/object-index';
54
- /**
55
- * Migration policy configuration.
56
- *
57
- * @description
58
- * Defines the criteria for determining when objects should be migrated
59
- * from the hot tier to the warm tier. Objects meeting ANY of these criteria
60
- * may be migrated.
61
- *
62
- * @example
63
- * ```typescript
64
- * const policy: MigrationPolicy = {
65
- * maxAgeInHot: 7 * 24 * 60 * 60 * 1000, // 7 days
66
- * minAccessCount: 10, // Stay hot if accessed 10+ times
67
- * maxHotSize: 500 * 1024 * 1024 // Trigger migration if hot > 500MB
68
- * };
69
- * ```
70
- */
71
- export interface MigrationPolicy {
72
- /**
73
- * Maximum age in hot tier before migration (milliseconds).
74
- * Objects older than this may be migrated to warm tier.
75
- * Use Infinity to disable age-based migration.
76
- */
77
- maxAgeInHot: number;
78
- /**
79
- * Minimum access count to stay in hot tier.
80
- * Objects with fewer accesses may be migrated.
81
- * Use 0 to disable access-count-based migration.
82
- */
83
- minAccessCount: number;
84
- /**
85
- * Maximum total size of hot tier (bytes).
86
- * When exceeded, oldest/coldest objects are migrated.
87
- */
88
- maxHotSize: number;
89
- }
90
- /**
91
- * Migration job state enumeration.
92
- *
93
- * @description
94
- * Represents the lifecycle states of a migration job:
95
- * - `pending`: Job created but not started
96
- * - `in_progress`: Migration actively running
97
- * - `completed`: Migration finished successfully
98
- * - `failed`: Migration failed (may be retried)
99
- * - `cancelled`: Job was cancelled by user
100
- * - `rolled_back`: Migration failed and changes were reverted
101
- */
102
- export type MigrationState = 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | 'rolled_back';
103
- /**
104
- * Migration job progress tracking.
105
- *
106
- * @description
107
- * Tracks the progress of data transfer during a migration job.
108
- * Useful for long-running migrations of large objects.
109
- *
110
- * @example
111
- * ```typescript
112
- * const job = await migrator.startMigrationJob(sha, 'hot', 'r2');
113
- * console.log(`Progress: ${job.progress.bytesTransferred}/${job.progress.totalBytes}`);
114
- * ```
115
- */
116
- export interface MigrationProgress {
117
- /** Number of bytes transferred so far */
118
- bytesTransferred: number;
119
- /** Total number of bytes to transfer */
120
- totalBytes: number;
121
- }
122
- /**
123
- * Migration job tracking information.
124
- *
125
- * @description
126
- * Contains all information about an active or completed migration job,
127
- * including progress tracking, timing, and state.
128
- *
129
- * @example
130
- * ```typescript
131
- * const job = await migrator.startMigrationJob(sha, 'hot', 'r2');
132
- * console.log(`Job ${job.id} started at ${new Date(job.startedAt)}`);
133
- * console.log(`State: ${job.state}`);
134
- * ```
135
- */
136
- export interface MigrationJob {
137
- /** Unique identifier for the migration job */
138
- id: string;
139
- /** SHA of the object being migrated */
140
- sha: string;
141
- /** Source storage tier */
142
- sourceTier: StorageTier;
143
- /** Target storage tier */
144
- targetTier: StorageTier;
145
- /** Current state of the migration */
146
- state: MigrationState;
147
- /** Whether a lock was successfully acquired */
148
- lockAcquired: boolean;
149
- /** Progress tracking for the migration */
150
- progress: MigrationProgress;
151
- /** Timestamp when the job started (ms since epoch) */
152
- startedAt: number;
153
- /** Timestamp when the job completed (ms since epoch), if completed */
154
- completedAt?: number;
155
- }
156
- /**
157
- * Result of a migration operation.
158
- *
159
- * @description
160
- * Contains the outcome of a single object migration, including success/failure
161
- * status, verification results, and error information if applicable.
162
- *
163
- * @example
164
- * ```typescript
165
- * const result = await migrator.migrate(sha, 'hot', 'r2', { verifyChecksum: true });
166
- * if (result.success) {
167
- * console.log('Migration successful');
168
- * if (result.checksumVerified) {
169
- * console.log('Data integrity verified');
170
- * }
171
- * } else if (result.skipped) {
172
- * console.log('Object was already migrated');
173
- * } else if (result.rolledBack) {
174
- * console.log(`Migration rolled back: ${result.rollbackReason}`);
175
- * }
176
- * ```
177
- */
178
- export interface MigrationResult {
179
- /** Whether the migration completed successfully */
180
- success: boolean;
181
- /** Whether the migration was skipped (e.g., already in target tier) */
182
- skipped?: boolean;
183
- /** Whether the migration was rolled back due to an error */
184
- rolledBack?: boolean;
185
- /** Whether checksum verification passed (if requested) */
186
- checksumVerified?: boolean;
187
- /** Error details if migration failed */
188
- error?: MigrationError;
189
- /** Reason for rollback if rolledBack is true */
190
- rollbackReason?: string;
191
- }
192
- /**
193
- * Result of a batch migration operation.
194
- *
195
- * @description
196
- * Contains arrays of successful and failed SHA hashes after a batch migration.
197
- *
198
- * @example
199
- * ```typescript
200
- * const result = await migrator.migrateBatch(shas, 'hot', 'r2');
201
- * console.log(`Migrated: ${result.successful.length}`);
202
- * console.log(`Failed: ${result.failed.length}`);
203
- * ```
204
- */
205
- export interface BatchMigrationResult {
206
- /** SHAs of objects that were successfully migrated */
207
- successful: string[];
208
- /** SHAs of objects that failed to migrate */
209
- failed: string[];
210
- }
211
- /**
212
- * Options for batch migration operations.
213
- *
214
- * @description
215
- * Configures batch migration behavior, particularly concurrency.
216
- *
217
- * @example
218
- * ```typescript
219
- * // Migrate with limited concurrency to avoid overwhelming storage
220
- * const result = await migrator.migrateBatch(shas, 'hot', 'r2', {
221
- * concurrency: 5
222
- * });
223
- * ```
224
- */
225
- export interface BatchMigrationOptions {
226
- /**
227
- * Number of concurrent migrations.
228
- * @default shas.length (all at once)
229
- */
230
- concurrency?: number;
231
- }
232
- /**
233
- * Options for individual migration operations.
234
- *
235
- * @description
236
- * Configures behavior of a single migration operation.
237
- *
238
- * @example
239
- * ```typescript
240
- * const result = await migrator.migrate(sha, 'hot', 'r2', {
241
- * verifyChecksum: true,
242
- * lockTimeout: 10000
243
- * });
244
- * ```
245
- */
246
- export interface MigrateOptions {
247
- /**
248
- * Whether to verify checksums after migration.
249
- * Adds overhead but ensures data integrity.
250
- * @default false
251
- */
252
- verifyChecksum?: boolean;
253
- /**
254
- * Timeout in milliseconds for acquiring the lock.
255
- * @default 5000
256
- */
257
- lockTimeout?: number;
258
- }
259
- /**
260
- * Migration history entry.
261
- *
262
- * @description
263
- * Records a single migration event for an object, useful for
264
- * auditing and debugging migration issues.
265
- *
266
- * @example
267
- * ```typescript
268
- * const history = await migrator.getMigrationHistory(sha);
269
- * for (const entry of history) {
270
- * console.log(`${entry.timestamp}: ${entry.sourceTier} -> ${entry.targetTier}: ${entry.state}`);
271
- * }
272
- * ```
273
- */
274
- export interface MigrationHistoryEntry {
275
- /** SHA of the migrated object */
276
- sha: string;
277
- /** Source storage tier */
278
- sourceTier: StorageTier;
279
- /** Target storage tier */
280
- targetTier: StorageTier;
281
- /** Final state of the migration */
282
- state: MigrationState;
283
- /** Timestamp of the migration event */
284
- timestamp: number;
285
- }
286
- /**
287
- * Access pattern information for an object.
288
- *
289
- * @description
290
- * Contains detailed access statistics for an object, used to make
291
- * informed migration decisions.
292
- *
293
- * @example
294
- * ```typescript
295
- * const pattern = await tracker.getAccessPattern(sha);
296
- * console.log(`Reads: ${pattern.readCount}, Writes: ${pattern.writeCount}`);
297
- * console.log(`Access frequency: ${pattern.accessFrequency.toFixed(2)}/sec`);
298
- * ```
299
- */
300
- export interface AccessPattern {
301
- /** SHA of the object */
302
- sha: string;
303
- /** Number of read operations */
304
- readCount: number;
305
- /** Number of write operations */
306
- writeCount: number;
307
- /** Timestamp of last access (ms since epoch) */
308
- lastAccessedAt: number;
309
- /** Access frequency (accesses per second) */
310
- accessFrequency: number;
311
- /** Total bytes read from this object */
312
- totalBytesRead?: number;
313
- /** Average latency in milliseconds for accessing this object */
314
- avgLatencyMs?: number;
315
- }
316
- /**
317
- * Aggregate access statistics.
318
- *
319
- * @description
320
- * Provides summary statistics about access patterns across all tracked objects.
321
- *
322
- * @example
323
- * ```typescript
324
- * const stats = await tracker.getAccessStats();
325
- * console.log(`Total reads: ${stats.totalReads}`);
326
- * console.log(`Unique objects: ${stats.uniqueObjectsAccessed}`);
327
- * ```
328
- */
329
- export interface AccessStats {
330
- /** Total number of read operations across all objects */
331
- totalReads: number;
332
- /** Total number of write operations across all objects */
333
- totalWrites: number;
334
- /** Number of unique objects that have been accessed */
335
- uniqueObjectsAccessed: number;
336
- }
337
- /**
338
- * Criteria for identifying hot or cold objects.
339
- *
340
- * @description
341
- * Specifies filters for querying objects based on access patterns.
342
- *
343
- * @example
344
- * ```typescript
345
- * // Find frequently accessed objects
346
- * const hotObjects = await tracker.identifyHotObjects({
347
- * minAccessCount: 100
348
- * });
349
- *
350
- * // Find rarely accessed objects
351
- * const coldObjects = await tracker.identifyColdObjects({
352
- * maxAccessCount: 2,
353
- * minAgeMs: 7 * 24 * 60 * 60 * 1000 // 7 days old
354
- * });
355
- * ```
356
- */
357
- export interface ObjectIdentificationCriteria {
358
- /** Minimum total access count (reads + writes) */
359
- minAccessCount?: number;
360
- /** Maximum total access count (reads + writes) */
361
- maxAccessCount?: number;
362
- /** Minimum age in milliseconds since last access */
363
- minAgeMs?: number;
364
- }
365
- /**
366
- * Options for applying access count decay.
367
- *
368
- * @description
369
- * Configures how access counts are decayed over time to gradually
370
- * "forget" old access patterns and respond to changing usage.
371
- *
372
- * @example
373
- * ```typescript
374
- * // Apply 50% decay to all access counts
375
- * await tracker.applyDecay({
376
- * decayFactor: 0.5,
377
- * minAgeForDecayMs: 24 * 60 * 60 * 1000 // Only decay after 24 hours
378
- * });
379
- * ```
380
- */
381
- export interface DecayOptions {
382
- /**
383
- * Multiplier applied to access counts (0-1).
384
- * 0.5 means counts are halved.
385
- */
386
- decayFactor: number;
387
- /**
388
- * Minimum age in milliseconds before decay is applied.
389
- * Prevents decay of recently accessed objects.
390
- */
391
- minAgeForDecayMs: number;
392
- }
393
- /**
394
- * Custom metrics for access recording.
395
- *
396
- * @description
397
- * Additional metrics that can be recorded with each access operation.
398
- *
399
- * @example
400
- * ```typescript
401
- * await tracker.recordAccess(sha, 'read', {
402
- * bytesRead: 1024,
403
- * latencyMs: 15
404
- * });
405
- * ```
406
- */
407
- export interface AccessMetrics {
408
- /** Number of bytes read in this operation */
409
- bytesRead?: number;
410
- /** Latency of this operation in milliseconds */
411
- latencyMs?: number;
412
- }
413
- /**
414
- * Error thrown during migration operations.
415
- *
416
- * @description
417
- * Custom error class for migration failures with detailed information
418
- * about the failure context. Also implements MigrationResult-like properties
419
- * for compatibility with result handling code.
420
- *
421
- * Error codes:
422
- * - `NOT_FOUND`: Object does not exist in source tier
423
- * - `ALREADY_IN_TARGET`: Object is already in the target tier
424
- * - `LOCK_TIMEOUT`: Could not acquire lock within timeout
425
- * - `WRITE_FAILED`: Failed to write to target tier
426
- * - `CHECKSUM_MISMATCH`: Data verification failed after migration
427
- * - `UPDATE_FAILED`: Failed to update object index
428
- *
429
- * @example
430
- * ```typescript
431
- * try {
432
- * await migrator.migrate(sha, 'hot', 'r2');
433
- * } catch (error) {
434
- * if (error instanceof MigrationError) {
435
- * console.log(`Migration failed: ${error.code}`);
436
- * console.log(`Object: ${error.sha}`);
437
- * console.log(`${error.sourceTier} -> ${error.targetTier}`);
438
- * }
439
- * }
440
- * ```
441
- */
442
- export declare class MigrationError extends Error {
443
- readonly code: string;
444
- readonly sha: string;
445
- readonly sourceTier: StorageTier;
446
- readonly targetTier: StorageTier;
447
- readonly cause?: Error | undefined;
448
- /** Always false for error objects */
449
- readonly success: boolean;
450
- /** Whether rollback was performed */
451
- readonly rolledBack: boolean;
452
- /** Reason for rollback (from cause error) */
453
- readonly rollbackReason?: string;
454
- /**
455
- * Creates a new MigrationError.
456
- *
457
- * @param message - Human-readable error message
458
- * @param code - Error code for programmatic handling
459
- * @param sha - SHA of the object being migrated
460
- * @param sourceTier - Source storage tier
461
- * @param targetTier - Target storage tier
462
- * @param cause - Underlying error that caused this failure
463
- */
464
- constructor(message: string, code: string, sha: string, sourceTier: StorageTier, targetTier: StorageTier, cause?: Error | undefined);
465
- /**
466
- * Returns this error as a MigrationError reference.
467
- *
468
- * @description
469
- * Provides compatibility with MigrationResult.error property access.
470
- *
471
- * @returns This MigrationError instance
472
- */
473
- get error(): MigrationError;
474
- }
475
- /**
476
- * Rollback handler for failed migrations.
477
- *
478
- * @description
479
- * Handles cleanup operations when a migration fails, ensuring
480
- * that partial migrations don't leave the system in an inconsistent state.
481
- *
482
- * @example
483
- * ```typescript
484
- * const rollback = new MigrationRollback(storage);
485
- * if (migrationFailed) {
486
- * await rollback.rollback(job);
487
- * }
488
- * ```
489
- */
490
- export declare class MigrationRollback {
491
- private storage;
492
- /**
493
- * Creates a new MigrationRollback handler.
494
- *
495
- * @param storage - The tier storage implementation
496
- */
497
- constructor(storage: unknown);
498
- /**
499
- * Rolls back a failed migration job.
500
- *
501
- * @description
502
- * Cleans up any partial data in the warm tier and releases the lock.
503
- * Updates the job state to 'rolled_back'.
504
- *
505
- * @param job - The migration job to roll back
506
- *
507
- * @example
508
- * ```typescript
509
- * await rollback.rollback(failedJob);
510
- * console.log(failedJob.state); // 'rolled_back'
511
- * ```
512
- */
513
- rollback(job: MigrationJob): Promise<void>;
514
- }
515
- /**
516
- * Handler for concurrent access during migration.
517
- *
518
- * @description
519
- * Manages read and write operations that occur while an object
520
- * is being migrated, ensuring data consistency.
521
- *
522
- * During migration:
523
- * - Reads check hot tier first (data still there), then warm tier
524
- * - Writes go to hot tier and may be queued for replay
525
- *
526
- * @example
527
- * ```typescript
528
- * const handler = new ConcurrentAccessHandler(storage);
529
- *
530
- * // Safe read during migration
531
- * const data = await handler.handleRead(sha);
532
- *
533
- * // Safe write during migration
534
- * await handler.handleWrite(sha, newData);
535
- * ```
536
- */
537
- export declare class ConcurrentAccessHandler {
538
- private storage;
539
- /**
540
- * Creates a new ConcurrentAccessHandler.
541
- *
542
- * @param storage - The tier storage implementation
543
- */
544
- constructor(storage: unknown);
545
- /**
546
- * Handles a read operation during migration.
547
- *
548
- * @description
549
- * Reads from hot tier first (data is still there during migration),
550
- * then falls back to warm tier if not found.
551
- *
552
- * @param sha - The object SHA to read
553
- *
554
- * @returns Object data or null if not found
555
- *
556
- * @example
557
- * ```typescript
558
- * const data = await handler.handleRead(sha);
559
- * if (data) {
560
- * // Process the data
561
- * }
562
- * ```
563
- */
564
- handleRead(sha: string): Promise<Uint8Array | null>;
565
- /**
566
- * Handles a write operation during migration.
567
- *
568
- * @description
569
- * Writes to the hot tier. The TierMigrator will handle replaying
570
- * pending writes after migration completes.
571
- *
572
- * @param sha - The object SHA to write
573
- * @param data - The data to write
574
- *
575
- * @example
576
- * ```typescript
577
- * await handler.handleWrite(sha, newData);
578
- * ```
579
- */
580
- handleWrite(sha: string, data: Uint8Array): Promise<void>;
581
- }
582
- /**
583
- * Tracks access patterns for objects to inform migration decisions.
584
- *
585
- * @description
586
- * Records and analyzes access patterns for objects in the storage system.
587
- * This information is used to make intelligent decisions about which
588
- * objects should be migrated between tiers.
589
- *
590
- * ## Features
591
- *
592
- * - Records read/write operations with optional metrics
593
- * - Calculates access frequency over time
594
- * - Identifies hot objects (frequently accessed)
595
- * - Identifies cold objects (rarely accessed)
596
- * - Supports access count decay for temporal relevance
597
- * - Persists patterns to storage for durability
598
- *
599
- * @example
600
- * ```typescript
601
- * const tracker = new AccessTracker(storage);
602
- *
603
- * // Record accesses
604
- * await tracker.recordAccess(sha, 'read', { bytesRead: 1024 });
605
- * await tracker.recordAccess(sha, 'write');
606
- *
607
- * // Get access pattern for an object
608
- * const pattern = await tracker.getAccessPattern(sha);
609
- * console.log(`Frequency: ${pattern.accessFrequency}/sec`);
610
- *
611
- * // Find hot and cold objects
612
- * const hotObjects = await tracker.identifyHotObjects({ minAccessCount: 50 });
613
- * const coldObjects = await tracker.identifyColdObjects({ maxAccessCount: 2 });
614
- *
615
- * // Apply decay to gradually forget old patterns
616
- * await tracker.applyDecay({ decayFactor: 0.5, minAgeForDecayMs: 86400000 });
617
- * ```
618
- */
619
- export declare class AccessTracker {
620
- private storage;
621
- private accessPatterns;
622
- /**
623
- * Creates a new AccessTracker.
624
- *
625
- * @param storage - The tier storage implementation
626
- *
627
- * @example
628
- * ```typescript
629
- * const tracker = new AccessTracker(storage);
630
- * ```
631
- */
632
- constructor(storage: unknown);
633
- /**
634
- * Records an access operation for an object.
635
- *
636
- * @description
637
- * Tracks a read or write operation, updating the access pattern
638
- * for the object. Can include optional metrics like bytes read
639
- * and latency.
640
- *
641
- * @param sha - The object SHA being accessed
642
- * @param type - Type of access ('read' or 'write')
643
- * @param metrics - Optional additional metrics
644
- *
645
- * @example
646
- * ```typescript
647
- * // Basic access recording
648
- * await tracker.recordAccess(sha, 'read');
649
- *
650
- * // With metrics
651
- * await tracker.recordAccess(sha, 'read', {
652
- * bytesRead: 2048,
653
- * latencyMs: 5
654
- * });
655
- * ```
656
- */
657
- recordAccess(sha: string, type: 'read' | 'write', metrics?: AccessMetrics): Promise<void>;
658
- private persistPattern;
659
- /**
660
- * Gets the access pattern for a specific object.
661
- *
662
- * @description
663
- * Returns detailed access statistics for an object including
664
- * read/write counts, access frequency, and average latency.
665
- *
666
- * @param sha - The object SHA to query
667
- *
668
- * @returns Access pattern for the object
669
- *
670
- * @example
671
- * ```typescript
672
- * const pattern = await tracker.getAccessPattern(sha);
673
- * console.log(`Reads: ${pattern.readCount}`);
674
- * console.log(`Writes: ${pattern.writeCount}`);
675
- * console.log(`Frequency: ${pattern.accessFrequency.toFixed(2)}/sec`);
676
- * ```
677
- */
678
- getAccessPattern(sha: string): Promise<AccessPattern>;
679
- /**
680
- * Identifies frequently accessed (hot) objects.
681
- *
682
- * @description
683
- * Returns SHAs of objects that meet the hot object criteria,
684
- * typically objects with high access counts.
685
- *
686
- * @param criteria - Criteria for identifying hot objects
687
- *
688
- * @returns Array of SHAs for hot objects
689
- *
690
- * @example
691
- * ```typescript
692
- * const hotObjects = await tracker.identifyHotObjects({
693
- * minAccessCount: 100
694
- * });
695
- * console.log(`Found ${hotObjects.length} hot objects`);
696
- * ```
697
- */
698
- identifyHotObjects(criteria: ObjectIdentificationCriteria): Promise<string[]>;
699
- /**
700
- * Identifies rarely accessed (cold) objects.
701
- *
702
- * @description
703
- * Returns SHAs of objects that meet the cold object criteria,
704
- * typically objects with low access counts.
705
- *
706
- * @param criteria - Criteria for identifying cold objects
707
- *
708
- * @returns Array of SHAs for cold objects
709
- *
710
- * @example
711
- * ```typescript
712
- * const coldObjects = await tracker.identifyColdObjects({
713
- * maxAccessCount: 2,
714
- * minAgeMs: 7 * 24 * 60 * 60 * 1000 // 7 days
715
- * });
716
- * console.log(`Found ${coldObjects.length} cold objects for migration`);
717
- * ```
718
- */
719
- identifyColdObjects(criteria: ObjectIdentificationCriteria): Promise<string[]>;
720
- /**
721
- * Applies decay to access counts.
722
- *
723
- * @description
724
- * Reduces access counts by a factor to gradually "forget" old access
725
- * patterns. This helps the system respond to changing usage patterns
726
- * over time.
727
- *
728
- * @param options - Decay configuration options
729
- *
730
- * @example
731
- * ```typescript
732
- * // Run daily to decay access counts by 50%
733
- * await tracker.applyDecay({
734
- * decayFactor: 0.5,
735
- * minAgeForDecayMs: 0 // Apply to all
736
- * });
737
- * ```
738
- */
739
- applyDecay(options: DecayOptions): Promise<void>;
740
- /**
741
- * Gets aggregate access statistics.
742
- *
743
- * @description
744
- * Returns summary statistics about access patterns across all
745
- * tracked objects.
746
- *
747
- * @returns Aggregate access statistics
748
- *
749
- * @example
750
- * ```typescript
751
- * const stats = await tracker.getAccessStats();
752
- * console.log(`Total reads: ${stats.totalReads}`);
753
- * console.log(`Total writes: ${stats.totalWrites}`);
754
- * console.log(`Unique objects: ${stats.uniqueObjectsAccessed}`);
755
- * ```
756
- */
757
- getAccessStats(): Promise<AccessStats>;
758
- /**
759
- * Loads persisted access patterns from storage.
760
- *
761
- * @description
762
- * Restores access patterns that were previously persisted,
763
- * useful for recovering state after a restart.
764
- *
765
- * @example
766
- * ```typescript
767
- * // On startup, restore access patterns
768
- * await tracker.loadFromStorage();
769
- * ```
770
- */
771
- loadFromStorage(): Promise<void>;
772
- }
773
- /**
774
- * Main tier migration service.
775
- *
776
- * @description
777
- * Orchestrates the migration of Git objects between storage tiers.
778
- * Provides both synchronous single-object migration and asynchronous
779
- * job-based migration for long-running operations.
780
- *
781
- * ## Migration Process
782
- *
783
- * 1. Validate object exists and is not already in target tier
784
- * 2. Acquire distributed lock with configurable timeout
785
- * 3. Read data from source tier
786
- * 4. Optionally compute source checksum
787
- * 5. Write data to target tier
788
- * 6. Optionally verify checksum matches
789
- * 7. Update object index to point to new location
790
- * 8. Delete from source tier
791
- * 9. Release lock
792
- *
793
- * If any step fails, the migration is automatically rolled back.
794
- *
795
- * @example
796
- * ```typescript
797
- * const migrator = new TierMigrator(storage);
798
- *
799
- * // Simple migration
800
- * const result = await migrator.migrate(sha, 'hot', 'r2');
801
- * if (result.success) {
802
- * console.log('Migration successful');
803
- * }
804
- *
805
- * // Migration with verification
806
- * const verifiedResult = await migrator.migrate(sha, 'hot', 'r2', {
807
- * verifyChecksum: true,
808
- * lockTimeout: 10000
809
- * });
810
- *
811
- * // Batch migration
812
- * const batchResult = await migrator.migrateBatch(shas, 'hot', 'r2', {
813
- * concurrency: 5
814
- * });
815
- * console.log(`Migrated: ${batchResult.successful.length}`);
816
- *
817
- * // Long-running migration job
818
- * const job = await migrator.startMigrationJob(largeSha, 'hot', 'r2');
819
- * // ... later
820
- * await migrator.completeMigrationJob(job);
821
- * ```
822
- */
823
- export declare class TierMigrator {
824
- private storage;
825
- private activeJobs;
826
- private migrationHistory;
827
- private migratingObjects;
828
- private pendingWrites;
829
- /**
830
- * Creates a new TierMigrator.
831
- *
832
- * @param storage - The tier storage implementation
833
- *
834
- * @example
835
- * ```typescript
836
- * const migrator = new TierMigrator(storage);
837
- * ```
838
- */
839
- constructor(storage: unknown);
840
- /**
841
- * Finds objects that are candidates for migration based on policy.
842
- *
843
- * @description
844
- * Analyzes objects in the hot tier and returns those that meet
845
- * the migration criteria defined in the policy. Results are sorted
846
- * by last access time (oldest first).
847
- *
848
- * @param policy - Migration policy defining criteria
849
- *
850
- * @returns Array of SHAs that are candidates for migration
851
- *
852
- * @example
853
- * ```typescript
854
- * const candidates = await migrator.findMigrationCandidates({
855
- * maxAgeInHot: 7 * 24 * 60 * 60 * 1000, // 7 days
856
- * minAccessCount: 5,
857
- * maxHotSize: 100 * 1024 * 1024
858
- * });
859
- *
860
- * console.log(`Found ${candidates.length} candidates for migration`);
861
- * ```
862
- */
863
- findMigrationCandidates(policy: MigrationPolicy): Promise<string[]>;
864
- /**
865
- * Migrates a single object between tiers.
866
- *
867
- * @description
868
- * Performs a complete migration of an object from the source tier
869
- * to the target tier. Handles locking, data transfer, verification,
870
- * and cleanup.
871
- *
872
- * @param sha - The object SHA to migrate
873
- * @param sourceTier - The source storage tier
874
- * @param targetTier - The target storage tier
875
- * @param options - Optional migration settings
876
- *
877
- * @returns Migration result with success/failure status
878
- *
879
- * @throws {MigrationError} If object not found or already in target tier
880
- *
881
- * @example
882
- * ```typescript
883
- * // Basic migration
884
- * const result = await migrator.migrate(sha, 'hot', 'r2');
885
- *
886
- * // With checksum verification
887
- * const verified = await migrator.migrate(sha, 'hot', 'r2', {
888
- * verifyChecksum: true,
889
- * lockTimeout: 10000
890
- * });
891
- *
892
- * if (verified.success) {
893
- * console.log('Migration successful');
894
- * if (verified.checksumVerified) {
895
- * console.log('Integrity verified');
896
- * }
897
- * } else if (verified.rolledBack) {
898
- * console.log(`Rolled back: ${verified.rollbackReason}`);
899
- * }
900
- * ```
901
- */
902
- migrate(sha: string, sourceTier: StorageTier, targetTier: StorageTier, options?: MigrateOptions): Promise<MigrationResult>;
903
- private recordHistory;
904
- /**
905
- * Starts a long-running migration job.
906
- *
907
- * @description
908
- * Initiates a migration job that can be monitored and completed
909
- * asynchronously. Useful for large objects where progress tracking
910
- * is important.
911
- *
912
- * @param sha - The object SHA to migrate
913
- * @param sourceTier - The source storage tier
914
- * @param targetTier - The target storage tier
915
- *
916
- * @returns The migration job with tracking information
917
- *
918
- * @example
919
- * ```typescript
920
- * const job = await migrator.startMigrationJob(largeSha, 'hot', 'r2');
921
- * console.log(`Job ${job.id} started`);
922
- * console.log(`Progress: ${job.progress.bytesTransferred}/${job.progress.totalBytes}`);
923
- *
924
- * // Complete the job when ready
925
- * await migrator.completeMigrationJob(job);
926
- * ```
927
- */
928
- startMigrationJob(sha: string, sourceTier: StorageTier, targetTier: StorageTier): Promise<MigrationJob>;
929
- /**
930
- * Completes a migration job.
931
- *
932
- * @description
933
- * Finalizes a migration job by updating the index and cleaning up
934
- * the source tier. Also processes any pending writes that occurred
935
- * during the migration.
936
- *
937
- * @param job - The migration job to complete
938
- *
939
- * @example
940
- * ```typescript
941
- * const job = await migrator.startMigrationJob(sha, 'hot', 'r2');
942
- * // ... wait for progress or do other work
943
- * await migrator.completeMigrationJob(job);
944
- * console.log(`Job completed at ${new Date(job.completedAt!)}`);
945
- * ```
946
- */
947
- completeMigrationJob(job: MigrationJob): Promise<void>;
948
- /**
949
- * Rolls back a migration job.
950
- *
951
- * @description
952
- * Cancels a migration job and cleans up any partial data in the
953
- * target tier.
954
- *
955
- * @param job - The migration job to roll back
956
- *
957
- * @example
958
- * ```typescript
959
- * const job = await migrator.startMigrationJob(sha, 'hot', 'r2');
960
- * if (someCondition) {
961
- * await migrator.rollbackMigrationJob(job);
962
- * console.log('Migration rolled back');
963
- * }
964
- * ```
965
- */
966
- rollbackMigrationJob(job: MigrationJob): Promise<void>;
967
- /**
968
- * Cancels a migration job by ID.
969
- *
970
- * @description
971
- * Stops a migration job and cleans up resources.
972
- *
973
- * @param jobId - The job ID to cancel
974
- *
975
- * @example
976
- * ```typescript
977
- * const job = await migrator.startMigrationJob(sha, 'hot', 'r2');
978
- * // Later...
979
- * await migrator.cancelMigrationJob(job.id);
980
- * ```
981
- */
982
- cancelMigrationJob(jobId: string): Promise<void>;
983
- /**
984
- * Gets all active migration jobs.
985
- *
986
- * @description
987
- * Returns jobs that are currently in progress.
988
- *
989
- * @returns Array of active migration jobs
990
- *
991
- * @example
992
- * ```typescript
993
- * const activeJobs = await migrator.getActiveMigrationJobs();
994
- * for (const job of activeJobs) {
995
- * console.log(`${job.id}: ${job.sha} - ${job.progress.bytesTransferred}/${job.progress.totalBytes}`);
996
- * }
997
- * ```
998
- */
999
- getActiveMigrationJobs(): Promise<MigrationJob[]>;
1000
- /**
1001
- * Gets migration history for an object.
1002
- *
1003
- * @description
1004
- * Returns the history of migration events for a specific object.
1005
- *
1006
- * @param sha - The object SHA to query
1007
- *
1008
- * @returns Array of migration history entries
1009
- *
1010
- * @example
1011
- * ```typescript
1012
- * const history = await migrator.getMigrationHistory(sha);
1013
- * for (const entry of history) {
1014
- * console.log(`${new Date(entry.timestamp)}: ${entry.state}`);
1015
- * }
1016
- * ```
1017
- */
1018
- getMigrationHistory(sha: string): Promise<MigrationHistoryEntry[]>;
1019
- /**
1020
- * Migrates multiple objects in a batch.
1021
- *
1022
- * @description
1023
- * Efficiently migrates multiple objects with configurable concurrency.
1024
- * Failed migrations don't affect other objects in the batch.
1025
- *
1026
- * @param shas - Array of object SHAs to migrate
1027
- * @param sourceTier - The source storage tier
1028
- * @param targetTier - The target storage tier
1029
- * @param options - Optional batch migration settings
1030
- *
1031
- * @returns Result with successful and failed SHAs
1032
- *
1033
- * @example
1034
- * ```typescript
1035
- * const result = await migrator.migrateBatch(
1036
- * candidates,
1037
- * 'hot',
1038
- * 'r2',
1039
- * { concurrency: 5 }
1040
- * );
1041
- *
1042
- * console.log(`Migrated: ${result.successful.length}`);
1043
- * console.log(`Failed: ${result.failed.length}`);
1044
- * ```
1045
- */
1046
- migrateBatch(shas: string[], sourceTier: StorageTier, targetTier: StorageTier, options?: BatchMigrationOptions): Promise<BatchMigrationResult>;
1047
- /**
1048
- * Reads object data during an in-progress migration.
1049
- *
1050
- * @description
1051
- * Safely reads data for an object that may be in the process of
1052
- * being migrated. Checks hot tier first, then warm tier.
1053
- *
1054
- * @param sha - The object SHA to read
1055
- *
1056
- * @returns Object data or null if not found
1057
- *
1058
- * @example
1059
- * ```typescript
1060
- * const data = await migrator.readDuringMigration(sha);
1061
- * if (data) {
1062
- * // Process the data regardless of which tier it's in
1063
- * }
1064
- * ```
1065
- */
1066
- readDuringMigration(sha: string): Promise<Uint8Array | null>;
1067
- /**
1068
- * Writes object data during an in-progress migration.
1069
- *
1070
- * @description
1071
- * Safely handles writes for an object that may be in the process
1072
- * of being migrated. If the object is being migrated, the write
1073
- * is queued and replayed after migration completes.
1074
- *
1075
- * @param sha - The object SHA to write
1076
- * @param data - The data to write
1077
- *
1078
- * @example
1079
- * ```typescript
1080
- * // This is safe to call even during migration
1081
- * await migrator.writeDuringMigration(sha, newData);
1082
- * ```
1083
- */
1084
- writeDuringMigration(sha: string, data: Uint8Array): Promise<void>;
1085
- /**
1086
- * Computes SHA-256 checksum for data verification.
1087
- *
1088
- * @description
1089
- * Calculates a SHA-256 hash of the data for integrity verification
1090
- * during migration.
1091
- *
1092
- * @param data - The data to hash
1093
- *
1094
- * @returns Hex-encoded SHA-256 hash
1095
- *
1096
- * @example
1097
- * ```typescript
1098
- * const checksum = await migrator.computeChecksum(data);
1099
- * console.log(`Checksum: ${checksum}`);
1100
- * ```
1101
- */
1102
- computeChecksum(data: Uint8Array): Promise<string>;
1103
- }
1104
- //# sourceMappingURL=migration.d.ts.map