@git-stunts/git-cas 6.5.1 → 6.5.3

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/ARCHITECTURE.md CHANGED
@@ -147,6 +147,8 @@ The public entrypoint is [index.js](./index.js).
147
147
  - exposes `retention`, `publications`, `caches`, and `expiringSets` for explicit
148
148
  reachability and lifecycle policy
149
149
  - exposes read-only repository evidence through `diagnostics.doctor()`
150
+ - owns explicit local resource closure without coupling closure to object or ref
151
+ mutation
150
152
 
151
153
  The facade is orchestration glue. It is not the storage engine itself.
152
154
 
@@ -329,7 +331,10 @@ Crypto:
329
331
 
330
332
  Git:
331
333
  - **`GitPersistenceAdapter`** — `GitPersistencePort` implementation using
332
- `@git-stunts/plumbing` to shell out to the `git` CLI.
334
+ `@git-stunts/plumbing` to shell out to the `git` CLI. It reuses typed
335
+ cat-file and mktree sessions, keeps parsed immutable trees count-and-byte
336
+ bounded, uses scoped fast-import only for explicit page batches, preserves
337
+ streaming payload reads, and owns deterministic child-process closure.
333
338
  - **`GitRefAdapter`** — `GitRefPort` implementation using
334
339
  `@git-stunts/plumbing`.
335
340
  - **`GitRepositoryInspectionAdapter`** — `RepositoryInspectionPort`
@@ -354,6 +359,8 @@ File I/O:
354
359
 
355
360
  - **`JsonCodec`** — `CodecPort` using JSON serialization (default).
356
361
  - **`CborCodec`** — `CodecPort` using CBOR serialization.
362
+ - **`GitTreeObjectCodec`** — boundary decoder for canonical SHA-1 and SHA-256
363
+ Git tree bytes plus typed mktree session entries.
357
364
 
358
365
  #### Chunkers (`src/infrastructure/chunkers/`)
359
366
 
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.5.3] — 2026-07-19
11
+
12
+ ### Performance
13
+
14
+ - **Coherent Git object session reuse** - successful loose object and tree
15
+ writes preserve typed `cat-file` and `mktree` processes. Scoped bulk writes
16
+ preserve `cat-file` but still retire `mktree` after checkpoint because Git's
17
+ quick tree-entry validation does not refresh packs created after the
18
+ session's object-database snapshot.
19
+
20
+ ## [6.5.2] — 2026-07-19
21
+
22
+ ### Added
23
+
24
+ - **Bounded page batches and explicit resource closure** -
25
+ `pages.putBatch()` stores an explicitly count-and-byte-bounded page group in
26
+ input order, while `ContentAddressableStore.close()` and async disposal drain
27
+ started operations and release local adapter resources without mutating
28
+ objects, refs, retention, or publication state.
29
+
30
+ ### Performance
31
+
32
+ - **Persistent Git object sessions** - immutable metadata and bounded tree
33
+ reads reuse one typed `cat-file` process, tree writes reuse typed `mktree`,
34
+ and page batches use one scoped `fast-import` process. Parsed tree reuse is
35
+ bounded by entry count and estimated bytes; payload streams remain streaming.
36
+ Individual blob writes deliberately remain one-shot so an object pruned by
37
+ an external process is recreated correctly on the next write.
38
+
10
39
  ## [6.5.1] — 2026-07-18
11
40
 
12
41
  ### Performance
package/GUIDE.md CHANGED
@@ -99,10 +99,13 @@ for await (const chunk of cas.assets.open({ handle: staged.handle })) {
99
99
  }
100
100
 
101
101
  console.log(retained.witness.root.generation);
102
+ await cas.close();
102
103
  ```
103
104
 
104
105
  Node's file stream is an `AsyncIterable<Uint8Array>`; Bun and Deno callers can
105
- supply their native async byte streams through the same contract.
106
+ supply their native async byte streams through the same contract. In production
107
+ code, call `close()` from `finally` or use async disposal. Closure releases
108
+ local resources only and does not change stored objects or retention.
106
109
 
107
110
  ## Application Storage Lifecycle
108
111
 
@@ -139,8 +142,9 @@ that is already sorted by canonical member path, so construction does not need
139
142
  to collect the complete member set.
140
143
 
141
144
  ```js
142
- const nodes = await cas.pages.put({ source: encodedNodePage });
143
- const edges = await cas.pages.put({ source: encodedEdgePage });
145
+ const [nodes, edges] = await cas.pages.putBatch({
146
+ pages: [{ source: encodedNodePage }, { source: encodedEdgePage }],
147
+ });
144
148
  const materialization = await cas.bundles.putOrdered({
145
149
  members: (async function* members() {
146
150
  yield ['edges/root', edges.handle];
@@ -163,6 +167,12 @@ lookup reads only the descriptor path and selected payload; retention and
163
167
  publication perform full bounded graph validation. Identical page bytes and
164
168
  identically constructed bundles produce identical handles.
165
169
 
170
+ `pages.putBatch()` collects and validates the complete explicit batch before
171
+ persistence. It accepts at most 256 pages and 32 MiB by default, preserves input
172
+ order, and uses one scoped Git write session when the plumbing adapter supports
173
+ it. Use individual `pages.put()` calls when inputs should not share one bounded
174
+ memory envelope.
175
+
166
176
  Repeated `pages.get()` calls reuse immutable payload reads within the store's
167
177
  bounded page cache. The defaults retain at most 128 payloads and 8 MiB; use
168
178
  `pageCacheEntries` and `pageCacheBytes` to tune that ceiling. Every result is a
package/README.md CHANGED
@@ -36,6 +36,11 @@ Unlike traditional LFS which moves files to external servers, `git-cas` treats t
36
36
  and deterministic structured bundles through validated handles, then retain
37
37
  or publish them with generation-scoped evidence instead of managing Git
38
38
  objects, trees, or payload OIDs directly.
39
+ - **Bounded Git Process Reuse**: Immutable object metadata and tree reads reuse
40
+ typed Git sessions behind the adapter, while explicitly bounded page batches
41
+ amortize writes without changing content identity. Read and payload streams
42
+ remain streaming; complete page-batch inputs are collected and validated only
43
+ within the explicit count-and-byte envelope.
39
44
  - **Key Lifecycle**: Envelope encryption separates DEKs from KEKs. Rotate passphrases across an entire vault without re-encrypting data blobs. Privacy mode HMAC-hashes slug names to prevent metadata discovery.
40
45
  - **Runtime-Adaptive**: A single core supports Node.js 22+, Bun, and Deno through a strict hexagonal port architecture with runtime-specific crypto adapters.
41
46
 
@@ -44,7 +49,7 @@ Unlike traditional LFS which moves files to external servers, `git-cas` treats t
44
49
  Existing v5 users should read [UPGRADING.md](./UPGRADING.md) and run
45
50
  `npm run upgrade` in dry-run mode before restoring old encrypted vault entries.
46
51
  For the release overview, see the
47
- [v6.5.1 Release Notes](./docs/releases/v6.5.1.md).
52
+ [v6.5.3 Release Notes](./docs/releases/v6.5.3.md).
48
53
 
49
54
  ### 1. CLI Usage
50
55
 
@@ -84,11 +89,13 @@ const retained = await cas.retention.retain({
84
89
  root: { ref: 'refs/cas/rootsets/my-app', name: 'app/asset' },
85
90
  policy: 'pinned',
86
91
  });
92
+ await cas.close();
87
93
  ```
88
94
 
89
95
  `staged.handle` is a content locator, not a durability promise. The returned
90
96
  retention witness identifies the exact Git generation and tree edge that made
91
- the asset reachable.
97
+ the asset reachable. `close()` releases local resources only; it never deletes
98
+ objects, updates refs, or changes retention.
92
99
 
93
100
  ## Capability Map
94
101
 
@@ -138,8 +145,9 @@ Core capabilities:
138
145
  read-only, and `sweep()` can release only markers whose expiry has passed.
139
146
  - **Application storage**: `assets`, `pages`, `bundles`, `retention`, and
140
147
  `publications` compose streaming CAS writes, bounded structured
141
- materializations, direct-reference or complete-validation member reads,
142
- reachability roots, compare-and-swap refs, and immutable lifecycle evidence.
148
+ materializations, explicitly bounded page batches, direct-reference or
149
+ complete-validation member reads, reachability roots, compare-and-swap refs,
150
+ and immutable lifecycle evidence.
143
151
  - **Scoped staging workspaces**: `workspaces.open()` mirrors application writes
144
152
  behind one renewable temporary RootSet, returns only after each handle is
145
153
  anchored, promotes destination-first, and exposes bounded age, expiry,
@@ -206,6 +214,10 @@ All three runtimes are tested in CI on every push. The hexagonal architecture is
206
214
  references, immutable metadata reuse, and corrected concurrency settlement.
207
215
  - **[v6.5.1 Release Notes](./docs/releases/v6.5.1.md)**: Bounded immutable page
208
216
  payload reuse with zero-command warm reads.
217
+ - **[v6.5.2 Release Notes](./docs/releases/v6.5.2.md)**: Persistent bounded Git
218
+ object sessions, scoped page batches, and deterministic resource closure.
219
+ - **[v6.5.3 Release Notes](./docs/releases/v6.5.3.md)**: Coherent reuse of
220
+ persistent Git object sessions across compatible immutable writes.
209
221
  - **[Upgrading](./UPGRADING.md)**: Migration guide for v5 → v6.
210
222
  - **[Changelog](./CHANGELOG.md)**: Version history and migration notes.
211
223
 
package/UPGRADING.md CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  v6.0.0 is a major release that simplifies the encryption model, hardens security defaults, and cleans up the architecture. This guide covers every breaking change and what you need to do.
4
4
 
5
+ ## v6.5.2 To v6.5.3
6
+
7
+ v6.5.3 changes no public API and requires no stored-data migration. Long-lived
8
+ stores automatically preserve their typed `cat-file` session across successful
9
+ immutable writes. They also preserve typed `mktree` across loose blob and tree
10
+ writes, while bounded bulk writes still retire `mktree` because `fast-import`
11
+ may create a pack that an already prepared process cannot discover.
12
+
13
+ No application code changes are required. Continue to call `await cas.close()`
14
+ when the store is no longer needed; explicit closure remains the deterministic
15
+ boundary for local Git children and bounded in-memory residency.
16
+
17
+ See [v6.5.3 Release Notes](./docs/releases/v6.5.3.md) for the audited coherence
18
+ matrix and measured process-count reduction.
19
+
20
+ ## v6.5.1 To v6.5.2
21
+
22
+ v6.5.2 is API-additive and does not require stored-data migration. Immutable
23
+ metadata and tree reads automatically reuse bounded typed Git sessions when the
24
+ injected plumbing supports them. Existing structural adapters remain compatible
25
+ and continue through the command-per-operation fallback.
26
+
27
+ Use `pages.putBatch()` when an application already has an explicit bounded page
28
+ group. The default envelope accepts at most 256 pages and 32 MiB, supports a
29
+ lower `maxBytes` on each page, preserves input order, and performs no writes
30
+ until the complete bounded batch is valid. Individual `pages.put()` calls remain
31
+ one-shot so an externally pruned unreachable blob can be recreated correctly.
32
+
33
+ Call `await cas.close()` when the store is no longer needed, especially when an
34
+ operation may still be active or a stream may remain unconsumed. Closing drains
35
+ or terminates local Git processes and releases bounded cache residency only; it
36
+ does not delete stored objects, move refs, or change retention or publication
37
+ state.
38
+
39
+ See [v6.5.2 Release Notes](./docs/releases/v6.5.2.md) and
40
+ [Application Storage](./docs/API.md#application-storage) for the complete batch,
41
+ streaming, and lifecycle contracts.
42
+
5
43
  ## v6.5.0 To v6.5.1
6
44
 
7
45
  v6.5.1 is API-additive and does not require stored-data migration. Repeated
package/build-info.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "49b7d5c",
3
- "timestamp": "2026-07-19T00:14:16.713Z"
2
+ "sha": "00df607",
3
+ "timestamp": "2026-07-19T17:10:30.099Z"
4
4
  }
package/docs/API.md CHANGED
@@ -182,6 +182,21 @@ Lazily initializes and returns the underlying VaultService instance.
182
182
  const vaultService = await cas.getVaultService();
183
183
  ```
184
184
 
185
+ #### close
186
+
187
+ ```javascript
188
+ await cas.close();
189
+ ```
190
+
191
+ Blocks new facade operations, drains started persistence operations, and
192
+ releases adapter-owned Git sessions and streams. The method is idempotent and
193
+ is also available as `Symbol.asyncDispose`.
194
+
195
+ Closure affects local resources only. It does not delete Git objects, update
196
+ refs, run garbage collection, expire retained content, or mutate publication
197
+ state. Production code should call `close()` from `finally` when async disposal
198
+ syntax is unavailable.
199
+
185
200
  #### store
186
201
 
187
202
  ```javascript
@@ -1004,11 +1019,20 @@ Validates an existing git-cas manifest tree and wraps it in the same staged
1004
1019
  result returned by `assets.put()`. This is a migration bridge for callers that
1005
1020
  already persisted raw tree OIDs; new application code should exchange handles.
1006
1021
 
1007
- ### `pages.put()`, `pages.open()`, and `pages.get()`
1022
+ ### `pages.put()`, `pages.putBatch()`, `pages.open()`, and `pages.get()`
1008
1023
 
1009
1024
  ```javascript
1010
1025
  const staged = await cas.pages.put({ source, maxBytes });
1011
1026
 
1027
+ const stagedBatch = await cas.pages.putBatch({
1028
+ pages: [
1029
+ { source: firstPage, maxBytes: 4096 },
1030
+ { source: secondPage, maxBytes: 4096 },
1031
+ ],
1032
+ maxBatchPages: 16,
1033
+ maxBatchBytes: 65536,
1034
+ });
1035
+
1012
1036
  for await (const chunk of cas.pages.open({ handle: staged.handle })) {
1013
1037
  consume(chunk);
1014
1038
  }
@@ -1027,6 +1051,14 @@ metadata before streaming it. `get()` additionally collects the page under its
1027
1051
  effective byte bound. An imported handle above the configured maximum fails
1028
1052
  with `PAGE_TOO_LARGE` without materializing the blob.
1029
1053
 
1054
+ `putBatch()` returns an immutable ordered array of `StagedPage` results. It
1055
+ validates and collects every page before persistence begins, defaults to at
1056
+ most 256 pages and 32 MiB across the batch, and rejects count or aggregate-byte
1057
+ overflow with `PAGE_BATCH_LIMIT`. A session-capable Git adapter writes the
1058
+ batch through one scoped fast-import process that checkpoints and closes before
1059
+ the method returns. Individual `put()` calls remain one-shot so an externally
1060
+ pruned object is recreated correctly on a later identical write.
1061
+
1030
1062
  Successful `get()` payloads share in-flight and completed immutable reads inside
1031
1063
  one store instance. The default LRU retains at most 128 payloads and 8 MiB of
1032
1064
  payload bytes; `pageCacheEntries` and `pageCacheBytes` may lower or raise those
@@ -3342,12 +3374,14 @@ new CasError({ message, code, meta, documentationUrl });
3342
3374
  | `GIT_ERROR` | Underlying Git plumbing command failed | `readManifest()`, `inspectAsset()`, `collectReferencedChunks()` |
3343
3375
  | `GIT_REF_NOT_FOUND` | Git ref lookup found no ref; vault reads normalize this to empty state | `GitRefAdapter`, `VaultPersistence` |
3344
3376
  | `INVALID_OPTIONS` | Mutually exclusive options provided or unsupported option value | `store()`, `restore()` |
3377
+ | `RESOURCE_CLOSED` | A facade or persistence adapter operation began while or after closure was in progress | `ContentAddressableStore`, `GitPersistenceAdapter` |
3345
3378
  | `HANDLE_INVALID` | Handle object, canonical token, or staged result is malformed or unsupported | Application handles and staged results |
3346
3379
  | `HANDLE_KIND_MISMATCH` | A handle has a valid envelope but the wrong content kind | Handle parsing and application storage |
3347
3380
  | `HANDLE_CODEC_MISMATCH` | Handle manifest codec differs from the active CAS codec | `assets.open()`, `assets.adopt()`, retention, publication |
3348
3381
  | `HANDLE_TARGET_MISSING` | The repository does not contain the complete object graph referenced by a handle | `assets.open()`, `assets.adopt()`, retention, publication |
3349
3382
  | `HANDLE_TARGET_TYPE_MISMATCH` | A handle root or referenced object has the wrong Git object type | Application storage validation |
3350
3383
  | `PAGE_TOO_LARGE` | Page input or imported page blob exceeds the effective byte bound | `pages.put()`, `pages.get()`, `pages.open()` |
3384
+ | `PAGE_BATCH_LIMIT` | Page batch count or aggregate bytes exceed the explicit batch policy | `pages.putBatch()` |
3351
3385
  | `BUNDLE_CORRUPT` | Persisted bundle descriptors, edges, ranges, or target summaries disagree | Bundle reads, retention, publication |
3352
3386
  | `BUNDLE_DESCRIPTOR_LIMIT` | Bundle descriptor bytes exceed admission or repository read policy | Bundle construction and validation |
3353
3387
  | `BUNDLE_DUPLICATE_PATH` | Two ordered bundle members use the same canonical path | `bundles.putOrdered()` |
@@ -0,0 +1,63 @@
1
+ # git-cas v6.5.2 Release Notes
2
+
3
+ v6.5.2 removes repeated Git process startup from immutable object metadata and
4
+ tree reads, adds an explicitly bounded page-batch write path, and gives store
5
+ owners deterministic local resource cleanup.
6
+
7
+ ## Persistent Git Object Sessions
8
+
9
+ `GitPersistenceAdapter` now reuses one lazily opened typed `cat-file` session
10
+ for immutable metadata and tree reads. Tree creation uses typed `mktree`, while
11
+ each explicit page batch uses one scoped `fast-import` process. Existing
12
+ injected plumbing without typed session capabilities remains source-compatible
13
+ and uses the command-per-operation fallback.
14
+
15
+ Parsed tree residency is bounded by entry count and estimated bytes. Payload
16
+ reads and streams preserve their existing bounds; streams are not buffered.
17
+ Individual blob writes deliberately remain one-shot so a blob pruned by an
18
+ external process is recreated on the next write rather than trusted through
19
+ stale process state.
20
+
21
+ ## Bounded Page Batches
22
+
23
+ `pages.putBatch()` accepts a complete explicit page group, defaults to at most
24
+ 256 pages and 32 MiB, and permits lower per-page and aggregate bounds. It
25
+ collects and validates the bounded inputs before persistence, preserves input
26
+ order, and returns immutable staged-page results with the same content identity
27
+ as individual writes.
28
+
29
+ ## Resource Lifecycle
30
+
31
+ `ContentAddressableStore.close()` and async disposal block new operations,
32
+ drain work that already started, terminate abandoned streams and Git children,
33
+ close typed sessions, and release bounded cache residency. Closing is local
34
+ resource cleanup only. It never removes objects, moves refs, or changes
35
+ retention and publication state.
36
+
37
+ ## Performance Evidence
38
+
39
+ The controlled real-Git diagnostic reduced selected bundle-reference reads from
40
+ 225 Git processes to one and observed wall time from 288.647 ms to 50.366 ms.
41
+ Bounded page writes fell from 32 processes to one and from 68.658 ms to
42
+ 33.490 ms. Semantic digests were identical in both comparisons. Timing is
43
+ environment-specific; process counts and semantic equality are stable
44
+ regression contracts.
45
+
46
+ These measurements exclude Git child CPU and RSS. git-warp still owes its own
47
+ process-tree CPU, end-to-end latency, and larger-than-memory streaming evidence
48
+ after adopting this release.
49
+
50
+ ## Verification
51
+
52
+ The versioned candidate passed all 14 release-verifier steps with 6,817 observed
53
+ tests: 2,080 Node unit tests, 2,079 Bun unit tests, 2,070 Deno unit tests, and
54
+ 196 real-Git integration tests on each runtime. Lint, examples, public type
55
+ compatibility, build stamping, npm packaging dry-run, and JSR publication
56
+ dry-run also passed.
57
+
58
+ ## Compatibility
59
+
60
+ This release does not require stored-data migration. Existing persisted formats,
61
+ handles, refs, witnesses, and method signatures remain compatible. The batch and
62
+ lifecycle methods are additive, and low-level persistence adapters may continue
63
+ to omit the optional session, batch-write, and close capabilities.
@@ -0,0 +1,47 @@
1
+ # git-cas v6.5.3 Release Notes
2
+
3
+ v6.5.3 preserves coherent persistent Git object sessions across compatible
4
+ immutable writes. It is a process-topology correction to v6.5.2 and changes no
5
+ public API, stored format, object identity, retention policy, or lifecycle
6
+ contract.
7
+
8
+ ## Session Coherence
9
+
10
+ `GitPersistenceAdapter` now preserves its typed `cat-file --batch-command`
11
+ session after successful loose blob, bulk blob, and tree writes. Git permits
12
+ that process to refresh object-database state and discover both new loose
13
+ objects and packs created after the session started.
14
+
15
+ The adapter also preserves `mktree --batch -z` after loose blob and tree writes.
16
+ It deliberately retires `mktree` after a bounded `fast-import` batch because
17
+ Git's quick tree-entry lookup does not refresh packs created after the process
18
+ prepared its object database. The scoped `fast-import` process still
19
+ checkpoints and closes before any object ID escapes.
20
+
21
+ ## Measured Effect
22
+
23
+ In the audited 128-node git-warp retained-materialization fixture, total Git
24
+ children fell from 558 to 401. `cat-file` openings fell from 80 to four and
25
+ `mktree` openings fell from 82 to one. The three-run median materialization test
26
+ time fell from 14.24 seconds to 12.72 seconds, and measured process CPU fell
27
+ from 15.74 seconds to 13.83 seconds.
28
+
29
+ Process counts are deterministic regression evidence. Timings are local
30
+ observations, not cross-platform performance guarantees. The remaining 401 Git
31
+ children include 140 intentionally one-shot `hash-object` writes and git-warp
32
+ history, ref, and workspace operations outside this patch's scope.
33
+
34
+ ## Verification
35
+
36
+ The versioned candidate passed 2,082 Node unit tests, 2,081 Bun unit tests, 2,072
37
+ Deno unit tests, and 198 real-Git integration tests on each runtime. The full
38
+ release verifier passed all 14 steps with 6,829 observed tests. Real-Git
39
+ coverage exercises SHA-1 and SHA-256 repositories, later loose objects, later
40
+ packs above `fastimport.unpackLimit`, failure invalidation, idle retirement, and
41
+ explicit closure.
42
+
43
+ ## Compatibility
44
+
45
+ This release requires no application changes or stored-data migration.
46
+ Existing public methods, handles, refs, witnesses, object IDs, and retention
47
+ semantics remain compatible with v6.5.2.
package/index.d.ts CHANGED
@@ -513,6 +513,7 @@ export declare class CryptoPortBase {
513
513
  /** Abstract port for persisting data to Git's object database. */
514
514
  export declare class GitPersistencePortBase {
515
515
  writeBlob(content: Uint8Array): Promise<string>;
516
+ writeBlobs?(contents: Iterable<Uint8Array>): Promise<string[]>;
516
517
  writeTree(entries: string[]): Promise<string>;
517
518
  readBlob(oid: string, maxBytes?: number): Promise<Uint8Array>;
518
519
  readBlobStream(oid: string): Promise<AsyncIterable<Uint8Array>>;
@@ -529,6 +530,8 @@ export declare class GitPersistencePortBase {
529
530
  readObjectType(oid: string): Promise<string>;
530
531
  readObjectSize(oid: string): Promise<number>;
531
532
  setMaxBlobSize?(maxBlobSize: number): void;
533
+ close?(): Promise<void>;
534
+ [Symbol.asyncDispose]?(): Promise<void>;
532
535
  }
533
536
 
534
537
  /** Abstract port for Git ref and commit operations. */
@@ -568,8 +571,14 @@ export declare class GitPersistenceAdapter extends GitPersistencePortBase {
568
571
  plumbing: unknown;
569
572
  policy?: unknown;
570
573
  metadataCacheEntries?: number;
574
+ sessionIdleTimeoutMs?: number;
575
+ treeCacheEntries?: number;
576
+ treeCacheBytes?: number;
571
577
  });
578
+ writeBlobs(contents: Iterable<Uint8Array>): Promise<string[]>;
572
579
  setMaxBlobSize(maxBlobSize: number): void;
580
+ close(): Promise<void>;
581
+ [Symbol.asyncDispose](): Promise<void>;
573
582
  }
574
583
 
575
584
  /** Git-backed implementation of the ref port. */
@@ -1455,6 +1464,11 @@ export type PageSource =
1455
1464
 
1456
1465
  export interface PageCapability {
1457
1466
  put(options: { source: PageSource; maxBytes?: number }): Promise<StagedPage>;
1467
+ putBatch(options: {
1468
+ pages: Array<{ source: PageSource; maxBytes?: number }>;
1469
+ maxBatchBytes?: number;
1470
+ maxBatchPages?: number;
1471
+ }): Promise<ReadonlyArray<StagedPage>>;
1458
1472
  get(options: { handle: PageHandleInput; maxBytes?: number }): Promise<Uint8Array>;
1459
1473
  open(options: { handle: PageHandleInput }): AsyncIterable<Uint8Array>;
1460
1474
  }
@@ -1723,6 +1737,9 @@ export default class ContentAddressableStore {
1723
1737
  getService(): Promise<CasService>;
1724
1738
  getVaultService(): Promise<VaultService>;
1725
1739
  getRootSetRegistry(): Promise<RootSetRegistry>;
1740
+ /** Releases local resources only. Stored objects and refs are unchanged. */
1741
+ close(): Promise<void>;
1742
+ [Symbol.asyncDispose](): Promise<void>;
1726
1743
 
1727
1744
  static open(options?: ContentAddressableStoreOpenOptions): Promise<ContentAddressableStore>;
1728
1745
 
package/index.js CHANGED
@@ -215,6 +215,7 @@ export default class ContentAddressableStore {
215
215
  });
216
216
  this.pages = Object.freeze({
217
217
  put: async (options) => (await this.#getPageService()).put(options),
218
+ putBatch: async (options) => (await this.#getPageService()).putBatch(options),
218
219
  get: async (options) => (await this.#getPageService()).get(options),
219
220
  open: (options) => this.#openPage(options),
220
221
  });
@@ -261,6 +262,8 @@ export default class ContentAddressableStore {
261
262
  #stagingWorkspaceRegistry = null;
262
263
  /** @type {RepositoryDoctor|null} */
263
264
  #repositoryDoctor = null;
265
+ #closePromise = null;
266
+ #closed = false;
264
267
  #servicePromise = null;
265
268
 
266
269
  /**
@@ -269,6 +272,7 @@ export default class ContentAddressableStore {
269
272
  * @returns {Promise<CasService>}
270
273
  */
271
274
  async #getService() {
275
+ this.#assertOpen();
272
276
  if (!this.#servicePromise) {
273
277
  this.#servicePromise = this.#initService();
274
278
  }
@@ -608,6 +612,37 @@ export default class ContentAddressableStore {
608
612
  return await this.#getRootSetRegistry();
609
613
  }
610
614
 
615
+ /**
616
+ * Releases local adapter resources. This does not mutate stored objects,
617
+ * refs, retention, or publication state.
618
+ * @returns {Promise<void>}
619
+ */
620
+ async close() {
621
+ if (this.#closePromise !== null) {
622
+ return await this.#closePromise;
623
+ }
624
+ this.#closed = true;
625
+ this.#closePromise = (async () => {
626
+ if (this.#servicePromise === null) {
627
+ return;
628
+ }
629
+ const service = await this.#servicePromise;
630
+ await service.persistence.close();
631
+ })();
632
+ return await this.#closePromise;
633
+ }
634
+
635
+ /** @returns {Promise<void>} */
636
+ async [Symbol.asyncDispose]() {
637
+ await this.close();
638
+ }
639
+
640
+ #assertOpen() {
641
+ if (this.#closed) {
642
+ throw createCasError('Content-addressable store is closed', ErrorCodes.RESOURCE_CLOSED);
643
+ }
644
+ }
645
+
611
646
  /**
612
647
  * Factory to create a default JSON CAS from a Git working directory.
613
648
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git-stunts/git-cas",
3
- "version": "6.5.1",
3
+ "version": "6.5.3",
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",
@@ -38,6 +38,8 @@
38
38
  "docs/releases/v6.4.0.md",
39
39
  "docs/releases/v6.5.0.md",
40
40
  "docs/releases/v6.5.1.md",
41
+ "docs/releases/v6.5.2.md",
42
+ "docs/releases/v6.5.3.md",
41
43
  "docs/THREAT_MODEL.md",
42
44
  "docs/VAULT_INTERNALS.md",
43
45
  "docs/WALKTHROUGH.md",
@@ -103,7 +105,7 @@
103
105
  "@flyingrobots/bijou-tui": "^5.0.0",
104
106
  "@flyingrobots/bijou-tui-app": "^5.0.0",
105
107
  "@git-stunts/alfred": "^0.10.0",
106
- "@git-stunts/plumbing": "^3.1.0",
108
+ "@git-stunts/plumbing": "^3.2.0",
107
109
  "@git-stunts/vault": "^1.0.1",
108
110
  "cbor-x": "^1.6.0",
109
111
  "commander": "14.0.3",
@@ -55,6 +55,7 @@ const ErrorCodes = Object.freeze({
55
55
  MANIFEST_NOT_FOUND: 'MANIFEST_NOT_FOUND',
56
56
  MISSING_KEY: 'MISSING_KEY',
57
57
  NO_MATCHING_RECIPIENT: 'NO_MATCHING_RECIPIENT',
58
+ PAGE_BATCH_LIMIT: 'PAGE_BATCH_LIMIT',
58
59
  PAGE_TOO_LARGE: 'PAGE_TOO_LARGE',
59
60
  PERSISTENCE_CAPABILITY_REQUIRED: 'PERSISTENCE_CAPABILITY_REQUIRED',
60
61
  PORT_NOT_IMPLEMENTED: 'PORT_NOT_IMPLEMENTED',
@@ -65,6 +66,7 @@ const ErrorCodes = Object.freeze({
65
66
  RECIPIENT_ALREADY_EXISTS: 'RECIPIENT_ALREADY_EXISTS',
66
67
  RECIPIENT_NOT_FOUND: 'RECIPIENT_NOT_FOUND',
67
68
  REPOSITORY_INSPECTION_INVALID: 'REPOSITORY_INSPECTION_INVALID',
69
+ RESOURCE_CLOSED: 'RESOURCE_CLOSED',
68
70
  RESTORE_TOO_LARGE: 'RESTORE_TOO_LARGE',
69
71
  RETENTION_WITNESS_INVALID: 'RETENTION_WITNESS_INVALID',
70
72
  ROOT_SET_CONFLICT: 'ROOT_SET_CONFLICT',