@git-stunts/git-cas 6.0.0 → 6.1.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.
- package/ADVANCED_GUIDE.md +111 -90
- package/ARCHITECTURE.md +12 -3
- package/CHANGELOG.md +78 -3
- package/GUIDE.md +242 -188
- package/README.md +67 -212
- package/UPGRADING.md +28 -1
- package/bin/ui/dashboard.js +442 -183
- package/bin/ui/store-wizard.js +90 -19
- package/build-info.json +2 -2
- package/docs/API.md +273 -51
- package/docs/WALKTHROUGH.md +46 -0
- package/docs/releases/v6.1.0.md +75 -0
- package/index.d.ts +185 -39
- package/index.js +95 -15
- package/package.json +6 -5
- package/src/domain/errors/Codes.js +13 -0
- package/src/domain/services/CasService.d.ts +42 -26
- package/src/domain/services/CasService.js +53 -32
- package/src/domain/services/ChunkRepository.js +50 -12
- package/src/domain/services/RootSet.js +277 -0
- package/src/domain/services/RootSetMetadataCodec.js +253 -0
- package/src/domain/services/RootSetPersistence.js +334 -0
- package/src/domain/services/RootSetRegistry.js +44 -0
- package/src/domain/services/RootSetRetryPolicy.js +87 -0
- package/src/domain/services/RootSetTreeCodec.js +95 -0
- package/src/domain/value-objects/RootSetRef.js +88 -0
- package/src/infrastructure/adapters/FileIOHelper.js +33 -31
- package/src/infrastructure/adapters/GitPersistenceAdapter.js +29 -0
- package/src/infrastructure/adapters/GitRefAdapter.js +20 -0
- package/src/infrastructure/chunkers/resolveChunker.js +7 -5
- package/src/package-version.js +1 -1
- package/src/ports/GitPersistencePort.js +9 -0
- package/src/ports/GitRefPort.js +9 -0
package/GUIDE.md
CHANGED
|
@@ -14,23 +14,30 @@ For advanced topics (benchmarks, Merkle trees, large-asset strategies), see [ADV
|
|
|
14
14
|
## Choose Your Path
|
|
15
15
|
|
|
16
16
|
### 1. Library Integration
|
|
17
|
+
|
|
17
18
|
Embed content-addressed storage into your JavaScript/TypeScript application.
|
|
19
|
+
|
|
18
20
|
- Start with [Library Quick Start](#library-quick-start) below.
|
|
19
21
|
- Understand the port/adapter model: [ARCHITECTURE.md](./ARCHITECTURE.md).
|
|
20
22
|
- Custom adapters: [docs/EXTENDING.md](./docs/EXTENDING.md).
|
|
21
23
|
|
|
22
24
|
### 2. CLI / TUI Usage
|
|
25
|
+
|
|
23
26
|
Store, restore, and manage assets from the terminal.
|
|
27
|
+
|
|
24
28
|
- Jump to [CLI Reference](#cli-reference).
|
|
25
29
|
- Interactive explorer: `git-cas vault dashboard`.
|
|
26
30
|
|
|
27
31
|
### 3. Agentic Automation
|
|
32
|
+
|
|
28
33
|
Machine-facing agent CLI for structured CI/CD or agentic workflows.
|
|
34
|
+
|
|
29
35
|
- [docs/API.md](./docs/API.md) for the agent command surface.
|
|
30
36
|
- Run: `git-cas agent <command>`.
|
|
31
37
|
|
|
32
38
|
### 4. Contributing
|
|
33
|
-
|
|
39
|
+
|
|
40
|
+
- Read `WORKFLOW.md`, `docs/method/process.md`, and `BEARING.md` for project process.
|
|
34
41
|
- See [Architecture](#architecture) for orientation.
|
|
35
42
|
|
|
36
43
|
---
|
|
@@ -41,23 +48,23 @@ This guide and [ADVANCED_GUIDE.md](./ADVANCED_GUIDE.md) are the complete
|
|
|
41
48
|
feature coverage pair. The quick path lives here; implementation mechanics,
|
|
42
49
|
limits, and port contracts live in the advanced guide.
|
|
43
50
|
|
|
44
|
-
| Feature Area
|
|
45
|
-
|
|
46
|
-
| Facade lifecycle, JSON/CBOR factories, full constructor
|
|
47
|
-
| Direct `CasService` construction
|
|
48
|
-
| File, stream, tree, vault-safe store workflows
|
|
49
|
-
| Restore modes and bounded memory behavior
|
|
50
|
-
| Fixed chunking, CDC, FastCDC normalization
|
|
51
|
-
| Encryption schemes and legacy migration
|
|
52
|
-
| Passphrases, PBKDF2, scrypt, KDF policy
|
|
53
|
-
| Multi-recipient envelope encryption and key rotation
|
|
54
|
-
| Vault init/list/resolve/remove, metadata, rotation, privacy mode
|
|
55
|
-
| Compression and custom adapters
|
|
56
|
-
| Manifest versions, format version, integrity hash, diffing
|
|
57
|
-
| Inspection, verification, referenced chunk analysis, deprecated aliases | [Manifest Features](#manifest-features), [Inspection and Verification](#inspection-and-verification)
|
|
58
|
-
| Human CLI, TUI dashboard, agent CLI
|
|
59
|
-
| Runtime support, ports, custom adapters, resilience policy
|
|
60
|
-
| Release verification, migration, build stamping
|
|
51
|
+
| Feature Area | Covered Here | Advanced Coverage |
|
|
52
|
+
| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| Facade lifecycle, JSON/CBOR factories, full constructor | [Library Quick Start](#library-quick-start), [Configuration Reference](#configuration-reference) | [Direct CasService and Custom Port Contracts](./ADVANCED_GUIDE.md#direct-casservice-and-custom-port-contracts) |
|
|
54
|
+
| Direct `CasService` construction | [Configuration Reference](#configuration-reference) notes the facade/direct split | [Direct CasService and Custom Port Contracts](./ADVANCED_GUIDE.md#direct-casservice-and-custom-port-contracts) |
|
|
55
|
+
| File, stream, tree, vault-safe store workflows | [Store Operations](#store-operations), [Vault Management](#vault-management) | [Store/Restore Pipeline](./docs/STORE_RESTORE_PIPELINE.md), [Manifest Integrity Hash](./ADVANCED_GUIDE.md#manifest-integrity-hash), [Merkle Manifests](./ADVANCED_GUIDE.md#merkle-manifests) |
|
|
56
|
+
| Restore modes and bounded memory behavior | [Restore Modes](#restore-modes) | [Store/Restore Pipeline](./docs/STORE_RESTORE_PIPELINE.md), [Parallel Chunk Restore](./ADVANCED_GUIDE.md#parallel-chunk-restore), [Streaming Decompression](./ADVANCED_GUIDE.md#streaming-decompression) |
|
|
57
|
+
| Fixed chunking, CDC, FastCDC normalization | [Chunking](#chunking) | [Content-Defined Chunking (CDC)](./ADVANCED_GUIDE.md#content-defined-chunking-cdc) |
|
|
58
|
+
| Encryption schemes and legacy migration | [Encryption](#encryption), [Migrating Legacy Encryption Schemes](#migrating-legacy-encryption-schemes) | [Encryption Schemes](./ADVANCED_GUIDE.md#encryption-schemes), [Convergent Encryption](./ADVANCED_GUIDE.md#convergent-encryption) |
|
|
59
|
+
| Passphrases, PBKDF2, scrypt, KDF policy | [Passphrase-Based Encryption](#passphrase-based-encryption) | [KDF Policy](./ADVANCED_GUIDE.md#kdf-policy) |
|
|
60
|
+
| Multi-recipient envelope encryption and key rotation | [Multi-Recipient (Envelope) Encryption](#multi-recipient-envelope-encryption), [Key and Recipient Management](#key-and-recipient-management) | [Envelope Encryption](./ADVANCED_GUIDE.md#envelope-encryption) |
|
|
61
|
+
| Vault init/list/resolve/remove, metadata, rotation, privacy mode | [Vault Management](#vault-management), [Vault Privacy Mode](#vault-privacy-mode) | [Vault Privacy Mode](./ADVANCED_GUIDE.md#vault-privacy-mode) |
|
|
62
|
+
| Compression and custom adapters | [Compression](#compression) | [CompressionPort Architecture](./ADVANCED_GUIDE.md#compressionport-architecture) |
|
|
63
|
+
| Manifest versions, format version, integrity hash, diffing | [Manifest Features](#manifest-features), [Manifest Diffing](#manifest-diffing) | [Format Version](./ADVANCED_GUIDE.md#format-version), [Manifest Integrity Hash](./ADVANCED_GUIDE.md#manifest-integrity-hash), [Manifest Diffing](./ADVANCED_GUIDE.md#manifest-diffing) |
|
|
64
|
+
| Inspection, verification, referenced chunk analysis, deprecated aliases | [Manifest Features](#manifest-features), [Inspection and Verification](#inspection-and-verification) | [Security Hardening Summary](./ADVANCED_GUIDE.md#security-hardening-summary) |
|
|
65
|
+
| Human CLI, TUI dashboard, agent CLI | [CLI Reference](#cli-reference) | [Operational Tooling](./ADVANCED_GUIDE.md#operational-tooling) |
|
|
66
|
+
| Runtime support, ports, custom adapters, resilience policy | [Architecture](#architecture) | [Direct CasService and Custom Port Contracts](./ADVANCED_GUIDE.md#direct-casservice-and-custom-port-contracts), [Configuration Reference](./ADVANCED_GUIDE.md#configuration-reference) |
|
|
67
|
+
| Release verification, migration, build stamping | [Migrating Legacy Encryption Schemes](#migrating-legacy-encryption-schemes) | [Operational Tooling](./ADVANCED_GUIDE.md#operational-tooling) |
|
|
61
68
|
|
|
62
69
|
---
|
|
63
70
|
|
|
@@ -90,11 +97,11 @@ const { buffer } = await cas.restore({ manifest: readBack });
|
|
|
90
97
|
|
|
91
98
|
### Factory Methods
|
|
92
99
|
|
|
93
|
-
| Factory
|
|
94
|
-
|
|
95
|
-
| `await ContentAddressableStore.open({ cwd })`
|
|
96
|
-
| `ContentAddressableStore.createJson({ plumbing })` | JSON
|
|
97
|
-
| `ContentAddressableStore.createCbor({ plumbing })` | CBOR
|
|
100
|
+
| Factory | Codec | Use Case |
|
|
101
|
+
| -------------------------------------------------- | ----- | ------------------------------------ |
|
|
102
|
+
| `await ContentAddressableStore.open({ cwd })` | JSON | Shortest normal application setup |
|
|
103
|
+
| `ContentAddressableStore.createJson({ plumbing })` | JSON | Human-readable manifests, debugging |
|
|
104
|
+
| `ContentAddressableStore.createCbor({ plumbing })` | CBOR | Compact binary manifests, production |
|
|
98
105
|
|
|
99
106
|
`open()` is async and accepts `cwd` plus the same facade options as the
|
|
100
107
|
constructor except `plumbing`. Use `createJson()` or `createCbor()` when you
|
|
@@ -116,14 +123,15 @@ import ContentAddressableStore, {
|
|
|
116
123
|
|
|
117
124
|
const cas = new ContentAddressableStore({
|
|
118
125
|
plumbing,
|
|
119
|
-
chunkSize: 128 * 1024,
|
|
126
|
+
chunkSize: 128 * 1024, // 128 KiB chunks
|
|
120
127
|
codec: new CborCodec(),
|
|
121
128
|
observability: new EventEmitterObserver(),
|
|
122
|
-
merkleThreshold: 500,
|
|
123
|
-
concurrency: 4,
|
|
124
|
-
maxRestoreBufferSize: 256 * 1024 * 1024,
|
|
129
|
+
merkleThreshold: 500, // Merkle sub-manifests above 500 chunks
|
|
130
|
+
concurrency: 4, // Parallel chunk I/O
|
|
131
|
+
maxRestoreBufferSize: 256 * 1024 * 1024, // 256 MiB buffer limit
|
|
125
132
|
compressionAdapter: new NodeCompressionAdapter(),
|
|
126
|
-
chunking: {
|
|
133
|
+
chunking: {
|
|
134
|
+
// CDC chunking
|
|
127
135
|
strategy: 'cdc',
|
|
128
136
|
targetChunkSize: 64 * 1024,
|
|
129
137
|
minChunkSize: 16 * 1024,
|
|
@@ -166,6 +174,21 @@ const manifest = await cas.storeFile({
|
|
|
166
174
|
|
|
167
175
|
The filename defaults to the basename of `filePath`. Override it with the optional `filename` parameter.
|
|
168
176
|
|
|
177
|
+
Use `chunking` on a single store call when one asset needs a different strategy
|
|
178
|
+
from the facade default:
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
const manifest = await cas.storeFile({
|
|
182
|
+
filePath: './large-archive.tar',
|
|
183
|
+
slug: 'archives/large',
|
|
184
|
+
chunking: { strategy: 'cdc' },
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
This override is scoped to that operation. The next `store()` or `storeFile()`
|
|
189
|
+
call returns to the facade's configured chunker unless it also supplies
|
|
190
|
+
`chunking`.
|
|
191
|
+
|
|
169
192
|
---
|
|
170
193
|
|
|
171
194
|
## Encryption
|
|
@@ -174,11 +197,11 @@ All store and restore methods accept encryption options. Encryption is AES-256-G
|
|
|
174
197
|
|
|
175
198
|
### Encryption Schemes
|
|
176
199
|
|
|
177
|
-
| Scheme
|
|
178
|
-
|
|
200
|
+
| Scheme | Description | Default When |
|
|
201
|
+
| ------------ | ----------------------------------------------------------------------------------------------- | ------------------------- |
|
|
179
202
|
| `convergent` | Per-chunk encryption keyed by content hash; preserves CDC deduplication across encrypted stores | CDC chunking + encryption |
|
|
180
|
-
| `framed`
|
|
181
|
-
| `whole`
|
|
203
|
+
| `framed` | Streaming framed encryption with per-frame AAD binding to slug | Non-CDC encrypted stores |
|
|
204
|
+
| `whole` | Whole-object encryption with AAD binding to slug | Explicit only |
|
|
182
205
|
|
|
183
206
|
AAD (Additional Authenticated Data) is always on for `whole` and `framed` schemes, binding ciphertext to the asset slug.
|
|
184
207
|
|
|
@@ -272,7 +295,7 @@ const { buffer } = await cas.restore({
|
|
|
272
295
|
// Add a recipient
|
|
273
296
|
const updated = await cas.addRecipient({
|
|
274
297
|
manifest: readBack,
|
|
275
|
-
existingKey: aliceKey,
|
|
298
|
+
existingKey: aliceKey, // Any current recipient's key
|
|
276
299
|
newRecipientKey: carolKey,
|
|
277
300
|
label: 'carol',
|
|
278
301
|
});
|
|
@@ -292,7 +315,7 @@ const rotated = await cas.rotateKey({
|
|
|
292
315
|
manifest: readBack,
|
|
293
316
|
oldKey: aliceKey,
|
|
294
317
|
newKey: aliceNewKey,
|
|
295
|
-
label: 'alice',
|
|
318
|
+
label: 'alice', // Optional: target a specific recipient
|
|
296
319
|
});
|
|
297
320
|
```
|
|
298
321
|
|
|
@@ -307,8 +330,8 @@ const framedManifest = await cas.storeFile({
|
|
|
307
330
|
slug: 'media/video',
|
|
308
331
|
encryptionKey: key,
|
|
309
332
|
encryption: {
|
|
310
|
-
scheme: 'framed',
|
|
311
|
-
frameBytes: 128 * 1024,
|
|
333
|
+
scheme: 'framed', // 'whole', 'framed', or 'convergent'
|
|
334
|
+
frameBytes: 128 * 1024, // 128 KiB frames (framed scheme only)
|
|
312
335
|
},
|
|
313
336
|
});
|
|
314
337
|
|
|
@@ -346,7 +369,7 @@ Splits data into equal-sized chunks. Simple and predictable.
|
|
|
346
369
|
```js
|
|
347
370
|
const cas = ContentAddressableStore.createJson({
|
|
348
371
|
plumbing,
|
|
349
|
-
chunkSize: 512 * 1024,
|
|
372
|
+
chunkSize: 512 * 1024, // 512 KiB chunks
|
|
350
373
|
});
|
|
351
374
|
```
|
|
352
375
|
|
|
@@ -359,20 +382,20 @@ const cas = new ContentAddressableStore({
|
|
|
359
382
|
plumbing,
|
|
360
383
|
chunking: {
|
|
361
384
|
strategy: 'cdc',
|
|
362
|
-
targetChunkSize: 64 * 1024,
|
|
363
|
-
minChunkSize: 16 * 1024,
|
|
364
|
-
maxChunkSize: 256 * 1024,
|
|
385
|
+
targetChunkSize: 64 * 1024, // 64 KiB target
|
|
386
|
+
minChunkSize: 16 * 1024, // 16 KiB minimum
|
|
387
|
+
maxChunkSize: 256 * 1024, // 256 KiB maximum
|
|
365
388
|
},
|
|
366
389
|
});
|
|
367
390
|
```
|
|
368
391
|
|
|
369
392
|
CDC parameters:
|
|
370
393
|
|
|
371
|
-
| Parameter
|
|
372
|
-
|
|
373
|
-
| `targetChunkSize` | Average chunk size the rolling hash targets
|
|
374
|
-
| `minChunkSize`
|
|
375
|
-
| `maxChunkSize`
|
|
394
|
+
| Parameter | Description |
|
|
395
|
+
| ----------------- | ------------------------------------------------- |
|
|
396
|
+
| `targetChunkSize` | Average chunk size the rolling hash targets |
|
|
397
|
+
| `minChunkSize` | Minimum chunk size (never split smaller) |
|
|
398
|
+
| `maxChunkSize` | Maximum chunk size (force split at this boundary) |
|
|
376
399
|
|
|
377
400
|
> **Note**: CDC deduplication is ineffective with standard encryption (`whole` or `framed`), since ciphertext is pseudorandom. Use the `convergent` scheme (the default for CDC + encryption) to preserve deduplication.
|
|
378
401
|
|
|
@@ -403,10 +426,18 @@ Implement the `CompressionPort` interface to use a different algorithm:
|
|
|
403
426
|
import { CompressionPort } from '@git-stunts/git-cas';
|
|
404
427
|
|
|
405
428
|
class BrotliAdapter extends CompressionPort {
|
|
406
|
-
async compressBuffer(buffer) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
async
|
|
429
|
+
async compressBuffer(buffer) {
|
|
430
|
+
/* ... */
|
|
431
|
+
}
|
|
432
|
+
async decompressBuffer(buffer) {
|
|
433
|
+
/* ... */
|
|
434
|
+
}
|
|
435
|
+
async *compressStream(source) {
|
|
436
|
+
/* ... */
|
|
437
|
+
}
|
|
438
|
+
async *decompressStream(source) {
|
|
439
|
+
/* ... */
|
|
440
|
+
}
|
|
410
441
|
}
|
|
411
442
|
|
|
412
443
|
const cas = new ContentAddressableStore({
|
|
@@ -437,8 +468,8 @@ console.log(standaloneDiff.summary);
|
|
|
437
468
|
// addedCount: 3, removedCount: 1, unchangedCount: 42,
|
|
438
469
|
// addedBytes: 196608, removedBytes: 65536, unchangedBytes: 2752512,
|
|
439
470
|
// }
|
|
440
|
-
console.log(standaloneDiff.added);
|
|
441
|
-
console.log(standaloneDiff.removed);
|
|
471
|
+
console.log(standaloneDiff.added); // Chunk[] -- new chunks in newManifest
|
|
472
|
+
console.log(standaloneDiff.removed); // Chunk[] -- chunks only in oldManifest
|
|
442
473
|
console.log(standaloneDiff.unchanged); // Chunk[] -- chunks in both (by digest)
|
|
443
474
|
```
|
|
444
475
|
|
|
@@ -457,7 +488,7 @@ await cas.initVault();
|
|
|
457
488
|
// Encrypted vault with passphrase
|
|
458
489
|
await cas.initVault({
|
|
459
490
|
passphrase: 'vault-secret',
|
|
460
|
-
kdfOptions: { algorithm: 'pbkdf2' },
|
|
491
|
+
kdfOptions: { algorithm: 'pbkdf2' }, // or 'scrypt'
|
|
461
492
|
});
|
|
462
493
|
|
|
463
494
|
// Encrypted vault with privacy mode
|
|
@@ -498,7 +529,7 @@ Re-wraps every envelope-encrypted entry's DEK with a new key derived from `newPa
|
|
|
498
529
|
const { commitOid, rotatedSlugs, skippedSlugs } = await cas.rotateVaultPassphrase({
|
|
499
530
|
oldPassphrase: 'old-secret',
|
|
500
531
|
newPassphrase: 'new-secret',
|
|
501
|
-
kdfOptions: { algorithm: 'scrypt' },
|
|
532
|
+
kdfOptions: { algorithm: 'scrypt' }, // optional: change KDF algorithm
|
|
502
533
|
});
|
|
503
534
|
```
|
|
504
535
|
|
|
@@ -557,12 +588,12 @@ Each manifest also carries an optional `formatVersion` field -- a semver string
|
|
|
557
588
|
```js
|
|
558
589
|
const manifest = await cas.readManifest({ treeOid });
|
|
559
590
|
|
|
560
|
-
console.log(manifest.slug);
|
|
561
|
-
console.log(manifest.filename);
|
|
562
|
-
console.log(manifest.size);
|
|
591
|
+
console.log(manifest.slug); // 'photos/vacation'
|
|
592
|
+
console.log(manifest.filename); // 'photo.jpg'
|
|
593
|
+
console.log(manifest.size); // total bytes
|
|
563
594
|
console.log(manifest.chunks.length); // number of chunks
|
|
564
|
-
console.log(manifest.encryption);
|
|
565
|
-
console.log(manifest.compression);
|
|
595
|
+
console.log(manifest.encryption); // encryption metadata or undefined
|
|
596
|
+
console.log(manifest.compression); // compression metadata or undefined
|
|
566
597
|
console.log(manifest.formatVersion); // '6.0.0' or undefined (older manifests)
|
|
567
598
|
```
|
|
568
599
|
|
|
@@ -623,7 +654,7 @@ const { bytesWritten } = await cas.restoreFile({
|
|
|
623
654
|
manifest,
|
|
624
655
|
outputPath: '/tmp/restored-photo.jpg',
|
|
625
656
|
baseDirectory: '/tmp',
|
|
626
|
-
encryptionKey: key,
|
|
657
|
+
encryptionKey: key, // if encrypted
|
|
627
658
|
});
|
|
628
659
|
```
|
|
629
660
|
|
|
@@ -641,11 +672,30 @@ for await (const chunk of cas.restoreStream({ manifest, encryptionKey: key })) {
|
|
|
641
672
|
|
|
642
673
|
### When to Use Each
|
|
643
674
|
|
|
644
|
-
| Mode
|
|
645
|
-
|
|
646
|
-
| `restore`
|
|
647
|
-
| `restoreFile`
|
|
648
|
-
| `restoreStream` | Low
|
|
675
|
+
| Mode | Memory | Streaming | Use Case |
|
|
676
|
+
| --------------- | ---------------- | -------------- | ---------------------------------- |
|
|
677
|
+
| `restore` | Full file in RAM | No | Small files, in-memory processing |
|
|
678
|
+
| `restoreFile` | Low | Yes (internal) | Disk targets, atomic writes |
|
|
679
|
+
| `restoreStream` | Low | Yes (external) | Pipes, HTTP responses, large files |
|
|
680
|
+
|
|
681
|
+
---
|
|
682
|
+
|
|
683
|
+
## Streaming Surface
|
|
684
|
+
|
|
685
|
+
| Surface | Streaming API? | Non-streaming API? | Notes |
|
|
686
|
+
| ------------------------------- | ------------------------------------------ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
687
|
+
| Write | `store({ source, ... })`, `storeFile(...)` | No dedicated non-streaming store facade | Write ingress is stream-based. CDC + encryption defaults to `convergent` (per-chunk deterministic encryption preserving dedup). Fixed + encryption defaults to `framed`. |
|
|
688
|
+
| Read: plaintext | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | True chunk-by-chunk streaming restore. |
|
|
689
|
+
| Read: encrypted `whole` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | `restoreStream()` is the buffered compatibility path. Uncompressed `restoreFile()` verifies chunks, streams tentative plaintext through whole-object AES-GCM decryption into a temp-file path, and renames into place only after auth succeeds. AAD (slug) is always bound. On Web Crypto runtimes this decrypt step is still one-shot internally, bounded by `maxDecryptionBufferSize`. |
|
|
690
|
+
| Read: encrypted `framed` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | True authenticated streaming restore. Plaintext is yielded frame-by-frame after each frame is verified. Per-frame AAD is always bound. |
|
|
691
|
+
| Read: compressed-only | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Plaintext + gzip now streams end-to-end. `restoreFile()` streams gunzip output through a bounded temp-file path. |
|
|
692
|
+
| Read: compressed + `whole` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Auth must complete before gunzip. `restoreFile()` therefore preserves the auth-before-decompress boundary and may buffer the encrypted compressed payload; use `framed` or `convergent` for large compressed encrypted assets. |
|
|
693
|
+
| Read: compressed + `framed` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Streaming decrypt, then streaming gunzip. |
|
|
694
|
+
| Read: encrypted `convergent` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | True per-chunk streaming restore. Each chunk is decrypted individually using a key derived from its content hash. Parallel chunk restore via prefetch window when concurrency > 1. |
|
|
695
|
+
| Read: compressed + `convergent` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Per-chunk convergent decrypt, then streaming gunzip. |
|
|
696
|
+
| Verify | No streaming verify surface | `verifyIntegrity(manifest, options?)` | Verifies chunk digests for all content. `whole` auth-checks the full ciphertext; `framed` parses and auth-checks every frame; `convergent` decrypts each chunk and verifies plaintext digests. |
|
|
697
|
+
|
|
698
|
+
Runtime note: `framed` is the honest cross-runtime streaming answer. On Node and Bun, `whole restoreFile()` has the stronger low-memory path; on Web Crypto runtimes such as Deno, `whole` remains bounded-buffer rather than true streaming.
|
|
649
699
|
|
|
650
700
|
---
|
|
651
701
|
|
|
@@ -655,127 +705,127 @@ All commands support `--json` for machine-readable output and `--quiet` to suppr
|
|
|
655
705
|
|
|
656
706
|
### Store and Restore
|
|
657
707
|
|
|
658
|
-
| Command
|
|
659
|
-
|
|
660
|
-
| `git-cas store <file> --slug <slug>`
|
|
661
|
-
| `git-cas restore --out <path> --slug <slug>`
|
|
662
|
-
| `git-cas restore --out <path> --oid <tree-oid>` | Restore a file from tree OID
|
|
708
|
+
| Command | Description |
|
|
709
|
+
| ----------------------------------------------- | ------------------------------ |
|
|
710
|
+
| `git-cas store <file> --slug <slug>` | Store a file into Git CAS |
|
|
711
|
+
| `git-cas restore --out <path> --slug <slug>` | Restore a file from vault slug |
|
|
712
|
+
| `git-cas restore --out <path> --oid <tree-oid>` | Restore a file from tree OID |
|
|
663
713
|
|
|
664
714
|
**Store flags:**
|
|
665
715
|
|
|
666
|
-
| Flag
|
|
667
|
-
|
|
668
|
-
| `--slug <slug>`
|
|
669
|
-
| `--tree`
|
|
670
|
-
| `--force`
|
|
671
|
-
| `--key-file <path>`
|
|
672
|
-
| `--recipient <label:keyfile>`
|
|
673
|
-
| `--vault-passphrase <pass>`
|
|
674
|
-
| `--vault-passphrase-file <path>`
|
|
675
|
-
| `--os-keychain-target <target>`
|
|
676
|
-
| `--os-keychain-account <account>` | Keychain account namespace (default: `git-cas`)
|
|
677
|
-
| `--gzip`
|
|
678
|
-
| `--strategy <fixed\|cdc>`
|
|
679
|
-
| `--chunk-size <n>`
|
|
680
|
-
| `--target-chunk-size <n>`
|
|
681
|
-
| `--min-chunk-size <n>`
|
|
682
|
-
| `--max-chunk-size <n>`
|
|
683
|
-
| `--concurrency <n>`
|
|
684
|
-
| `--codec <json\|cbor>`
|
|
685
|
-
| `--merkle-threshold <n>`
|
|
686
|
-
| `--cwd <dir>`
|
|
716
|
+
| Flag | Description |
|
|
717
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
718
|
+
| `--slug <slug>` | Asset slug identifier (required) |
|
|
719
|
+
| `--tree` | Create Git tree and add to vault |
|
|
720
|
+
| `--force` | Overwrite existing vault entry (requires `--tree`) |
|
|
721
|
+
| `--key-file <path>` | Path to 32-byte raw encryption key file |
|
|
722
|
+
| `--recipient <label:keyfile>` | Envelope recipient (repeatable) |
|
|
723
|
+
| `--vault-passphrase <pass>` | Inline vault passphrase (accepted with warning; prefer `--vault-passphrase-file -`, `GIT_CAS_PASSPHRASE`, or `--os-keychain-target`) |
|
|
724
|
+
| `--vault-passphrase-file <path>` | Read passphrase from file (`-` for stdin) |
|
|
725
|
+
| `--os-keychain-target <target>` | Read passphrase from OS keychain via `@git-stunts/vault` |
|
|
726
|
+
| `--os-keychain-account <account>` | Keychain account namespace (default: `git-cas`) |
|
|
727
|
+
| `--gzip` | Enable gzip compression |
|
|
728
|
+
| `--strategy <fixed\|cdc>` | Chunking strategy |
|
|
729
|
+
| `--chunk-size <n>` | Chunk size in bytes |
|
|
730
|
+
| `--target-chunk-size <n>` | CDC target chunk size |
|
|
731
|
+
| `--min-chunk-size <n>` | CDC minimum chunk size |
|
|
732
|
+
| `--max-chunk-size <n>` | CDC maximum chunk size |
|
|
733
|
+
| `--concurrency <n>` | Parallel chunk I/O operations |
|
|
734
|
+
| `--codec <json\|cbor>` | Manifest codec |
|
|
735
|
+
| `--merkle-threshold <n>` | Chunk count for Merkle sub-manifests |
|
|
736
|
+
| `--cwd <dir>` | Git working directory (default: `.`) |
|
|
687
737
|
|
|
688
738
|
**Restore flags:**
|
|
689
739
|
|
|
690
|
-
| Flag
|
|
691
|
-
|
|
692
|
-
| `--out <path>`
|
|
693
|
-
| `--slug <slug>`
|
|
694
|
-
| `--oid <tree-oid>`
|
|
695
|
-
| `--key-file <path>`
|
|
696
|
-
| `--vault-passphrase <pass>`
|
|
697
|
-
| `--vault-passphrase-file <path>`
|
|
698
|
-
| `--os-keychain-target <target>`
|
|
699
|
-
| `--os-keychain-account <account>` | Keychain account namespace
|
|
700
|
-
| `--concurrency <n>`
|
|
701
|
-
| `--max-restore-buffer <n>`
|
|
702
|
-
| `--cwd <dir>`
|
|
740
|
+
| Flag | Description |
|
|
741
|
+
| --------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
742
|
+
| `--out <path>` | Non-empty output file path (required) |
|
|
743
|
+
| `--slug <slug>` | Resolve tree OID from vault slug |
|
|
744
|
+
| `--oid <tree-oid>` | Direct tree OID |
|
|
745
|
+
| `--key-file <path>` | Encryption key file |
|
|
746
|
+
| `--vault-passphrase <pass>` | Inline vault passphrase (accepted with warning; prefer file/stdin, env, or keychain sources) |
|
|
747
|
+
| `--vault-passphrase-file <path>` | Read passphrase from file (`-` for stdin) |
|
|
748
|
+
| `--os-keychain-target <target>` | OS keychain passphrase source |
|
|
749
|
+
| `--os-keychain-account <account>` | Keychain account namespace |
|
|
750
|
+
| `--concurrency <n>` | Parallel chunk I/O |
|
|
751
|
+
| `--max-restore-buffer <n>` | Max buffered restore size in bytes |
|
|
752
|
+
| `--cwd <dir>` | Git working directory |
|
|
703
753
|
|
|
704
754
|
### Vault Commands
|
|
705
755
|
|
|
706
|
-
| Command
|
|
707
|
-
|
|
708
|
-
| `git-cas vault init`
|
|
709
|
-
| `git-cas vault list`
|
|
710
|
-
| `git-cas vault remove <slug>` | Remove a vault entry
|
|
711
|
-
| `git-cas vault info <slug>`
|
|
712
|
-
| `git-cas vault stats`
|
|
713
|
-
| `git-cas vault history`
|
|
714
|
-
| `git-cas vault rotate`
|
|
715
|
-
| `git-cas vault dashboard`
|
|
756
|
+
| Command | Description |
|
|
757
|
+
| ----------------------------- | ------------------------------------- |
|
|
758
|
+
| `git-cas vault init` | Initialize the vault |
|
|
759
|
+
| `git-cas vault list` | List all vault entries |
|
|
760
|
+
| `git-cas vault remove <slug>` | Remove a vault entry |
|
|
761
|
+
| `git-cas vault info <slug>` | Show info for a vault entry |
|
|
762
|
+
| `git-cas vault stats` | Vault size, dedup, encryption summary |
|
|
763
|
+
| `git-cas vault history` | Show vault commit history |
|
|
764
|
+
| `git-cas vault rotate` | Rotate vault passphrase |
|
|
765
|
+
| `git-cas vault dashboard` | Interactive TUI explorer |
|
|
716
766
|
|
|
717
767
|
**Vault init flags:**
|
|
718
768
|
|
|
719
|
-
| Flag
|
|
720
|
-
|
|
721
|
-
| `--vault-passphrase <pass>`
|
|
722
|
-
| `--vault-passphrase-file <path>` | Read passphrase from file (`-` for stdin)
|
|
723
|
-
| `--os-keychain-target <target>`
|
|
724
|
-
| `--algorithm <pbkdf2\|scrypt>`
|
|
769
|
+
| Flag | Description |
|
|
770
|
+
| -------------------------------- | ------------------------------------------------------------------------ |
|
|
771
|
+
| `--vault-passphrase <pass>` | Enable encrypted vault from an inline passphrase (accepted with warning) |
|
|
772
|
+
| `--vault-passphrase-file <path>` | Read passphrase from file (`-` for stdin) |
|
|
773
|
+
| `--os-keychain-target <target>` | OS keychain passphrase source |
|
|
774
|
+
| `--algorithm <pbkdf2\|scrypt>` | KDF algorithm |
|
|
725
775
|
|
|
726
776
|
**Vault rotate flags:**
|
|
727
777
|
|
|
728
|
-
| Flag
|
|
729
|
-
|
|
730
|
-
| `--old-passphrase <pass>`
|
|
731
|
-
| `--new-passphrase <pass>`
|
|
732
|
-
| `--old-passphrase-file <path>` | Read old passphrase from file (`-` for stdin)
|
|
733
|
-
| `--new-passphrase-file <path>` | Read new passphrase from file (`-` for stdin)
|
|
734
|
-
| `--algorithm <pbkdf2\|scrypt>` | KDF algorithm for new passphrase
|
|
778
|
+
| Flag | Description |
|
|
779
|
+
| ------------------------------ | ------------------------------------------------------- |
|
|
780
|
+
| `--old-passphrase <pass>` | Current inline vault passphrase (accepted with warning) |
|
|
781
|
+
| `--new-passphrase <pass>` | New inline vault passphrase (accepted with warning) |
|
|
782
|
+
| `--old-passphrase-file <path>` | Read old passphrase from file (`-` for stdin) |
|
|
783
|
+
| `--new-passphrase-file <path>` | Read new passphrase from file (`-` for stdin) |
|
|
784
|
+
| `--algorithm <pbkdf2\|scrypt>` | KDF algorithm for new passphrase |
|
|
735
785
|
|
|
736
786
|
### Inspection and Verification
|
|
737
787
|
|
|
738
|
-
| Command
|
|
739
|
-
|
|
740
|
-
| `git-cas inspect --slug <slug>`
|
|
741
|
-
| `git-cas inspect --oid <tree-oid> --heatmap` | Chunk size heatmap visualization
|
|
742
|
-
| `git-cas verify --slug <slug>`
|
|
743
|
-
| `git-cas doctor`
|
|
744
|
-
| `git-cas tree --manifest <path>`
|
|
788
|
+
| Command | Description |
|
|
789
|
+
| -------------------------------------------- | ----------------------------------------- |
|
|
790
|
+
| `git-cas inspect --slug <slug>` | Inspect manifest (human-readable or JSON) |
|
|
791
|
+
| `git-cas inspect --oid <tree-oid> --heatmap` | Chunk size heatmap visualization |
|
|
792
|
+
| `git-cas verify --slug <slug>` | Verify chunk-level SHA-256 integrity |
|
|
793
|
+
| `git-cas doctor` | Vault health report |
|
|
794
|
+
| `git-cas tree --manifest <path>` | Create Git tree from manifest JSON file |
|
|
745
795
|
|
|
746
796
|
### Key and Recipient Management
|
|
747
797
|
|
|
748
|
-
| Command
|
|
749
|
-
|
|
750
|
-
| `git-cas rotate --slug <slug> --old-key-file <path> --new-key-file <path>`
|
|
751
|
-
| `git-cas recipient add <slug> --label <label> --key-file <path> --existing-key-file <path>` | Add recipient
|
|
752
|
-
| `git-cas recipient remove <slug> --label <label>`
|
|
753
|
-
| `git-cas recipient list <slug>`
|
|
798
|
+
| Command | Description |
|
|
799
|
+
| ------------------------------------------------------------------------------------------- | --------------------- |
|
|
800
|
+
| `git-cas rotate --slug <slug> --old-key-file <path> --new-key-file <path>` | Rotate encryption key |
|
|
801
|
+
| `git-cas recipient add <slug> --label <label> --key-file <path> --existing-key-file <path>` | Add recipient |
|
|
802
|
+
| `git-cas recipient remove <slug> --label <label>` | Remove recipient |
|
|
803
|
+
| `git-cas recipient list <slug>` | List recipients |
|
|
754
804
|
|
|
755
805
|
### Agent CLI
|
|
756
806
|
|
|
757
807
|
Machine-facing commands for CI/CD and agentic workflows. The agent CLI returns newline-delimited protocol events on stdout and exits with stable status codes. It accepts the same core targets and credential sources as the human CLI.
|
|
758
808
|
|
|
759
|
-
| Command
|
|
760
|
-
|
|
761
|
-
| `git-cas agent store <file> --slug <slug> --tree`
|
|
762
|
-
| `git-cas agent tree --manifest <path>`
|
|
763
|
-
| `git-cas agent restore --slug <slug> --out <path>`
|
|
764
|
-
| `git-cas agent restore --oid <tree-oid> --out <path>` | Restore from a direct tree OID
|
|
765
|
-
| `git-cas agent inspect --slug <slug>`
|
|
766
|
-
| `git-cas agent verify --slug <slug>`
|
|
767
|
-
| `git-cas agent doctor`
|
|
768
|
-
| `git-cas agent rotate --slug <slug>`
|
|
769
|
-
| `git-cas agent recipient add <slug>`
|
|
770
|
-
| `git-cas agent recipient remove <slug>`
|
|
771
|
-
| `git-cas agent recipient list <slug>`
|
|
772
|
-
| `git-cas agent vault init`
|
|
773
|
-
| `git-cas agent vault list`
|
|
774
|
-
| `git-cas agent vault info <slug>`
|
|
775
|
-
| `git-cas agent vault history`
|
|
776
|
-
| `git-cas agent vault remove <slug>`
|
|
777
|
-
| `git-cas agent vault rotate`
|
|
778
|
-
| `git-cas agent vault stats`
|
|
809
|
+
| Command | Description |
|
|
810
|
+
| ----------------------------------------------------- | ---------------------------------------------- |
|
|
811
|
+
| `git-cas agent store <file> --slug <slug> --tree` | Store an asset and optionally vault it |
|
|
812
|
+
| `git-cas agent tree --manifest <path>` | Create a Git tree from manifest JSON |
|
|
813
|
+
| `git-cas agent restore --slug <slug> --out <path>` | Restore from a vault slug |
|
|
814
|
+
| `git-cas agent restore --oid <tree-oid> --out <path>` | Restore from a direct tree OID |
|
|
815
|
+
| `git-cas agent inspect --slug <slug>` | Return manifest JSON for a target |
|
|
816
|
+
| `git-cas agent verify --slug <slug>` | Verify integrity and return an agent exit code |
|
|
817
|
+
| `git-cas agent doctor` | Return a vault health report |
|
|
818
|
+
| `git-cas agent rotate --slug <slug>` | Rotate a recipient/key wrapper |
|
|
819
|
+
| `git-cas agent recipient add <slug>` | Add an envelope recipient |
|
|
820
|
+
| `git-cas agent recipient remove <slug>` | Remove an envelope recipient |
|
|
821
|
+
| `git-cas agent recipient list <slug>` | List envelope recipients |
|
|
822
|
+
| `git-cas agent vault init` | Initialize the vault |
|
|
823
|
+
| `git-cas agent vault list` | List vault entries |
|
|
824
|
+
| `git-cas agent vault info <slug>` | Inspect a vault entry |
|
|
825
|
+
| `git-cas agent vault history` | Return vault history |
|
|
826
|
+
| `git-cas agent vault remove <slug>` | Remove a vault entry |
|
|
827
|
+
| `git-cas agent vault rotate` | Rotate the vault passphrase |
|
|
828
|
+
| `git-cas agent vault stats` | Return vault size/dedupe/encryption stats |
|
|
779
829
|
|
|
780
830
|
Use `--request <json>` or stdin JSON for structured request payloads where a workflow needs machine-built inputs. See [docs/API.md](./docs/API.md) for the detailed protocol fields and response schemas.
|
|
781
831
|
|
|
@@ -787,39 +837,43 @@ Use `--request <json>` or stdin JSON for structured request payloads where a wor
|
|
|
787
837
|
|
|
788
838
|
This table describes the high-level `ContentAddressableStore` facade. The facade supplies `FixedChunker`, `NodeCompressionAdapter`, runtime crypto, and the package `formatVersion` automatically when those options are omitted. If you construct `CasService` directly, `chunker` and `compressionAdapter` are required injections; see [ADVANCED_GUIDE.md](./ADVANCED_GUIDE.md#direct-casservice-and-custom-port-contracts).
|
|
789
839
|
|
|
790
|
-
| Option
|
|
791
|
-
|
|
792
|
-
| `plumbing`
|
|
793
|
-
| `chunkSize`
|
|
794
|
-
| `codec`
|
|
795
|
-
| `crypto`
|
|
796
|
-
| `observability`
|
|
797
|
-
| `policy`
|
|
798
|
-
| `merkleThreshold`
|
|
799
|
-
| `concurrency`
|
|
800
|
-
| `chunking`
|
|
801
|
-
| `chunker`
|
|
802
|
-
| `maxRestoreBufferSize` | `number`
|
|
803
|
-
| `compressionAdapter`
|
|
804
|
-
| `formatVersion`
|
|
840
|
+
| Option | Type | Default | Description |
|
|
841
|
+
| ---------------------- | ------------------- | ------------------------ | --------------------------------------------------------------------------------------------------- |
|
|
842
|
+
| `plumbing` | `GitPlumbing` | (required) | `@git-stunts/plumbing` instance |
|
|
843
|
+
| `chunkSize` | `number` | `262144` (256 KiB) | Chunk size in bytes (min 1024, max 100 MiB) |
|
|
844
|
+
| `codec` | `CodecPort` | `JsonCodec` | Manifest serialization codec |
|
|
845
|
+
| `crypto` | `CryptoPort` | Auto-detected | Crypto adapter (Node or WebCrypto) |
|
|
846
|
+
| `observability` | `ObservabilityPort` | `SilentObserver` | Metrics, logs, spans |
|
|
847
|
+
| `policy` | `Policy` | None | `@git-stunts/alfred` resilience policy |
|
|
848
|
+
| `merkleThreshold` | `number` | `1000` | Chunk count above which Merkle sub-manifests are used |
|
|
849
|
+
| `concurrency` | `number` | `1` | Parallel chunk I/O operations (max 64); values > 1 enable parallel chunk restore |
|
|
850
|
+
| `chunking` | `object` | None | Chunking strategy config (see below) |
|
|
851
|
+
| `chunker` | `ChunkingPort` | `FixedChunker` | Pre-built chunker instance (advanced) |
|
|
852
|
+
| `maxRestoreBufferSize` | `number` | `536870912` (512 MiB) | Max bytes for buffered restore |
|
|
853
|
+
| `compressionAdapter` | `CompressionPort` | `NodeCompressionAdapter` | Compression adapter |
|
|
854
|
+
| `formatVersion` | `string` | Package version | Semver string stamped into new manifests by the facade. Directly configurable only on `CasService`. |
|
|
805
855
|
|
|
806
856
|
### Encryption Options (Store)
|
|
807
857
|
|
|
808
|
-
| Key
|
|
809
|
-
|
|
810
|
-
| `scheme`
|
|
811
|
-
| `frameBytes` | `number`
|
|
812
|
-
| `convergent` | `boolean`
|
|
858
|
+
| Key | Type | Default | Description |
|
|
859
|
+
| ------------ | ------------------------------------- | ------------------------------------- | --------------------------------------------------------------- |
|
|
860
|
+
| `scheme` | `'whole' \| 'framed' \| 'convergent'` | `convergent` (CDC) / `framed` (fixed) | Encryption scheme |
|
|
861
|
+
| `frameBytes` | `number` | `65536` (64 KiB) | Frame size for `framed` scheme (max 64 MiB) |
|
|
862
|
+
| `convergent` | `boolean` | Auto | Explicit convergent opt-in/opt-out when no `scheme` is provided |
|
|
813
863
|
|
|
814
864
|
### Chunking Config Object
|
|
815
865
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
|
820
|
-
|
|
|
821
|
-
| `
|
|
822
|
-
| `
|
|
866
|
+
Constructor `chunking` sets the facade default. `store()` and `storeFile()` can
|
|
867
|
+
also receive the same object as a per-operation override.
|
|
868
|
+
|
|
869
|
+
| Key | Type | Description |
|
|
870
|
+
| ----------------- | ------------------ | -------------------------------------- |
|
|
871
|
+
| `strategy` | `'fixed' \| 'cdc'` | Chunking strategy |
|
|
872
|
+
| `chunkSize` | `number` | Fixed chunk size (fixed strategy only) |
|
|
873
|
+
| `targetChunkSize` | `number` | CDC target chunk size |
|
|
874
|
+
| `minChunkSize` | `number` | CDC minimum chunk size |
|
|
875
|
+
| `maxChunkSize` | `number` | CDC maximum chunk size |
|
|
876
|
+
| `normalized` | `boolean` | Use FastCDC-style dual-mask boundaries |
|
|
823
877
|
|
|
824
878
|
### `.casrc` Project Config
|
|
825
879
|
|
|
@@ -844,8 +898,8 @@ Place a `.casrc` JSON file at your repository root to set defaults. CLI flags al
|
|
|
844
898
|
|
|
845
899
|
### Environment Variables
|
|
846
900
|
|
|
847
|
-
| Variable
|
|
848
|
-
|
|
901
|
+
| Variable | Description |
|
|
902
|
+
| -------------------- | ----------------------------------------------------------- |
|
|
849
903
|
| `GIT_CAS_PASSPHRASE` | Vault passphrase (preferred over `--vault-passphrase` flag) |
|
|
850
904
|
|
|
851
905
|
---
|