@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.
@@ -28,6 +28,7 @@ and [THREAT_MODEL.md](./THREAT_MODEL.md).
28
28
  11b. [Multi-Recipient Encryption & Key Rotation](#11b-multi-recipient-encryption--key-rotation)
29
29
  12. [Merkle Manifests](#12-merkle-manifests)
30
30
  13. [Vault](#13-vault)
31
+ 13b. [Root Sets](#13b-root-sets)
31
32
  14. [Architecture](#14-architecture)
32
33
  15. [Codec System](#15-codec-system)
33
34
  16. [Error Handling](#16-error-handling)
@@ -213,6 +214,11 @@ The tree contains one entry for the manifest file (named `manifest.json` or
213
214
  its SHA-256 digest. This tree OID is a standard Git object -- you can commit
214
215
  it, tag it, push it, or embed it in a larger tree.
215
216
 
217
+ The returned OID is not durable by itself. Use a branch or tag for ordinary Git
218
+ history, the vault for durable named history, or a root set for a mutable
219
+ current-generation cache. A JSON field containing the OID does not make Git
220
+ consider the object reachable.
221
+
216
222
  ### Codecs
217
223
 
218
224
  The codec controls how the manifest is serialized before being written to
@@ -1379,6 +1385,46 @@ Invalid slugs throw `INVALID_SLUG`.
1379
1385
 
1380
1386
  ---
1381
1387
 
1388
+ ## 13b. Root Sets
1389
+
1390
+ Root sets are the GC-safe surface for caches and derived state. Unlike the
1391
+ vault, they retain only the current generation by default.
1392
+
1393
+ ```javascript
1394
+ const snapshots = await cas.rootSets.open({
1395
+ ref: 'refs/cas/rootsets/warp/state-cache',
1396
+ });
1397
+
1398
+ await snapshots.put({
1399
+ name: snapshotId,
1400
+ oid: payloadTreeOid,
1401
+ type: 'tree',
1402
+ retention: 'evictable',
1403
+ });
1404
+ ```
1405
+
1406
+ While the entry is present, the root-set ref reaches the target tree and its
1407
+ payload blobs. After `remove({ name })`, the target follows normal Git grace
1408
+ period and pruning rules if no other ref reaches it.
1409
+
1410
+ For an existing application index, adopt all still-live OIDs before cleanup:
1411
+
1412
+ ```javascript
1413
+ const report = await snapshots.doctor();
1414
+ if (!report.healthy) {
1415
+ await snapshots.repair({ entries: authoritativeLiveEntries });
1416
+ }
1417
+ ```
1418
+
1419
+ `pinned` and `evictable` are application policy labels. Both entries are
1420
+ anchored while present. Root sets do not create pack `.keep` files, encrypt
1421
+ entry names, or preserve mutation history.
1422
+
1423
+ See [API Reference: Root Sets](./API.md#root-sets) for the full mutation,
1424
+ doctor, repair, and error contracts.
1425
+
1426
+ ---
1427
+
1382
1428
  ## 14. Architecture
1383
1429
 
1384
1430
  `git-cas` follows a hexagonal (ports and adapters) architecture. The domain
@@ -0,0 +1,75 @@
1
+ # git-cas v6.1.0 Release Notes
2
+
3
+ `v6.1.0` adds a middle retention surface between unrooted CAS plumbing and the
4
+ history-preserving vault.
5
+
6
+ ## Root Sets
7
+
8
+ Applications can now retain the current generation of cache, checkpoint,
9
+ index, or derived-state objects under a caller-owned ref:
10
+
11
+ ```javascript
12
+ const cas = await ContentAddressableStore.open({ cwd: '.' });
13
+ const rootSet = await cas.rootSets.open({
14
+ ref: 'refs/cas/rootsets/my-application/cache',
15
+ });
16
+
17
+ await rootSet.put({
18
+ name: cacheKey,
19
+ oid: payloadTreeOid,
20
+ type: 'tree',
21
+ retention: 'evictable',
22
+ });
23
+ ```
24
+
25
+ Entries are Git-reachable while present. Each update writes a parentless
26
+ current-generation commit, so removing an entry releases it from root-set
27
+ history. If no other branch, tag, reflog, vault, or root set reaches the target,
28
+ it follows normal Git grace-period and pruning rules.
29
+
30
+ ## Retention Vocabulary
31
+
32
+ - `pinned` and `evictable` describe application retention policy.
33
+ - `anchored`, `orphaned`, and `volatile` describe Git reachability state.
34
+ - Root-set `pinned` does not create pack `.keep` files.
35
+ - The vault still preserves mutation history and remains the durable named
36
+ asset surface.
37
+
38
+ ## Doctor And Repair
39
+
40
+ `rootSet.doctor()` checks ref, commit, metadata, reachability edges, target
41
+ existence, and target type. `rootSet.repair({ entries })` rebuilds a missing or
42
+ malformed current head from an authoritative list without trusting existing
43
+ metadata.
44
+
45
+ Applications upgrading from JSON-only OID indexes should adopt every still-live
46
+ object into a root set before any destructive cleanup. Objects already pruned
47
+ by Git cannot be recovered by this API.
48
+
49
+ ## Compatibility
50
+
51
+ This release is API-additive. Existing manifests, vaults, branches, tags, and
52
+ `createTree()` behavior are unchanged. `createTree()` remains low-level and
53
+ unrooted until a caller anchors its returned OID.
54
+
55
+ Custom persistence implementations that support root sets must add
56
+ `readObjectType(oid)`, and custom ref adapters must add
57
+ `resolveParents(commitOid)`. Existing CAS store/restore paths do not call those
58
+ methods.
59
+
60
+ ## Proof
61
+
62
+ The release includes a real-Git integration test using
63
+ `git prune -n --expire=now`:
64
+
65
+ - a target tree is not reported while present in a root set
66
+ - the same tree is reported after removal when no other ref reaches it
67
+ - root-set commits have no parent
68
+ - missing and mismatched targets are rejected before the ref changes
69
+
70
+ See [API Reference: Root Sets](../API.md#root-sets) and
71
+ [UPGRADING.md](../../UPGRADING.md#v601-to-v610).
72
+
73
+ The release verifier passed 12/12 steps with 5,521 observed tests across Node,
74
+ Bun, Deno, and all three integration runtimes. The JSR publish dry-run remains
75
+ intentionally skipped under the documented upstream toolchain gate.
package/index.d.ts CHANGED
@@ -3,19 +3,55 @@
3
3
  * Content Addressable Store — Managed blob storage in Git.
4
4
  */
5
5
 
6
- import Manifest from "./src/domain/value-objects/Manifest.js";
7
- import type { EncryptionMeta, ManifestData, CompressionMeta, KdfParams, SubManifestRef, RecipientEntry, EncryptionScheme } from "./src/domain/value-objects/Manifest.js";
8
- import Chunk from "./src/domain/value-objects/Chunk.js";
9
- import CasService from "./src/domain/services/CasService.js";
10
- import CasError from "./src/domain/errors/CasError.js";
11
- import type { CryptoPort, CodecPort, GitPersistencePort, ObservabilityPort, CasServiceOptions, DeriveKeyOptions, DeriveKeyResult, StoreEncryptionOptions, VerifyIntegrityOptions } from "./src/domain/services/CasService.js";
6
+ import Manifest from './src/domain/value-objects/Manifest.js';
7
+ import type {
8
+ EncryptionMeta,
9
+ ManifestData,
10
+ CompressionMeta,
11
+ KdfParams,
12
+ SubManifestRef,
13
+ RecipientEntry,
14
+ EncryptionScheme,
15
+ } from './src/domain/value-objects/Manifest.js';
16
+ import Chunk from './src/domain/value-objects/Chunk.js';
17
+ import CasService from './src/domain/services/CasService.js';
18
+ import CasError from './src/domain/errors/CasError.js';
19
+ import type {
20
+ CryptoPort,
21
+ CodecPort,
22
+ GitPersistencePort,
23
+ ObservabilityPort,
24
+ CasServiceOptions,
25
+ DeriveKeyOptions,
26
+ DeriveKeyResult,
27
+ StoreEncryptionOptions,
28
+ VerifyIntegrityOptions,
29
+ } from './src/domain/services/CasService.js';
12
30
 
13
31
  export { CasService, CasError, Manifest, Chunk };
14
32
  /** Type alias mapping the runtime `CompressionPort` export to its base class declaration. */
15
33
  export type CompressionPort = CompressionPortBase;
16
34
 
17
- export type { EncryptionMeta, ManifestData, CompressionMeta, KdfParams, SubManifestRef, RecipientEntry, EncryptionScheme };
18
- export type { CryptoPort, CodecPort, GitPersistencePort, ObservabilityPort, CasServiceOptions, DeriveKeyOptions, DeriveKeyResult, StoreEncryptionOptions, VerifyIntegrityOptions };
35
+ export type {
36
+ EncryptionMeta,
37
+ ManifestData,
38
+ CompressionMeta,
39
+ KdfParams,
40
+ SubManifestRef,
41
+ RecipientEntry,
42
+ EncryptionScheme,
43
+ };
44
+ export type {
45
+ CryptoPort,
46
+ CodecPort,
47
+ GitPersistencePort,
48
+ ObservabilityPort,
49
+ CasServiceOptions,
50
+ DeriveKeyOptions,
51
+ DeriveKeyResult,
52
+ StoreEncryptionOptions,
53
+ VerifyIntegrityOptions,
54
+ };
19
55
 
20
56
  /** Abstract port for compression and decompression of buffers and streams. */
21
57
  export declare class CompressionPortBase {
@@ -38,7 +74,7 @@ export declare class ChunkingPort {
38
74
  /** Fixed-size chunking adapter. */
39
75
  export declare class FixedChunker extends ChunkingPort {
40
76
  constructor(options?: { chunkSize?: number });
41
- get strategy(): "fixed";
77
+ get strategy(): 'fixed';
42
78
  get params(): { chunkSize: number };
43
79
  }
44
80
 
@@ -50,7 +86,7 @@ export declare class CdcChunker extends ChunkingPort {
50
86
  targetChunkSize?: number;
51
87
  normalized?: boolean;
52
88
  });
53
- get strategy(): "cdc";
89
+ get strategy(): 'cdc';
54
90
  get params(): { target: number; min: number; max: number; normalized: boolean };
55
91
  }
56
92
 
@@ -61,27 +97,39 @@ export declare class CryptoPortBase {
61
97
  encryptBuffer(
62
98
  buffer: Uint8Array,
63
99
  key: Uint8Array,
64
- aad?: Uint8Array,
100
+ aad?: Uint8Array
65
101
  ): { buf: Uint8Array; meta: EncryptionMeta } | Promise<{ buf: Uint8Array; meta: EncryptionMeta }>;
66
- decryptBuffer(buffer: Uint8Array, key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): Uint8Array | Promise<Uint8Array>;
67
- createEncryptionStream(key: Uint8Array, aad?: Uint8Array): {
102
+ decryptBuffer(
103
+ buffer: Uint8Array,
104
+ key: Uint8Array,
105
+ meta: EncryptionMeta,
106
+ aad?: Uint8Array
107
+ ): Uint8Array | Promise<Uint8Array>;
108
+ createEncryptionStream(
109
+ key: Uint8Array,
110
+ aad?: Uint8Array
111
+ ): {
68
112
  encrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
69
113
  finalize: () => EncryptionMeta;
70
114
  };
71
- createDecryptionStream(key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): {
115
+ createDecryptionStream(
116
+ key: Uint8Array,
117
+ meta: EncryptionMeta,
118
+ aad?: Uint8Array
119
+ ): {
72
120
  decrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
73
121
  };
74
122
  hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array | Promise<Uint8Array>;
75
123
  encryptBufferWithNonce(
76
124
  buffer: Uint8Array,
77
125
  key: Uint8Array,
78
- nonce: Uint8Array,
126
+ nonce: Uint8Array
79
127
  ): { buf: Uint8Array; tag: Uint8Array } | Promise<{ buf: Uint8Array; tag: Uint8Array }>;
80
128
  decryptBufferWithNonceTag(
81
129
  buffer: Uint8Array,
82
130
  key: Uint8Array,
83
131
  nonce: Uint8Array,
84
- tag: Uint8Array,
132
+ tag: Uint8Array
85
133
  ): Uint8Array | Promise<Uint8Array>;
86
134
  deriveKey(options: DeriveKeyOptions): Promise<DeriveKeyResult>;
87
135
  }
@@ -93,15 +141,16 @@ export declare class GitPersistencePortBase {
93
141
  readBlob(oid: string): Promise<Uint8Array>;
94
142
  readBlobStream(oid: string): Promise<AsyncIterable<Uint8Array>>;
95
143
  readTree(
96
- treeOid: string,
144
+ treeOid: string
97
145
  ): Promise<Array<{ mode: string; type: string; oid: string; name: string }>>;
98
146
  readTreeEntry(
99
147
  treeOid: string,
100
- treePath: string,
148
+ treePath: string
101
149
  ): Promise<{ mode: string; type: string; oid: string; name: string } | null>;
102
150
  iterateTree(
103
- treeOid: string,
151
+ treeOid: string
104
152
  ): AsyncIterable<{ mode: string; type: string; oid: string; name: string }>;
153
+ readObjectType(oid: string): Promise<string>;
105
154
  setMaxBlobSize?(maxBlobSize: number): void;
106
155
  }
107
156
 
@@ -109,6 +158,7 @@ export declare class GitPersistencePortBase {
109
158
  export declare class GitRefPortBase {
110
159
  resolveRef(ref: string): Promise<string>;
111
160
  resolveTree(commitOid: string): Promise<string>;
161
+ resolveParents(commitOid: string): Promise<string[]>;
112
162
  createCommit(options: {
113
163
  treeOid: string;
114
164
  parentOid?: string | null;
@@ -188,11 +238,12 @@ export declare class StatsCollector {
188
238
 
189
239
  /** Declarative chunking strategy configuration. */
190
240
  export interface ChunkingConfig {
191
- strategy: "fixed" | "cdc";
241
+ strategy: 'fixed' | 'cdc';
192
242
  chunkSize?: number;
193
243
  targetChunkSize?: number;
194
244
  minChunkSize?: number;
195
245
  maxChunkSize?: number;
246
+ normalized?: boolean;
196
247
  }
197
248
 
198
249
  /** Constructor options for {@link ContentAddressableStore}. */
@@ -216,7 +267,10 @@ export interface ContentAddressableStoreOptions {
216
267
  }
217
268
 
218
269
  /** Options for {@link ContentAddressableStore.open}. */
219
- export interface ContentAddressableStoreOpenOptions extends Omit<ContentAddressableStoreOptions, "plumbing"> {
270
+ export interface ContentAddressableStoreOpenOptions extends Omit<
271
+ ContentAddressableStoreOptions,
272
+ 'plumbing'
273
+ > {
220
274
  /** Git working directory used to construct the default Git plumbing adapter. @default "." */
221
275
  cwd?: string;
222
276
  /** Optional shell-runner environment override for Git plumbing. */
@@ -224,7 +278,10 @@ export interface ContentAddressableStoreOpenOptions extends Omit<ContentAddressa
224
278
  }
225
279
 
226
280
  /** Options for codec-specific facade factories. */
227
- export type ContentAddressableStoreCodecFactoryOptions = Omit<ContentAddressableStoreOptions, "codec">;
281
+ export type ContentAddressableStoreCodecFactoryOptions = Omit<
282
+ ContentAddressableStoreOptions,
283
+ 'codec'
284
+ >;
228
285
 
229
286
  /** A single vault entry. */
230
287
  export interface VaultEntry {
@@ -232,6 +289,92 @@ export interface VaultEntry {
232
289
  treeOid: string;
233
290
  }
234
291
 
292
+ export type RootSetEntryType = 'blob' | 'tree';
293
+ export type RootSetRetention = 'pinned' | 'evictable';
294
+
295
+ /** One Git object retained by a root set while the entry is present. */
296
+ export interface RootSetEntry {
297
+ name: string;
298
+ oid: string;
299
+ type: RootSetEntryType;
300
+ retention: RootSetRetention;
301
+ }
302
+
303
+ export interface RootSetState {
304
+ ref: string;
305
+ headOid: string | null;
306
+ treeOid: string | null;
307
+ entries: RootSetEntry[];
308
+ }
309
+
310
+ export interface RootSetMutationResult {
311
+ changed: boolean;
312
+ commitOid: string | null;
313
+ treeOid: string | null;
314
+ entries: RootSetEntry[];
315
+ }
316
+
317
+ export interface RootSetDoctorResult {
318
+ healthy: boolean;
319
+ ref: string;
320
+ headOid?: string | null;
321
+ treeOid?: string | null;
322
+ entryCount?: number;
323
+ entries?: RootSetEntry[];
324
+ policyCounts?: { pinned: number; evictable: number };
325
+ reachabilityCounts?: {
326
+ anchored: number;
327
+ missing: number;
328
+ unknown: number;
329
+ orphaned: number;
330
+ volatile: number;
331
+ };
332
+ targets?: Array<RootSetEntry & {
333
+ exists: boolean | null;
334
+ actualType: string | null;
335
+ reachability: 'anchored' | 'missing' | 'unknown';
336
+ }>;
337
+ issues?: Array<Record<string, unknown>>;
338
+ error?: { code: string; message: string };
339
+ }
340
+
341
+ export declare class RootSet {
342
+ readonly ref: string;
343
+ read(): Promise<RootSetState>;
344
+ list(): Promise<RootSetEntry[]>;
345
+ contains(name: string): Promise<boolean>;
346
+ put(entry: Omit<RootSetEntry, 'retention'> & { retention?: RootSetRetention }): Promise<
347
+ RootSetMutationResult & { entry: RootSetEntry; previous: RootSetEntry | null }
348
+ >;
349
+ remove(options: { name: string }): Promise<
350
+ RootSetMutationResult & { removed: RootSetEntry | null }
351
+ >;
352
+ replace(options: {
353
+ entries: Iterable<RootSetEntry>;
354
+ expectedHeadOid?: string | null;
355
+ }): Promise<RootSetMutationResult>;
356
+ mutate(
357
+ mutator: (
358
+ entries: ReadonlyArray<Readonly<RootSetEntry>>,
359
+ ) => Iterable<RootSetEntry> | Promise<Iterable<RootSetEntry>>,
360
+ options?: { expectedHeadOid?: string | null },
361
+ ): Promise<RootSetMutationResult>;
362
+ doctor(): Promise<RootSetDoctorResult>;
363
+ repair(options: { entries: Iterable<RootSetEntry> }): Promise<{
364
+ repaired: true;
365
+ commitOid: string;
366
+ treeOid: string;
367
+ entries: RootSetEntry[];
368
+ }>;
369
+ }
370
+
371
+ export declare class RootSetRegistry {
372
+ open(options: {
373
+ ref: string;
374
+ retry?: { maxAttempts?: number; baseDelayMs?: number };
375
+ }): RootSet;
376
+ }
377
+
235
378
  /** Encrypted vault key verifier stored in .vault.json. */
236
379
  export interface VaultEncryptionVerifier {
237
380
  version: 1;
@@ -308,7 +451,7 @@ export declare class VaultService {
308
451
  /** Initializes the vault, optionally with encryption and privacy mode. */
309
452
  initVault(options?: {
310
453
  passphrase?: string;
311
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
454
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
312
455
  /** Enable privacy mode (requires passphrase/encryption). */
313
456
  privacy?: boolean;
314
457
  }): Promise<{ commitOid: string }>;
@@ -393,8 +536,16 @@ export default class ContentAddressableStore {
393
536
 
394
537
  get chunkSize(): number;
395
538
 
539
+ readonly rootSets: {
540
+ open(options: {
541
+ ref: string;
542
+ retry?: { maxAttempts?: number; baseDelayMs?: number };
543
+ }): Promise<RootSet>;
544
+ };
545
+
396
546
  getService(): Promise<CasService>;
397
547
  getVaultService(): Promise<VaultService>;
548
+ getRootSetRegistry(): Promise<RootSetRegistry>;
398
549
 
399
550
  static open(options?: ContentAddressableStoreOpenOptions): Promise<ContentAddressableStore>;
400
551
 
@@ -422,10 +573,11 @@ export default class ContentAddressableStore {
422
573
  encryptionKey?: Uint8Array;
423
574
  passphrase?: string;
424
575
  encryption?: StoreEncryptionOptions;
425
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
426
- compression?: { algorithm: "gzip" };
576
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
577
+ compression?: { algorithm: 'gzip' };
427
578
  recipients?: Array<{ label: string; key: Uint8Array }>;
428
579
  merkleThreshold?: number;
580
+ chunking?: ChunkingConfig;
429
581
  }): Promise<Manifest>;
430
582
 
431
583
  store(options: {
@@ -435,10 +587,11 @@ export default class ContentAddressableStore {
435
587
  encryptionKey?: Uint8Array;
436
588
  passphrase?: string;
437
589
  encryption?: StoreEncryptionOptions;
438
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
439
- compression?: { algorithm: "gzip" };
590
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
591
+ compression?: { algorithm: 'gzip' };
440
592
  recipients?: Array<{ label: string; key: Uint8Array }>;
441
593
  merkleThreshold?: number;
594
+ chunking?: ChunkingConfig;
442
595
  }): Promise<Manifest>;
443
596
 
444
597
  restoreFile(options: {
@@ -467,14 +620,10 @@ export default class ContentAddressableStore {
467
620
 
468
621
  readManifest(options: { treeOid: string }): Promise<Manifest>;
469
622
 
470
- inspectAsset(options: {
471
- treeOid: string;
472
- }): Promise<{ slug: string; chunksOrphaned: number }>;
623
+ inspectAsset(options: { treeOid: string }): Promise<{ slug: string; chunksOrphaned: number }>;
473
624
 
474
625
  /** @deprecated Use {@link inspectAsset} instead. */
475
- deleteAsset(options: {
476
- treeOid: string;
477
- }): Promise<{ slug: string; chunksOrphaned: number }>;
626
+ deleteAsset(options: { treeOid: string }): Promise<{ slug: string; chunksOrphaned: number }>;
478
627
 
479
628
  collectReferencedChunks(options: {
480
629
  treeOids: string[];
@@ -494,10 +643,7 @@ export default class ContentAddressableStore {
494
643
  label: string;
495
644
  }): Promise<Manifest>;
496
645
 
497
- removeRecipient(options: {
498
- manifest: Manifest;
499
- label: string;
500
- }): Promise<Manifest>;
646
+ removeRecipient(options: { manifest: Manifest; label: string }): Promise<Manifest>;
501
647
 
502
648
  listRecipients(manifest: Manifest): Promise<string[]>;
503
649
 
@@ -514,7 +660,7 @@ export default class ContentAddressableStore {
514
660
 
515
661
  initVault(options?: {
516
662
  passphrase?: string;
517
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
663
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
518
664
  /** Enable privacy mode (requires passphrase/encryption). */
519
665
  privacy?: boolean;
520
666
  }): Promise<{ commitOid: string }>;
@@ -558,7 +704,7 @@ export default class ContentAddressableStore {
558
704
  rotateVaultPassphrase(options: {
559
705
  oldPassphrase: string;
560
706
  newPassphrase: string;
561
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
707
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
562
708
  /** Maximum optimistic-concurrency retries on VAULT_CONFLICT. @default 3 */
563
709
  maxRetries?: number;
564
710
  /** Base delay in ms for exponential backoff between retries. @default 50 */