@amalgm/live 0.2.59 → 0.2.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PURPOSE.md +17 -5
- package/dist/transfer/download.d.ts +65 -25
- package/dist/transfer/download.d.ts.map +1 -1
- package/dist/transfer/download.js +339 -84
- package/dist/transfer/download.js.map +1 -1
- package/dist/transfer/ranges.d.ts +20 -35
- package/dist/transfer/ranges.d.ts.map +1 -1
- package/dist/transfer/ranges.js +35 -121
- package/dist/transfer/ranges.js.map +1 -1
- package/dist/transfer/refs.d.ts +15 -14
- package/dist/transfer/refs.d.ts.map +1 -1
- package/dist/transfer/refs.js +33 -37
- package/dist/transfer/refs.js.map +1 -1
- package/dist-cjs/transfer/download.js +339 -85
- package/dist-cjs/transfer/download.js.map +1 -1
- package/dist-cjs/transfer/ranges.js +37 -124
- package/dist-cjs/transfer/ranges.js.map +1 -1
- package/dist-cjs/transfer/refs.js +34 -38
- package/dist-cjs/transfer/refs.js.map +1 -1
- package/package.json +1 -1
package/PURPOSE.md
CHANGED
|
@@ -204,11 +204,12 @@ its cutover.
|
|
|
204
204
|
complete-file allocation in the bounded transfer path.
|
|
205
205
|
31. **A content block is not a round trip.** Text and binary retain independent
|
|
206
206
|
content-addressed block identities. Cold upload moves complete small
|
|
207
|
-
artifacts in bounded cargo segments and adjacent missing large-file
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
artifacts in bounded cargo segments and adjacent missing large-file blocks
|
|
208
|
+
in bounded binary batches. Cold download plans whole waves against
|
|
209
|
+
placement: all missing manifests, then all missing blocks, each wave
|
|
210
|
+
grouped by pack so adjacent members merge into bounded range reads.
|
|
211
|
+
Packing may reduce transport work but can never weaken per-block
|
|
212
|
+
verification, durable sealing, or commit order.
|
|
212
213
|
32. **A content layout owns a cloud namespace.** A writer change that derives
|
|
213
214
|
different block identities for the same complete bytes advances the
|
|
214
215
|
content contract and storage namespace together. Readers remain additive;
|
|
@@ -297,6 +298,17 @@ its cutover.
|
|
|
297
298
|
current pointer atomically. Retries never reactivate an older id, prior
|
|
298
299
|
deployments remain addressable, and SQLite rows, WAL pages, locks, and
|
|
299
300
|
offsets remain machine-local materializations rather than sync payloads.
|
|
301
|
+
44. **Sealed answers correctness; packed answers placement.** `sealed` proves
|
|
302
|
+
an artifact's bytes are durably valid under the current content contract,
|
|
303
|
+
and record submission trusts it unconditionally, whatever the placement.
|
|
304
|
+
`packed` proves the artifact is stored efficiently inside an immutable
|
|
305
|
+
pack — and one manifest location row proves its complete packed closure,
|
|
306
|
+
because the authority records every block location and the manifest
|
|
307
|
+
location before sealing. Upload skips a small artifact only when it is
|
|
308
|
+
both sealed and packed; a large artifact requires only sealed. Repacking
|
|
309
|
+
is placement work, never correctness work: placement rows converge
|
|
310
|
+
first-wins, a source missing at repack time is skipped silently, and
|
|
311
|
+
what readers can open never changes.
|
|
300
312
|
|
|
301
313
|
## Five surfaces, one behavior
|
|
302
314
|
|
|
@@ -1,37 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Download a set of immutable artifacts into a machine cache.
|
|
3
3
|
*
|
|
4
|
-
* The set is the primitive
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* The set is the primitive and the plan is physical. Wave one proves every
|
|
5
|
+
* manifest: locally held ones are checked in place, missing ones are
|
|
6
|
+
* resolved as one want-list and fetched grouped by the pack that holds
|
|
7
|
+
* them. Wave two reads the proven manifests, asks the cache which chunks
|
|
8
|
+
* are gaps, resolves the whole gap list, and fetches it the same way: all
|
|
9
|
+
* members of one pack collapse into a few broad byte spans — approximately
|
|
10
|
+
* one read per pack — while standalone objects remain one read each. A
|
|
11
|
+
* lone artifact is a set of one; there is no second download path.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Spans complete in whatever order storage answers, but each artifact
|
|
14
14
|
* stores its chunks in chunk order: a verified chunk waits until every
|
|
15
|
-
* earlier gap of the same artifact
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* earlier gap of the same artifact is stored, so a host assembling a
|
|
16
|
+
* whole-file digest never re-reads what landed early. The scheduler admits
|
|
17
|
+
* fetch units strictly in fair plan order, and the plan orders units so a
|
|
18
|
+
* chunk's predecessor always lives in the same or an earlier unit — an
|
|
19
|
+
* artifact whose gaps do not line up ascending inside one pack falls back
|
|
20
|
+
* to per-object reads at its own positions — so ordered stores can never
|
|
21
|
+
* deadlock. Chains enter the plan round-robin by depth, so one multi-chunk
|
|
22
|
+
* artifact cannot monopolize the bounded window while unrelated artifacts
|
|
23
|
+
* wait. In-flight span bytes stay inside one explicit bound; raising request
|
|
24
|
+
* concurrency never silently raises memory.
|
|
19
25
|
*
|
|
20
|
-
* Every
|
|
21
|
-
* envelope lives alone or as a byte range inside an immutable pack
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
26
|
+
* Every object keeps one content-addressed identity whether its sealed
|
|
27
|
+
* envelope lives alone or as a byte range inside an immutable pack, and
|
|
28
|
+
* placement is immutable: a retried read may refresh its URL but never its
|
|
29
|
+
* geometry. Wrong or shifted bytes cannot leak — every dispensed slice is
|
|
30
|
+
* still an authenticated envelope the host opens and this engine
|
|
31
|
+
* hash-verifies before a single byte is stored.
|
|
25
32
|
*/
|
|
26
33
|
import { type ContentManifest } from '../contracts/content.js';
|
|
27
34
|
import type { Sha256Hex } from '../entities/types.js';
|
|
28
35
|
import { type TransferArtifact } from './artifacts.js';
|
|
36
|
+
import { type ByteSpan } from './ranges.js';
|
|
37
|
+
import { type ContentObjectName, type ContentRef } from './refs.js';
|
|
29
38
|
export interface DownloadPorts<LocalArtifact> {
|
|
30
39
|
readonly sha256Hex: Sha256Hex;
|
|
31
|
-
|
|
40
|
+
/** A manifest the host already holds for this artifact, or null to have
|
|
41
|
+
* the set fetch it. A hint only — the answer is still proven here. */
|
|
42
|
+
localManifest(artifact: TransferArtifact): unknown;
|
|
43
|
+
/** Resolve one batch of named objects to storage locations, aligned by
|
|
44
|
+
* index. Called with at most CONTENT_REFS_BATCH_OBJECTS names. */
|
|
45
|
+
requestRefs(objects: readonly ContentObjectName[]): Promise<readonly ContentRef[]>;
|
|
46
|
+
/** Perform one storage read: a byte range of a pack, or a whole
|
|
47
|
+
* standalone object when span is null. `refresh` re-resolves the read's
|
|
48
|
+
* location for a retry attempt and throws loudly if placement moved. */
|
|
49
|
+
fetchSpan(url: string, span: ByteSpan | null, refresh: () => Promise<string>): Promise<Uint8Array>;
|
|
50
|
+
/** Open one sealed envelope into its plaintext bytes. */
|
|
51
|
+
openEnvelope(object: ContentObjectName, sealed: Uint8Array): Promise<Uint8Array>;
|
|
52
|
+
/** A fetched manifest just proved against its artifact; the host persists
|
|
53
|
+
* it wherever this artifact is being assembled. */
|
|
54
|
+
manifestProven(artifact: TransferArtifact, manifest: ContentManifest): Promise<void>;
|
|
32
55
|
/** True only when this exact content-addressed chunk is locally verified. */
|
|
33
56
|
hasChunk(artifact: TransferArtifact, manifest: ContentManifest, index: number): Promise<boolean>;
|
|
34
|
-
getChunk(artifact: TransferArtifact, manifest: ContentManifest, index: number): Promise<Uint8Array>;
|
|
35
57
|
putChunk(artifact: TransferArtifact, manifest: ContentManifest, index: number, bytes: Uint8Array): Promise<void>;
|
|
36
58
|
/** Verify and expose the complete immutable artifact assembled from cache. */
|
|
37
59
|
sealArtifact(artifact: TransferArtifact, manifest: ContentManifest): Promise<SealedArtifact<LocalArtifact>>;
|
|
@@ -43,8 +65,10 @@ export interface SealedArtifact<LocalArtifact> {
|
|
|
43
65
|
}
|
|
44
66
|
export interface DownloadOptions {
|
|
45
67
|
readonly concurrency?: number;
|
|
46
|
-
/** Maximum
|
|
47
|
-
*
|
|
68
|
+
/** Maximum bytes held by in-flight fetch units. Raising request
|
|
69
|
+
* concurrency never silently raises this memory bound. A single sealed
|
|
70
|
+
* envelope larger than the bound still fetches whole; admission then
|
|
71
|
+
* serializes around it. */
|
|
48
72
|
readonly maxInFlightBytes?: number;
|
|
49
73
|
}
|
|
50
74
|
export interface DownloadReceipt<LocalArtifact> {
|
|
@@ -54,10 +78,26 @@ export interface DownloadReceipt<LocalArtifact> {
|
|
|
54
78
|
readonly downloadedChunks: number;
|
|
55
79
|
readonly reusedChunks: number;
|
|
56
80
|
}
|
|
81
|
+
/** The physical geometry one download performed — how knowledge arrived and
|
|
82
|
+
* how many storage reads carried it. */
|
|
83
|
+
export interface DownloadShape {
|
|
84
|
+
readonly localManifests: number;
|
|
85
|
+
readonly fetchedManifests: number;
|
|
86
|
+
readonly packedManifests: number;
|
|
87
|
+
readonly standaloneManifests: number;
|
|
88
|
+
/** Ranged pack reads that carried manifests. */
|
|
89
|
+
readonly manifestSpans: number;
|
|
90
|
+
readonly packedBlocks: number;
|
|
91
|
+
readonly standaloneBlocks: number;
|
|
92
|
+
/** Ranged pack reads that carried chunk blocks. */
|
|
93
|
+
readonly blockSpans: number;
|
|
94
|
+
}
|
|
95
|
+
export interface DownloadResult<LocalArtifact> {
|
|
96
|
+
readonly receipts: readonly DownloadReceipt<LocalArtifact>[];
|
|
97
|
+
readonly shape: DownloadShape;
|
|
98
|
+
}
|
|
57
99
|
/** Download a set of immutable artifacts, fetching only machine-cache gaps.
|
|
58
100
|
* Receipts return in input order; any failure fails the whole set after
|
|
59
101
|
* letting in-flight effects settle. */
|
|
60
|
-
export declare function downloadAll<LocalArtifact>(artifacts: readonly TransferArtifact[], ports: DownloadPorts<LocalArtifact>, options?: DownloadOptions): Promise<
|
|
61
|
-
/** Download one immutable artifact — a set of one. */
|
|
62
|
-
export declare function download<LocalArtifact>(artifact: TransferArtifact, ports: DownloadPorts<LocalArtifact>, options?: DownloadOptions): Promise<DownloadReceipt<LocalArtifact>>;
|
|
102
|
+
export declare function downloadAll<LocalArtifact>(artifacts: readonly TransferArtifact[], ports: DownloadPorts<LocalArtifact>, options?: DownloadOptions): Promise<DownloadResult<LocalArtifact>>;
|
|
63
103
|
//# sourceMappingURL=download.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/transfer/download.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/transfer/download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAqC,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAM/E,OAAO,EAAwC,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAsB,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAExF,MAAM,WAAW,aAAa,CAAC,aAAa;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B;0EACsE;IACtE,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC;IACnD;sEACkE;IAClE,WAAW,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC;IACnF;;4EAEwE;IACxE,SAAS,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC7B,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,yDAAyD;IACzD,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACjF;uDACmD;IACnD,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,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