@git-stunts/git-cas 5.3.0 → 5.3.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.3.1] — 2026-03-15
9
+
10
+ ### Fixed
11
+ - **Repeated chunk tree emission** — `createTree()` and `_createMerkleTree()` now emit one chunk blob tree entry per unique digest, preserving first-seen order at write time while leaving the manifest unchanged as the authoritative ordered index of chunk occurrences.
12
+ - **Invalid Git trees for repetitive content** — repetitive files no longer produce duplicate tree entry names, so emitted trees pass `git fsck --full` without `duplicateEntries` failures.
13
+ - **Regression coverage for tree reachability** — added unit tests for first-seen dedupe behavior and integration tests that store repetitive content, verify restore correctness, and assert clean `git fsck` results on a real Git repository.
14
+
8
15
  ## [5.3.0] — 2026-03-08
9
16
 
10
17
  ### Added
package/README.md CHANGED
@@ -38,6 +38,17 @@ We use the object database.
38
38
 
39
39
  <img src="./docs/demo.gif" alt="git-cas demo" />
40
40
 
41
+ ## What's new in v5.3.1
42
+
43
+ **Patch release — repeated chunk tree fix.**
44
+
45
+ - **Unique chunk tree entries** — `createTree()` and `_createMerkleTree()` now emit one tree entry per unique chunk digest instead of repeating the same filename for repeated chunk occurrences.
46
+ - **Manifest remains authoritative** — chunk order and multiplicity still come entirely from the manifest; restore behavior is unchanged.
47
+ - **Clean `git fsck` on repetitive files** — repetitive content no longer yields duplicate tree filenames or `duplicateEntries` errors.
48
+ - **New regressions** — unit and integration coverage now exercises repeated-chunk files and validates real Git tree integrity with `git fsck --full`.
49
+
50
+ See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
51
+
41
52
  ## What's new in v5.3.0
42
53
 
43
54
  **M16 Capstone — audit remediation, CLI configuration, and security hardening.**
@@ -56,8 +67,6 @@ We use the object database.
56
67
  - **Constructor validation** — `chunkSize`, `maxRestoreBufferSize`, `maxEncryptionBufferSize` validated at construction time.
57
68
  - **Cross-runtime portability** — `Error.captureStackTrace` guarded, crypto adapter contracts normalized.
58
69
 
59
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
60
-
61
70
  ## What's new in v5.2.3
62
71
 
63
72
  **Internal refactoring — no breaking API changes.** The facade, CasService, and crypto adapters were restructured for better separation of concerns:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git-stunts/git-cas",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Content-addressed storage backed by Git's object database, with optional encryption and pluggable codecs",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -320,11 +320,37 @@ export default class CasService {
320
320
  return data;
321
321
  }
322
322
 
323
+ /**
324
+ * Builds unique chunk blob tree entries in first-seen order.
325
+ *
326
+ * Tree entries keep chunk blobs reachable in Git. The manifest remains the
327
+ * authoritative ordered list of chunk occurrences, so repeated digests only
328
+ * need one tree entry.
329
+ *
330
+ * @private
331
+ * @param {import('../value-objects/Chunk.js').default[]} chunks
332
+ * @returns {string[]}
333
+ */
334
+ _createChunkTreeEntries(chunks) {
335
+ const treeEntries = [];
336
+ const seenDigests = new Set();
337
+
338
+ for (const chunk of chunks) {
339
+ if (seenDigests.has(chunk.digest)) {
340
+ continue;
341
+ }
342
+ seenDigests.add(chunk.digest);
343
+ treeEntries.push(`100644 blob ${chunk.blob}\t${chunk.digest}`);
344
+ }
345
+
346
+ return treeEntries;
347
+ }
348
+
323
349
  /**
324
350
  * Creates a Git tree object from a manifest.
325
351
  *
326
- * The tree contains the serialized manifest file and one blob entry per chunk,
327
- * keyed by its SHA-256 digest.
352
+ * The tree contains the serialized manifest file and one blob entry per
353
+ * unique chunk digest, preserving first-seen order.
328
354
  *
329
355
  * @param {Object} options
330
356
  * @param {import('../value-objects/Manifest.js').default} options.manifest - The file manifest.
@@ -342,7 +368,7 @@ export default class CasService {
342
368
 
343
369
  const treeEntries = [
344
370
  `100644 blob ${manifestOid}\tmanifest.${this.codec.extension}`,
345
- ...chunks.map((c) => `100644 blob ${c.blob}\t${c.digest}`),
371
+ ...this._createChunkTreeEntries(chunks),
346
372
  ];
347
373
 
348
374
  return await this.persistence.writeTree(treeEntries);
@@ -358,7 +384,6 @@ export default class CasService {
358
384
  async _createMerkleTree({ manifest }) {
359
385
  const chunks = [...manifest.chunks];
360
386
  const subManifestRefs = [];
361
- const chunkBlobEntries = [];
362
387
 
363
388
  for (let i = 0; i < chunks.length; i += this.merkleThreshold) {
364
389
  const group = chunks.slice(i, i + this.merkleThreshold);
@@ -371,10 +396,6 @@ export default class CasService {
371
396
  chunkCount: group.length,
372
397
  startIndex: i,
373
398
  });
374
-
375
- for (const c of group) {
376
- chunkBlobEntries.push(`100644 blob ${c.blob}\t${c.digest}`);
377
- }
378
399
  }
379
400
 
380
401
  const rootManifestData = {
@@ -394,7 +415,7 @@ export default class CasService {
394
415
  const treeEntries = [
395
416
  `100644 blob ${rootOid}\tmanifest.${this.codec.extension}`,
396
417
  ...subManifestEntries,
397
- ...chunkBlobEntries,
418
+ ...this._createChunkTreeEntries(chunks),
398
419
  ];
399
420
 
400
421
  return await this.persistence.writeTree(treeEntries);