sealkeep 0.8.1 → 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 (275) hide show
  1. package/ARCHITECTURE.md +163 -14
  2. package/CHANGELOG.md +244 -1
  3. package/CONTROL_PLANE.md +2 -2
  4. package/LICENSE +1 -1
  5. package/README.md +108 -22
  6. package/THIRD_PARTY.md +2 -2
  7. package/THREAT_MODEL.md +23 -4
  8. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/chunk-access.d.ts +26 -4
  9. package/dist/packages/sealkeep-crypto/src/chunk-access.js +219 -0
  10. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/envelope.d.ts +11 -1
  11. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/envelope.js +58 -21
  12. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/format.d.ts +2 -2
  13. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/index.d.ts +1 -0
  14. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/index.js +1 -0
  15. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/recipients.js +4 -4
  16. package/dist/packages/sealkeep-crypto/src/squeeze.d.ts +6 -0
  17. package/dist/packages/sealkeep-crypto/src/squeeze.js +39 -0
  18. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/stream.d.ts +36 -3
  19. package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/stream.js +196 -37
  20. package/dist/site/index.html +1808 -1904
  21. package/dist/site/llms.txt +67 -0
  22. package/dist/site/trust/architecture-data-flow.html +53 -0
  23. package/dist/site/trust/audit-roadmap.html +37 -0
  24. package/dist/site/trust/deployment-responsibility.html +11 -0
  25. package/dist/site/trust/dpa-sample.html +30 -0
  26. package/dist/site/trust/release-provenance.html +21 -0
  27. package/dist/site/trust/subprocessors.html +15 -0
  28. package/dist/site/trust/threat-model.html +34 -0
  29. package/dist/site/trust/toms.html +41 -0
  30. package/dist/site/trust-document.css +32 -0
  31. package/dist/site/trust.html +73 -0
  32. package/dist/site/visual/assets/index-8Nxnkc7o.js +207 -0
  33. package/dist/site/visual/assets/index-oxLy1bpy.css +1 -0
  34. package/dist/site/visual/index.html +18 -0
  35. package/dist/site.zip +0 -0
  36. package/dist/src/activity.d.ts +9 -0
  37. package/dist/src/activity.js +90 -1
  38. package/dist/src/adapters.d.ts +175 -5
  39. package/dist/src/adapters.js +961 -73
  40. package/dist/src/agent-context.d.ts +135 -0
  41. package/dist/src/agent-context.js +1059 -0
  42. package/dist/src/archive-copies.d.ts +47 -0
  43. package/dist/src/archive-copies.js +179 -0
  44. package/dist/src/audit.d.ts +1 -1
  45. package/dist/src/audit.js +29 -4
  46. package/dist/src/autopilot.d.ts +52 -7
  47. package/dist/src/autopilot.js +143 -25
  48. package/dist/src/background-bandwidth.d.ts +46 -0
  49. package/dist/src/background-bandwidth.js +301 -0
  50. package/dist/src/background-cpu.d.ts +82 -0
  51. package/dist/src/background-cpu.js +212 -0
  52. package/dist/src/background-worker-error.d.ts +12 -0
  53. package/dist/src/background-worker-error.js +18 -0
  54. package/dist/src/branding.d.ts +24 -1
  55. package/dist/src/branding.js +31 -1
  56. package/dist/src/bridge.d.ts +233 -0
  57. package/dist/src/bridge.js +604 -0
  58. package/dist/src/byte-stream.d.ts +91 -0
  59. package/dist/src/byte-stream.js +385 -0
  60. package/dist/src/chunk-store.d.ts +41 -8
  61. package/dist/src/chunk-store.js +161 -65
  62. package/dist/src/cli.js +1746 -166
  63. package/dist/src/cloud.d.ts +841 -31
  64. package/dist/src/cloud.js +3196 -277
  65. package/dist/src/context-background.d.ts +37 -0
  66. package/dist/src/context-background.js +309 -0
  67. package/dist/src/context-drain-child.d.ts +1 -0
  68. package/dist/src/context-drain-child.js +98 -0
  69. package/dist/src/context-reader.d.ts +118 -0
  70. package/dist/src/context-reader.js +447 -0
  71. package/dist/src/control-plane/auth.d.ts +32 -4
  72. package/dist/src/control-plane/auth.js +85 -24
  73. package/dist/src/control-plane/server.js +19 -6
  74. package/dist/src/control-plane.d.ts +17 -1
  75. package/dist/src/control-plane.js +32 -6
  76. package/dist/src/crypto.d.ts +1 -1
  77. package/dist/src/crypto.js +5 -5
  78. package/dist/src/daemon-lease.d.ts +70 -0
  79. package/dist/src/daemon-lease.js +420 -0
  80. package/dist/src/daemon.d.ts +94 -1
  81. package/dist/src/daemon.js +1082 -105
  82. package/dist/src/darwin-service-policy.d.ts +41 -0
  83. package/dist/src/darwin-service-policy.js +60 -0
  84. package/dist/src/dashboard-cli.js +15 -15
  85. package/dist/src/device-authorization.d.ts +37 -0
  86. package/dist/src/device-authorization.js +199 -0
  87. package/dist/src/device-enrollment.d.ts +91 -0
  88. package/dist/src/device-enrollment.js +349 -0
  89. package/dist/src/disk.d.ts +17 -12
  90. package/dist/src/disk.js +43 -17
  91. package/dist/src/doctor.d.ts +35 -1
  92. package/dist/src/doctor.js +316 -41
  93. package/dist/src/durable-ticket-lock.d.ts +24 -0
  94. package/dist/src/durable-ticket-lock.js +232 -0
  95. package/dist/src/enroll.d.ts +1 -1
  96. package/dist/src/enroll.js +13 -7
  97. package/dist/src/env.d.ts +10 -1
  98. package/dist/src/env.js +11 -3
  99. package/dist/src/errors.d.ts +8 -8
  100. package/dist/src/errors.js +6 -6
  101. package/dist/src/flush.d.ts +12 -0
  102. package/dist/src/flush.js +37 -0
  103. package/dist/src/heartbeat.d.ts +86 -12
  104. package/dist/src/heartbeat.js +415 -29
  105. package/dist/src/index-background-watchdog.d.ts +1 -0
  106. package/dist/src/index-background-watchdog.js +94 -0
  107. package/dist/src/index-background-work.d.ts +21 -0
  108. package/dist/src/index-background-work.js +25 -0
  109. package/dist/src/index-background.d.ts +64 -0
  110. package/dist/src/index-background.js +394 -0
  111. package/dist/src/index-build-child.d.ts +1 -0
  112. package/dist/src/index-build-child.js +109 -0
  113. package/dist/src/index-manifest.d.ts +52 -0
  114. package/dist/src/index-manifest.js +444 -0
  115. package/dist/src/index-publication-proof.d.ts +84 -0
  116. package/dist/src/index-publication-proof.js +380 -0
  117. package/dist/src/index-publication-state.d.ts +149 -0
  118. package/dist/src/index-publication-state.js +696 -0
  119. package/dist/src/index-publication-verifier.d.ts +89 -0
  120. package/dist/src/index-publication-verifier.js +341 -0
  121. package/dist/src/index-publish.d.ts +62 -0
  122. package/dist/src/index-publish.js +540 -0
  123. package/dist/src/index-scratch-cleanup.d.ts +19 -0
  124. package/dist/src/index-scratch-cleanup.js +166 -0
  125. package/dist/src/index-segment-types.d.ts +132 -0
  126. package/dist/src/index-segment-types.js +21 -0
  127. package/dist/src/index-segments.d.ts +9 -0
  128. package/dist/src/index-segments.js +516 -0
  129. package/dist/src/index-store.d.ts +123 -0
  130. package/dist/src/index-store.js +495 -0
  131. package/dist/src/index-sync.d.ts +91 -15
  132. package/dist/src/index-sync.js +286 -53
  133. package/dist/src/index-upgrade-publication.d.ts +30 -0
  134. package/dist/src/index-upgrade-publication.js +179 -0
  135. package/dist/src/integration-manager.d.ts +32 -0
  136. package/dist/src/integration-manager.js +394 -0
  137. package/dist/src/leakscan.js +1 -1
  138. package/dist/src/local-api.d.ts +56 -15
  139. package/dist/src/local-api.js +4979 -541
  140. package/dist/src/machine-settings.d.ts +51 -0
  141. package/dist/src/machine-settings.js +166 -0
  142. package/dist/src/managed-chunks.d.ts +5 -2
  143. package/dist/src/managed-chunks.js +14 -14
  144. package/dist/src/mcp-install.d.ts +11 -9
  145. package/dist/src/mcp-install.js +73 -28
  146. package/dist/src/mcp-workspace.d.ts +18 -0
  147. package/dist/src/mcp-workspace.js +50 -0
  148. package/dist/src/mcp.js +294 -25
  149. package/dist/src/migrate.d.ts +1 -0
  150. package/dist/src/migrate.js +33 -5
  151. package/dist/src/notify.d.ts +1 -1
  152. package/dist/src/notify.js +5 -5
  153. package/dist/src/offload.d.ts +201 -14
  154. package/dist/src/offload.js +1848 -140
  155. package/dist/src/onboarding.d.ts +8 -1
  156. package/dist/src/onboarding.js +4 -4
  157. package/dist/src/packages.d.ts +2 -2
  158. package/dist/src/packages.js +10 -2
  159. package/dist/src/passkey.d.ts +0 -1
  160. package/dist/src/passkey.js +2 -7
  161. package/dist/src/password-lock.d.ts +2 -2
  162. package/dist/src/password-lock.js +6 -6
  163. package/dist/src/paths.d.ts +2 -0
  164. package/dist/src/paths.js +2 -0
  165. package/dist/src/presence.d.ts +86 -0
  166. package/dist/src/presence.js +240 -0
  167. package/dist/src/progress-deadline.d.ts +21 -0
  168. package/dist/src/progress-deadline.js +91 -0
  169. package/dist/src/project-repair.d.ts +55 -0
  170. package/dist/src/project-repair.js +131 -0
  171. package/dist/src/providers/gcs.d.ts +28 -7
  172. package/dist/src/providers/gcs.js +35 -24
  173. package/dist/src/providers/gdrive.d.ts +71 -8
  174. package/dist/src/providers/gdrive.js +223 -50
  175. package/dist/src/providers/index.d.ts +11 -3
  176. package/dist/src/providers/index.js +30 -10
  177. package/dist/src/providers/s3.d.ts +30 -8
  178. package/dist/src/providers/s3.js +41 -30
  179. package/dist/src/providers/safe-storage-fetch.d.ts +12 -0
  180. package/dist/src/providers/safe-storage-fetch.js +72 -0
  181. package/dist/src/queue.d.ts +136 -19
  182. package/dist/src/queue.js +862 -96
  183. package/dist/src/reclaim-transaction.d.ts +156 -0
  184. package/dist/src/reclaim-transaction.js +1027 -0
  185. package/dist/src/recovery-codes.d.ts +32 -0
  186. package/dist/src/recovery-codes.js +338 -0
  187. package/dist/src/recovery.js +12 -9
  188. package/dist/src/rehydrate.d.ts +25 -22
  189. package/dist/src/rehydrate.js +319 -23
  190. package/dist/src/restore.d.ts +57 -4
  191. package/dist/src/restore.js +272 -36
  192. package/dist/src/resume-stub.d.ts +92 -0
  193. package/dist/src/resume-stub.js +417 -0
  194. package/dist/src/retention.d.ts +98 -7
  195. package/dist/src/retention.js +1066 -62
  196. package/dist/src/rotate.js +3 -3
  197. package/dist/src/search.d.ts +566 -8
  198. package/dist/src/search.js +5897 -290
  199. package/dist/src/secrets.d.ts +51 -7
  200. package/dist/src/secrets.js +316 -24
  201. package/dist/src/service.d.ts +49 -11
  202. package/dist/src/service.js +776 -35
  203. package/dist/src/share.js +3 -3
  204. package/dist/src/shared-spaces.d.ts +98 -0
  205. package/dist/src/shared-spaces.js +214 -0
  206. package/dist/src/source-reader.d.ts +73 -0
  207. package/dist/src/source-reader.js +715 -0
  208. package/dist/src/spool.d.ts +1 -1
  209. package/dist/src/spool.js +1 -1
  210. package/dist/src/start-tui.js +2 -1
  211. package/dist/src/start.js +2 -2
  212. package/dist/src/storage-endpoint.d.ts +21 -0
  213. package/dist/src/storage-endpoint.js +122 -0
  214. package/dist/src/storage-setup.js +12 -12
  215. package/dist/src/storage-targets.d.ts +109 -6
  216. package/dist/src/storage-targets.js +975 -67
  217. package/dist/src/stream-to-cloud.d.ts +5 -1
  218. package/dist/src/stream-to-cloud.js +34 -14
  219. package/dist/src/sync-rules.d.ts +31 -6
  220. package/dist/src/sync-rules.js +153 -14
  221. package/dist/src/team-backfill-scheduling.d.ts +8 -0
  222. package/dist/src/team-backfill-scheduling.js +33 -0
  223. package/dist/src/team-backfill.d.ts +116 -0
  224. package/dist/src/team-backfill.js +1429 -0
  225. package/dist/src/team-index-cache.d.ts +16 -0
  226. package/dist/src/team-index-cache.js +152 -0
  227. package/dist/src/team-offboarding.d.ts +38 -0
  228. package/dist/src/team-offboarding.js +1043 -0
  229. package/dist/src/team-presence.d.ts +127 -0
  230. package/dist/src/team-presence.js +904 -0
  231. package/dist/src/team-publication-policy.d.ts +20 -0
  232. package/dist/src/team-publication-policy.js +140 -0
  233. package/dist/src/team-realtime.d.ts +68 -0
  234. package/dist/src/team-realtime.js +816 -0
  235. package/dist/src/team-source-facts-cache.d.ts +23 -0
  236. package/dist/src/team-source-facts-cache.js +255 -0
  237. package/dist/src/trash.d.ts +1 -1
  238. package/dist/src/trash.js +2 -2
  239. package/dist/src/tui.js +11 -12
  240. package/dist/src/types.d.ts +173 -7
  241. package/dist/src/types.js +20 -0
  242. package/dist/src/ui-server.d.ts +163 -35
  243. package/dist/src/ui-server.js +712 -72
  244. package/dist/src/ui.d.ts +1 -2
  245. package/dist/src/ui.js +1 -2
  246. package/dist/src/upload.d.ts +27 -0
  247. package/dist/src/upload.js +383 -43
  248. package/dist/src/vault.d.ts +235 -29
  249. package/dist/src/vault.js +1783 -190
  250. package/dist/src/watcher.d.ts +7 -1
  251. package/dist/src/watcher.js +198 -55
  252. package/dist/src/worker.d.ts +27 -3
  253. package/dist/src/worker.js +274 -55
  254. package/package.json +33 -12
  255. package/scripts/native-reboot-rehearsal.mjs +90 -0
  256. package/web/app.js +6032 -343
  257. package/web/bootstrap.js +17 -0
  258. package/web/index.html +255 -57
  259. package/web/rail.js +317 -40
  260. package/web/retention.html +2 -2
  261. package/web/rules-view.js +188 -16
  262. package/web/sessions-view.js +485 -62
  263. package/web/sessions.html +2 -2
  264. package/web/setup-api.js +152 -29
  265. package/web/setup-logic.js +68 -9
  266. package/web/setup.html +113 -44
  267. package/web/setup.js +604 -71
  268. package/web/style.css +513 -98
  269. package/dist/packages/vaultline-crypto/src/chunk-access.js +0 -93
  270. /package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/aead.d.ts +0 -0
  271. /package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/aead.js +0 -0
  272. /package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/format.js +0 -0
  273. /package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/recipients.d.ts +0 -0
  274. /package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/sha256-stream.d.ts +0 -0
  275. /package/dist/packages/{vaultline-crypto → sealkeep-crypto}/src/sha256-stream.js +0 -0
@@ -1,5 +1,6 @@
1
- import { type ArchiveRecord } from "./types.js";
2
- import { createActiveLease } from "./providers/index.js";
1
+ import { type ArchiveRecord, type ArchiveRecordV2, type RemoteObject } from "./types.js";
2
+ import { createActiveLease, type EndpointOverrides } from "./providers/index.js";
3
+ import { type ByteStream } from "./byte-stream.js";
3
4
  /**
4
5
  * Removing the local copy of an archive that lives in a bucket.
5
6
  *
@@ -11,12 +12,15 @@ import { createActiveLease } from "./providers/index.js";
11
12
  *
12
13
  * Offloading finishes the job: once the bucket has a verified copy, the local
13
14
  * one is redundant, and restoring downloads it back. Nothing is lost — but the
14
- * archive stops being reachable while offline, which is a real trade and the
15
- * reason this is opt-in and never automatic.
15
+ * archive stops being reachable while offline, which is a real trade. The
16
+ * daemon runs it automatically once an upload VERIFIES — freeing the disk is
17
+ * that loop's whole purpose — so the safety here is the verification gate,
18
+ * not an opt-in. (This comment used to claim "never automatic" while
19
+ * heartbeat.ts called it on every successful upload.)
16
20
  *
17
- * The bar for removing a local archive is deliberately higher than for
18
- * reclaiming a source: a source that was reclaimed can still be recovered from
19
- * the trash, while an archive removed without a genuine remote copy is gone.
21
+ * Removing either a local archive or a native source requires a genuine,
22
+ * verified remote copy. Source reclaim is an explicit/opt-in permanent purge;
23
+ * the encrypted archive remains the recovery copy after local bytes are freed.
20
24
  */
21
25
  /**
22
26
  * Just enough of a provider client to read an archive back. Injectable for the
@@ -24,7 +28,12 @@ import { createActiveLease } from "./providers/index.js";
24
28
  * offloaded archive can be recovered has to be testable without a bucket.
25
29
  */
26
30
  export type FetchClient = {
27
- download?: (lease: ReturnType<typeof createActiveLease>) => Promise<Buffer>;
31
+ download?: (lease: ReturnType<typeof createActiveLease>, options?: {
32
+ signal?: AbortSignal;
33
+ }) => Promise<Buffer>;
34
+ downloadStream?: (lease: ReturnType<typeof createActiveLease>, options?: {
35
+ signal?: AbortSignal;
36
+ }) => Promise<ByteStream>;
28
37
  };
29
38
  export type OffloadCandidate = {
30
39
  id: string;
@@ -32,19 +41,93 @@ export type OffloadCandidate = {
32
41
  path: string;
33
42
  /** What removing the local copy would give back. */
34
43
  localBytes: number;
44
+ /** Filesystem blocks released when this is the inode's final named link. */
45
+ allocatedBytes: number;
35
46
  provider: string;
36
47
  bucket: string;
37
48
  objectKey: string;
49
+ /** Exact verified copy selected as the restore source. */
50
+ copyId?: string;
38
51
  };
39
52
  export type OffloadBlocked = {
40
53
  id: string;
41
54
  reason: string;
42
55
  };
43
- export declare function offloadable(dataDir: string): Promise<{
56
+ export type OffloadOptions = {
57
+ /** Narrow a sweep to records at least this many days old. */
58
+ olderThanDays?: number;
59
+ /** Clock used by the age policy; injectable for deterministic previews/tests. */
60
+ now?: number;
61
+ /** Narrow a sweep to these archive ids. */
62
+ only?: ReadonlySet<string>;
63
+ /** Lets the daemon stop a long read-back proof without deleting anything. */
64
+ signal?: AbortSignal;
65
+ /** Aggregate ceiling used only by automatic/background read-back proofs. */
66
+ maxBytesPerSecond?: number;
67
+ /** Deterministic transaction seams; production callers never provide them. */
68
+ operations?: {
69
+ afterJournal?: (transaction: OffloadTransaction) => void | Promise<void>;
70
+ afterLinked?: (transaction: OffloadTransaction) => void | Promise<void>;
71
+ afterRemoteVerified?: (transaction: OffloadTransaction) => void | Promise<void>;
72
+ afterMetadata?: (transaction: OffloadTransaction) => void | Promise<void>;
73
+ afterSourceUnlinked?: (transaction: OffloadTransaction) => void | Promise<void>;
74
+ afterPurgeAuthorized?: (transaction: OffloadTransaction) => void | Promise<void>;
75
+ beforeStagingUnlink?: (transaction: OffloadTransaction) => void | Promise<void>;
76
+ afterStagingPurged?: (transaction: OffloadTransaction) => void | Promise<void>;
77
+ };
78
+ };
79
+ /**
80
+ * The local-cache clock starts only after both facts are true: the archive
81
+ * exists and an off-machine copy has been verified. An old archive uploaded
82
+ * today therefore receives the same complete cache period as a new one.
83
+ */
84
+ export declare function archiveCacheReferenceTime(record: ArchiveRecord): number;
85
+ export declare function offloadable(dataDir: string, options?: OffloadOptions): Promise<{
44
86
  candidates: OffloadCandidate[];
45
87
  blocked: OffloadBlocked[];
46
88
  freeableBytes: number;
47
89
  }>;
90
+ type OffloadStage = "prepared" | "linked" | "remote-verified" | "metadata-committed" | "source-unlinked" | "purge-authorized";
91
+ type OffloadFileIdentity = {
92
+ bytes: number;
93
+ allocatedBytes: number;
94
+ links: number;
95
+ dev: string;
96
+ ino: string;
97
+ };
98
+ /** Durable intent for removing one immutable local encrypted archive. */
99
+ export type OffloadTransaction = {
100
+ version: 1;
101
+ id: string;
102
+ archiveId: string;
103
+ objectPath: string;
104
+ stagingPath: string;
105
+ createdAt: string;
106
+ updatedAt: string;
107
+ stage: OffloadStage;
108
+ original: OffloadFileIdentity;
109
+ /** Exact final inode state authorised for the staged-name unlink. */
110
+ purgeSnapshot?: OffloadFileIdentity;
111
+ remote: {
112
+ copyId?: string;
113
+ destinationKey?: string;
114
+ provider: string;
115
+ bucket: string;
116
+ objectKey: string;
117
+ };
118
+ };
119
+ export declare function offloadJournalPath(dataDir: string, id: string): string;
120
+ export declare function reconcileOffloadTransactions(dataDir: string, options?: OffloadOptions & {
121
+ client?: FetchClient;
122
+ overrides?: EndpointOverrides;
123
+ }): Promise<{
124
+ completed: OffloadCandidate[];
125
+ failed: {
126
+ id: string;
127
+ error: string;
128
+ }[];
129
+ freedBytes: number;
130
+ }>;
48
131
  /**
49
132
  * Removes local archives that a bucket has a verified copy of.
50
133
  *
@@ -52,10 +135,10 @@ export declare function offloadable(dataDir: string): Promise<{
52
135
  * accepted from a caller, so a page held open since yesterday cannot ask for
53
136
  * the deletion of something that has since become the only copy.
54
137
  */
55
- export declare function offloadArchives(dataDir: string, options?: {
138
+ export declare function offloadArchives(dataDir: string, options?: OffloadOptions & {
56
139
  confirm?: boolean;
57
140
  client?: FetchClient;
58
- only?: ReadonlySet<string>;
141
+ overrides?: EndpointOverrides;
59
142
  freshlyVerified?: ReadonlySet<string>;
60
143
  }): Promise<{
61
144
  mode: "preview";
@@ -75,13 +158,23 @@ export declare function offloadArchives(dataDir: string, options?: {
75
158
  freedBytes: number;
76
159
  wouldOffload?: undefined;
77
160
  }>;
161
+ /**
162
+ * Downloads an archive's ciphertext from the bucket it was offloaded to.
163
+ *
164
+ * SEALKEEP_ENABLE_SIGNER gates *uploading*, and it is off unless the installed
165
+ * service turns it on. Reading back an archive in order to restore it is not
166
+ * uploading, and refusing it on that flag would mean an offloaded archive could
167
+ * not be recovered by the person who owns it — which would turn a space-saving
168
+ * feature into data loss. The flag is set for this call only.
169
+ */
170
+ export declare function fetchCiphertextStream(dataDir: string, record: ArchiveRecordV2, client?: FetchClient, selectedCopy?: RemoteObject, overrides?: EndpointOverrides, signal?: AbortSignal, idleMs?: number, maxBytesPerSecond?: number): Promise<ByteStream>;
78
171
  /**
79
172
  * Asks the storage, right now, whether it still holds this archive.
80
173
  *
81
174
  * `remote.verifiedAt` says the copy was proven once; between then and now is
82
175
  * exactly where a bucket lifecycle rule or a fat-fingered console delete
83
176
  * lives. This is the question a person asks before trusting the cloud copy
84
- * enough to trash the original — so it goes to the provider, not to our own
177
+ * enough to reclaim the original — so it goes to the provider, not to our own
85
178
  * records, and it compares the size the provider reports against the size we
86
179
  * recorded. It does not re-download the object: the byte-level proof already
87
180
  * ran when the copy was verified, and runs again on any restore (AEAD refuses
@@ -94,7 +187,7 @@ export type CopyCheck = {
94
187
  checkedAt: string;
95
188
  detail: string;
96
189
  };
97
- export declare function checkRemoteCopy(dataDir: string, archiveId: string, client?: FetchClient): Promise<CopyCheck>;
190
+ export declare function checkRemoteCopy(dataDir: string, archiveId: string, client?: FetchClient, copyId?: string): Promise<CopyCheck>;
98
191
  /**
99
192
  * The bulk form of `checkRemoteCopy`. Managed rows share ONE control-plane
100
193
  * listing instead of asking per archive — checking a 53-row vault is one call
@@ -105,6 +198,99 @@ export type Materialised = {
105
198
  path: string;
106
199
  release: () => Promise<void>;
107
200
  };
201
+ export type MaterialiseOptions = {
202
+ /** Fetch this exact stored copy rather than whichever copy is primary. */
203
+ copyId?: string;
204
+ overrides?: EndpointOverrides;
205
+ /**
206
+ * Caller-owned scratch pathname. The transfer journal uses this so a
207
+ * restart knows exactly which temporary bytes it owns and may remove.
208
+ */
209
+ path?: string;
210
+ /** Cancels a queued or active scratch fetch. Historical indexing uses this
211
+ * when its owning daemon stops, so the partial is removed before the child
212
+ * exits whenever the provider is still making progress. */
213
+ signal?: AbortSignal;
214
+ /** Cumulative verified staging bytes, for the caller's idle deadline. */
215
+ onProgress?: (bytes: number) => void;
216
+ /** Background callers share the vault-wide transfer bucket; manual restores
217
+ * remain explicitly unpaced unless their caller requests this ceiling. */
218
+ maxBytesPerSecond?: number;
219
+ /** Cooperative CPU checkpoint while hashing/staging a remote body. */
220
+ onYield?: () => void | Promise<void>;
221
+ /** Test/embedding seam. Ordinary callers use the operating-system temp
222
+ * directory; the chosen directory must already exist. */
223
+ scratchRoot?: string;
224
+ /** Maximum time to wait for another process that owns archive-sized scratch
225
+ * space. The default is deliberately short enough for an interactive action
226
+ * to finish with a retryable answer instead of looking permanently stuck. */
227
+ scratchWaitMs?: number;
228
+ };
229
+ /**
230
+ * Processes from different vaults can still spend the same filesystem's free
231
+ * bytes. Key the well-known lease by the scratch directory's device id in a
232
+ * per-user temp namespace; fall back to this vault's trusted runtime directory
233
+ * only on platforms where that identity cannot be established.
234
+ */
235
+ export declare function ensurePrivateScratchCoordination(baseDir: string, user: string, expectedUid?: number | undefined): Promise<string>;
236
+ /**
237
+ * Restores the sealed archive blob itself to this machine without decrypting
238
+ * the session. This is the safe first half of a remote-to-remote move: once a
239
+ * verified local blob exists, the ordinary target upload can copy it anywhere
240
+ * without buffering two providers through the browser or risking the source.
241
+ */
242
+ export declare function restoreArchiveLocal(dataDir: string, archiveId: string, options?: {
243
+ copyId?: string;
244
+ client?: FetchClient;
245
+ overrides?: EndpointOverrides;
246
+ signal?: AbortSignal;
247
+ onProgress?: (bytes: number) => void;
248
+ }): Promise<{
249
+ restored: boolean;
250
+ alreadyPresent: boolean;
251
+ bytes: number;
252
+ path: string;
253
+ }>;
254
+ export type RestoreArchiveChainLocalResult = {
255
+ /** True when at least one encrypted chain link was downloaded. */
256
+ restored: boolean;
257
+ /** True only when every required link was already present and verified. */
258
+ alreadyPresent: boolean;
259
+ /** Total encrypted bytes the complete local chain occupies. */
260
+ bytes: number;
261
+ /** Encrypted bytes downloaded by this call. */
262
+ restoredBytes: number;
263
+ /** Canonical local path of the selected head. */
264
+ path: string;
265
+ /** Oldest complete base first, selected head last. */
266
+ chain: string[];
267
+ restoredArchiveIds: string[];
268
+ alreadyPresentArchiveIds: string[];
269
+ };
270
+ /**
271
+ * Restore one logical session's complete encrypted delta chain.
272
+ *
273
+ * Every missing link is downloaded into a private sibling temporary file and
274
+ * checked against its authenticated ciphertext length and digest first. Only
275
+ * after the *whole* chain passes are the files hard-linked into their canonical
276
+ * paths. A hard link gives us an exclusive publish operation: another process
277
+ * cannot race this restore into overwriting an existing archive. If any publish
278
+ * fails, every path published by this call is removed again, while all remote
279
+ * copies and archive records remain untouched.
280
+ *
281
+ * Metadata is changed only after every required local file exists. A metadata
282
+ * write failure deliberately keeps the complete verified local chain as an
283
+ * extra safe copy and leaves all remote copies in place; it can never expose a
284
+ * head without its base or authorize a provider delete.
285
+ */
286
+ export declare function restoreArchiveChainLocal(dataDir: string, archiveId: string, options?: {
287
+ /** Exact source for the selected head. */
288
+ copyId?: string;
289
+ /** Exact sources selected by the caller for individual chain links. */
290
+ copyIds?: Readonly<Record<string, string>>;
291
+ client?: FetchClient;
292
+ overrides?: EndpointOverrides;
293
+ }): Promise<RestoreArchiveChainLocalResult>;
108
294
  /**
109
295
  * Gives back a local path holding this archive's ciphertext, fetching it first
110
296
  * if the local copy was offloaded.
@@ -114,4 +300,5 @@ export type Materialised = {
114
300
  * one and removed afterwards, which keeps the disk saving intact: the bytes are
115
301
  * on this machine only for as long as the restore takes.
116
302
  */
117
- export declare function materialiseArchive(dataDir: string, record: ArchiveRecord, client?: FetchClient): Promise<Materialised>;
303
+ export declare function materialiseArchive(dataDir: string, record: ArchiveRecord, client?: FetchClient, options?: MaterialiseOptions): Promise<Materialised>;
304
+ export {};