@git-stunts/git-cas 6.5.9 → 6.5.10
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 +7 -5
- package/CHANGELOG.md +24 -0
- package/GUIDE.md +12 -7
- package/README.md +8 -4
- package/UPGRADING.md +41 -3
- package/build-info.json +2 -2
- package/docs/releases/v6.5.10.md +117 -0
- package/index.d.ts +6 -0
- package/package.json +2 -1
- package/src/domain/services/AssetService.js +5 -0
- package/src/domain/services/StagingWorkspaceRegistry.js +1 -1
- package/src/domain/services/WorkspaceCompoundAdmission.js +80 -5
- package/src/domain/services/WorkspaceCompoundScope.js +23 -4
- package/src/package-version.js +1 -1
package/ARCHITECTURE.md
CHANGED
|
@@ -185,11 +185,13 @@ The facade is orchestration glue. It is not the storage engine itself.
|
|
|
185
185
|
- **`StagingWorkspaceRegistry` and `StagingWorkspace`** — own renewable
|
|
186
186
|
temporary RootSet generations for multi-step application construction.
|
|
187
187
|
`WorkspaceCompoundAdmission` and `WorkspaceCompoundScope` serialize an
|
|
188
|
-
explicitly bounded sequence of provisional page and bundle batches
|
|
189
|
-
one operation-owned persistence view
|
|
190
|
-
targets
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
explicitly bounded sequence of provisional asset, page, and bundle batches
|
|
189
|
+
through one operation-owned persistence view. Compound calls retain all new
|
|
190
|
+
targets by default or canonically validate an exact nonempty selection of
|
|
191
|
+
handles staged by that call, then install those selected roots together with
|
|
192
|
+
every prior workspace target in one exact generation. Existing workspace
|
|
193
|
+
methods retain each result independently and remain the boundary when a
|
|
194
|
+
handle leaves private construction code before later writes begin.
|
|
193
195
|
|
|
194
196
|
- **`RetentionService` and `PublicationService`** — validate complete handle
|
|
195
197
|
graphs, then either retain them in a RootSet with generation-scoped evidence
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.5.10] — 2026-08-24
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Compound asset admission and exact terminal roots** -
|
|
15
|
+
`workspace.batch()` now exposes bounded `scope.assets.putBatch()` alongside
|
|
16
|
+
page and ordered-bundle waves. An optional synchronous `retain(value)`
|
|
17
|
+
selector can retain a nonempty, canonical, deduplicated subset of handles
|
|
18
|
+
staged by that exact call while preserving every prior workspace root.
|
|
19
|
+
Malformed, asynchronous, empty, oversized, lookalike, and
|
|
20
|
+
valid-but-unstaged selections fail before ref movement. Omitting the selector
|
|
21
|
+
preserves v6.5.9 retain-all behavior.
|
|
22
|
+
|
|
23
|
+
### Performance
|
|
24
|
+
|
|
25
|
+
- **One admission for payload-to-terminal graphs** - replay and provenance
|
|
26
|
+
assets can share the compound persistence scope and final workspace
|
|
27
|
+
installation with their support bundles, descriptor, and terminal bundle.
|
|
28
|
+
In the downstream controlled 65-node/65-patch git-warp prototype, cold Git
|
|
29
|
+
commands fell from 139 to 50 and median wall time from 2.823 s to 1.329 s;
|
|
30
|
+
incremental commands fell from 149 to 60 and median wall time from 3.040 s to
|
|
31
|
+
1.387 s. Semantic fingerprints, cache posture, replay counts, storage
|
|
32
|
+
formats, handles, and the 25-command warm read path remained unchanged.
|
|
33
|
+
|
|
10
34
|
## [6.5.9] — 2026-08-24
|
|
11
35
|
|
|
12
36
|
### Added
|
package/GUIDE.md
CHANGED
|
@@ -207,25 +207,30 @@ intermediate handles inside one compound staging-workspace operation:
|
|
|
207
207
|
|
|
208
208
|
```js
|
|
209
209
|
const admitted = await workspace.batch({
|
|
210
|
-
maxOperations:
|
|
210
|
+
maxOperations: 4,
|
|
211
211
|
operation: async (scope) => {
|
|
212
|
+
const assets = await scope.assets.putBatch({ assets: assetRequests });
|
|
212
213
|
const pages = await scope.pages.putBatch({ pages: pageRequests });
|
|
213
214
|
const leaves = await scope.bundles.putOrderedBatch({
|
|
214
|
-
bundles: leafRequests(pages),
|
|
215
|
+
bundles: leafRequests(assets, pages),
|
|
215
216
|
});
|
|
216
217
|
return (await scope.bundles.putOrderedBatch({
|
|
217
218
|
bundles: [rootRequest(leaves)],
|
|
218
219
|
}))[0];
|
|
219
220
|
},
|
|
221
|
+
retain: (terminal) => [terminal],
|
|
220
222
|
});
|
|
221
223
|
```
|
|
222
224
|
|
|
223
225
|
`admitted.value` becomes caller-visible only with `admitted.retention`, after
|
|
224
|
-
one exact workspace generation anchors
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
one exact workspace generation anchors the selected terminal plus every root
|
|
227
|
+
retained before the compound call. Omit `retain` to preserve the retain-all
|
|
228
|
+
behavior. A selector must synchronously return at least one canonical handle
|
|
229
|
+
staged by that exact callback; it cannot import another operation's handle or
|
|
230
|
+
remove a prior workspace root. The default operation ceiling is 64 and the hard
|
|
231
|
+
ceiling is 1,024; each scope call also preserves its ordinary asset, page, or
|
|
232
|
+
bundle batch bounds. Use the existing independently retained workspace methods
|
|
233
|
+
when intermediate handles must leave the private callback.
|
|
229
234
|
|
|
230
235
|
Repeated `pages.get()` calls reuse immutable payload reads within the store's
|
|
231
236
|
bounded page cache. The defaults retain at most 128 payloads and 8 MiB; use
|
package/README.md
CHANGED
|
@@ -41,8 +41,9 @@ Unlike traditional LFS which moves files to external servers, `git-cas` treats t
|
|
|
41
41
|
blob reads at or below a fixed 10 MiB ceiling use one bounded session read;
|
|
42
42
|
larger payloads retain the genuine one-shot streaming path. Explicitly
|
|
43
43
|
bounded page, asset, and ordered-bundle batches pipeline independent Git
|
|
44
|
-
writes. `workspace.batch()` can compose dependent page and bundle
|
|
45
|
-
one private persistence scope and retain their union
|
|
44
|
+
writes. `workspace.batch()` can compose dependent asset, page, and bundle
|
|
45
|
+
waves in one private persistence scope and either retain their union or an
|
|
46
|
+
explicitly selected set of newly staged terminal roots under one exact final
|
|
46
47
|
generation without changing content identity.
|
|
47
48
|
- **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.
|
|
48
49
|
- **Runtime-Adaptive**: A single core supports Node.js 22+, Bun, and Deno through a strict hexagonal port architecture with runtime-specific crypto adapters.
|
|
@@ -52,7 +53,7 @@ Unlike traditional LFS which moves files to external servers, `git-cas` treats t
|
|
|
52
53
|
Existing v5 users should read [UPGRADING.md](./UPGRADING.md) and run
|
|
53
54
|
`npm run upgrade` in dry-run mode before restoring old encrypted vault entries.
|
|
54
55
|
For the release overview, see the
|
|
55
|
-
[v6.5.
|
|
56
|
+
[v6.5.10 Release Notes](./docs/releases/v6.5.10.md).
|
|
56
57
|
|
|
57
58
|
### 1. CLI Usage
|
|
58
59
|
|
|
@@ -158,7 +159,8 @@ Core capabilities:
|
|
|
158
159
|
compare-and-swap refs, and immutable lifecycle evidence.
|
|
159
160
|
- **Scoped staging workspaces**: `workspaces.open()` mirrors application writes
|
|
160
161
|
behind one renewable temporary RootSet, supports one-generation bounded
|
|
161
|
-
asset/page/bundle batches plus compound dependent page/bundle admission
|
|
162
|
+
asset/page/bundle batches plus compound dependent asset/page/bundle admission
|
|
163
|
+
with exact newly staged terminal-root selection,
|
|
162
164
|
returns only after each public result is anchored, promotes destination-first,
|
|
163
165
|
and exposes bounded age, expiry, logical-content, and direct-root diagnostics
|
|
164
166
|
with opaque cleanup pagination.
|
|
@@ -240,6 +242,8 @@ All three runtimes are tested in CI on every push. The hexagonal architecture is
|
|
|
240
242
|
write waves, one-generation workspace batches, and reusable ref sessions.
|
|
241
243
|
- **[v6.5.9 Release Notes](./docs/releases/v6.5.9.md)**: Compound dependent
|
|
242
244
|
write waves retained under one exact staging-workspace generation.
|
|
245
|
+
- **[v6.5.10 Release Notes](./docs/releases/v6.5.10.md)**: Compound asset,
|
|
246
|
+
page, and bundle admission with exact selected terminal roots.
|
|
243
247
|
- **[Upgrading](./UPGRADING.md)**: Migration guide for v5 → v6.
|
|
244
248
|
- **[Changelog](./CHANGELOG.md)**: Version history and migration notes.
|
|
245
249
|
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
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.9 To v6.5.10
|
|
6
|
+
|
|
7
|
+
v6.5.10 adds compound asset admission and exact terminal-root selection and
|
|
8
|
+
requires no application or stored-data migration. Existing object bytes,
|
|
9
|
+
handles, descriptors, workspace generations, ref layouts, readers, and
|
|
10
|
+
retain-all compound calls remain compatible. Existing repositories open in
|
|
11
|
+
place.
|
|
12
|
+
|
|
13
|
+
Compound callbacks may now stage bounded asset batches alongside pages and
|
|
14
|
+
ordered bundles. An optional synchronous selector can retain only terminal
|
|
15
|
+
handles staged by that exact callback:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
const admitted = await workspace.batch({
|
|
19
|
+
maxOperations: 4,
|
|
20
|
+
operation: async (scope) => {
|
|
21
|
+
const assets = await scope.assets.putBatch({ assets: assetRequests });
|
|
22
|
+
const pages = await scope.pages.putBatch({ pages: pageRequests });
|
|
23
|
+
const leaves = await scope.bundles.putOrderedBatch({
|
|
24
|
+
bundles: leafRequests(assets, pages),
|
|
25
|
+
});
|
|
26
|
+
return (
|
|
27
|
+
await scope.bundles.putOrderedBatch({
|
|
28
|
+
bundles: [rootRequest(leaves)],
|
|
29
|
+
})
|
|
30
|
+
)[0];
|
|
31
|
+
},
|
|
32
|
+
retain: (terminal) => [terminal],
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The selector must return a nonempty array of canonical handles staged by the
|
|
37
|
+
same admission. It is bounded by that admission's staged-artifact count,
|
|
38
|
+
deduplicates repeated handles in stable order, and cannot remove roots retained
|
|
39
|
+
before the call. Omit `retain` to preserve v6.5.9 retain-all behavior.
|
|
40
|
+
|
|
5
41
|
## v6.5.8 To v6.5.9
|
|
6
42
|
|
|
7
43
|
v6.5.9 adds `workspace.batch()` and requires no application or stored-data
|
|
@@ -20,9 +56,11 @@ const admitted = await workspace.batch({
|
|
|
20
56
|
const leaves = await scope.bundles.putOrderedBatch({
|
|
21
57
|
bundles: buildLeafRequests(pages),
|
|
22
58
|
});
|
|
23
|
-
return (
|
|
24
|
-
bundles
|
|
25
|
-
|
|
59
|
+
return (
|
|
60
|
+
await scope.bundles.putOrderedBatch({
|
|
61
|
+
bundles: [buildRootRequest(leaves)],
|
|
62
|
+
})
|
|
63
|
+
)[0];
|
|
26
64
|
},
|
|
27
65
|
});
|
|
28
66
|
|
package/build-info.json
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# git-cas v6.5.10 Release Notes
|
|
2
|
+
|
|
3
|
+
v6.5.10 completes bounded compound staging-workspace admission by adding asset
|
|
4
|
+
waves and exact selected terminal roots. Applications can stage replay or
|
|
5
|
+
provenance payloads, pages, support bundles, descriptors, and one terminal
|
|
6
|
+
bundle through a shared persistence scope, then publish one exact workspace
|
|
7
|
+
generation without retaining every construction intermediate as a direct root.
|
|
8
|
+
|
|
9
|
+
## Compound Assets And Exact Roots
|
|
10
|
+
|
|
11
|
+
`workspace.batch()` now exposes the existing bounded asset-batch contract on
|
|
12
|
+
its private scope:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
const admitted = await workspace.batch({
|
|
16
|
+
maxOperations: 4,
|
|
17
|
+
operation: async (scope) => {
|
|
18
|
+
const assets = await scope.assets.putBatch({ assets: assetRequests });
|
|
19
|
+
const pages = await scope.pages.putBatch({ pages: pageRequests });
|
|
20
|
+
const leaves = await scope.bundles.putOrderedBatch({
|
|
21
|
+
bundles: leafRequests(assets, pages),
|
|
22
|
+
});
|
|
23
|
+
return (
|
|
24
|
+
await scope.bundles.putOrderedBatch({
|
|
25
|
+
bundles: [rootRequest(leaves)],
|
|
26
|
+
})
|
|
27
|
+
)[0];
|
|
28
|
+
},
|
|
29
|
+
retain: (terminal) => [terminal],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
admitted.value;
|
|
33
|
+
admitted.retention;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Asset, page, and bundle calls serialize by invocation order and share the
|
|
37
|
+
operation-owned persistence scope. Every call retains its ordinary count,
|
|
38
|
+
object, member, and byte limits. Asset writes preserve the same chunking,
|
|
39
|
+
compression, encryption, manifest, and handle semantics as the public
|
|
40
|
+
`assets.putBatch()` method.
|
|
41
|
+
|
|
42
|
+
The optional `retain(value)` callback executes synchronously after the bounded
|
|
43
|
+
operation succeeds. It must return a nonempty array of canonical handles staged
|
|
44
|
+
by that exact admission. Input count cannot exceed the staged-artifact ledger;
|
|
45
|
+
repeated handles deduplicate in stable order. Malformed, asynchronous, empty,
|
|
46
|
+
oversized, lookalike, and valid-but-unstaged selections fail before the
|
|
47
|
+
workspace ref moves. Omitting the selector preserves v6.5.9 retain-all
|
|
48
|
+
behavior.
|
|
49
|
+
|
|
50
|
+
Exact selection affects only newly staged direct roots. Every root retained
|
|
51
|
+
before the compound call remains in the next generation. A selected terminal
|
|
52
|
+
bundle continues to retain its referenced pages, assets, and nested bundles
|
|
53
|
+
transitively through ordinary Git tree edges.
|
|
54
|
+
|
|
55
|
+
## Failure And Reachability
|
|
56
|
+
|
|
57
|
+
An asset failure poisons queued dependent work, publishes no compound
|
|
58
|
+
generation, and exposes no admitted callback result. A selector refusal also
|
|
59
|
+
leaves the prior generation unchanged. Immutable objects written before a
|
|
60
|
+
refusal may remain unreachable until normal Git maintenance reclaims them; the
|
|
61
|
+
selector is not a cross-ref transaction.
|
|
62
|
+
|
|
63
|
+
Real-Git integration tests cover fresh SHA-1 and SHA-256 repositories. They
|
|
64
|
+
prove one checked workspace update, closed scoped sessions, selected-root
|
|
65
|
+
readback after immediate prune, preservation of prior roots, reclamation after
|
|
66
|
+
workspace release, and no-generation refusal behavior.
|
|
67
|
+
|
|
68
|
+
## Downstream Process Witness
|
|
69
|
+
|
|
70
|
+
A controlled git-warp prototype compared a 65-node, 65-patch materialization
|
|
71
|
+
plus a five-patch suffix using public v6.5.9 as the control and this exact API
|
|
72
|
+
as a local prototype. Each scenario used one warmup and three measured runs.
|
|
73
|
+
|
|
74
|
+
| Scenario | Git commands | Median CPU ms | Median wall ms |
|
|
75
|
+
| ----------- | -----------: | ------------: | -------------: |
|
|
76
|
+
| Cold before | 139 | 545.476 | 2,822.893 |
|
|
77
|
+
| Cold after | 50 | 322.103 | 1,328.603 |
|
|
78
|
+
| Incr before | 149 | 555.478 | 3,039.536 |
|
|
79
|
+
| Incr after | 60 | 320.050 | 1,387.245 |
|
|
80
|
+
| Warm before | 25 | 166.882 | 548.191 |
|
|
81
|
+
| Warm after | 25 | 176.325 | 622.956 |
|
|
82
|
+
|
|
83
|
+
Cold writes fell from 139 to 50 Git commands: 64.029% fewer commands, 40.950%
|
|
84
|
+
less Node CPU, and 52.935% less wall time. Incremental writes fell from 149 to
|
|
85
|
+
60 commands: 59.732% fewer commands, 42.383% less Node CPU, and 54.360% less
|
|
86
|
+
wall time. Semantic fingerprints, node/edge/property counts, cache posture, and
|
|
87
|
+
replay counts matched. The warm read path materializes no writes and retained
|
|
88
|
+
its exact 25-command topology; elapsed variation there is host noise, not a
|
|
89
|
+
claimed regression or gain.
|
|
90
|
+
|
|
91
|
+
These downstream measurements are deliberately provisional until git-warp
|
|
92
|
+
installs the public v6.5.10 registry artifact and repeats the same corpus. The
|
|
93
|
+
deterministic contract is the equal semantic result and reduced command
|
|
94
|
+
topology, not a universal timing promise.
|
|
95
|
+
|
|
96
|
+
## Verification
|
|
97
|
+
|
|
98
|
+
Implementation review #128 merged normally as
|
|
99
|
+
`57cd300294a94660d2afb644c653a3be78c15d53`; its exact reviewed head is
|
|
100
|
+
`6714750620aa2310ad0279f957414be65898a66a`. Exact implementation checkpoint
|
|
101
|
+
`e663754bf221784f0e5856a41fe071bebfa5befb` passed all 14 release-verifier
|
|
102
|
+
stages with 7,186 observed tests across Node, Bun, Deno, public types,
|
|
103
|
+
executable examples, real-Git integrations, build stamping, npm packing, and a
|
|
104
|
+
JSR publication dry-run. Exact versioned candidate
|
|
105
|
+
`2a5be40c718e8069fb466af1be265357d8cb7ce0` then passed the same 14-stage
|
|
106
|
+
method with 7,192 observed tests: 2,194 Node, 2,193 Bun, 2,184 Deno, and 207
|
|
107
|
+
integration tests in each runtime. No tag, npm artifact, or GitHub Release is
|
|
108
|
+
claimed by this candidate.
|
|
109
|
+
|
|
110
|
+
## Compatibility
|
|
111
|
+
|
|
112
|
+
This release is additive and requires no application or stored-data migration.
|
|
113
|
+
It makes no stored object, handle, descriptor, ref layout, or reader change.
|
|
114
|
+
Existing repositories and workspace refs open in place; existing callers may
|
|
115
|
+
keep retain-all compound behavior by omitting `retain`. Custom asset services
|
|
116
|
+
that do not implement the scoped persistence hook remain compatible for page-
|
|
117
|
+
and bundle-only compound calls and reject only if the new asset scope is used.
|
package/index.d.ts
CHANGED
|
@@ -1618,6 +1618,11 @@ export const DEFAULT_WORKSPACE_COMPOUND_OPERATIONS: 64;
|
|
|
1618
1618
|
export const MAX_WORKSPACE_COMPOUND_OPERATIONS: 1024;
|
|
1619
1619
|
|
|
1620
1620
|
export interface WorkspaceCompoundScope {
|
|
1621
|
+
readonly assets: {
|
|
1622
|
+
putBatch(
|
|
1623
|
+
options: Parameters<AssetCapability['putBatch']>[0],
|
|
1624
|
+
): Promise<ReadonlyArray<AssetHandle>>;
|
|
1625
|
+
};
|
|
1621
1626
|
readonly pages: {
|
|
1622
1627
|
putBatch(
|
|
1623
1628
|
options: Parameters<PageCapability['putBatch']>[0],
|
|
@@ -1715,6 +1720,7 @@ export declare class StagingWorkspace {
|
|
|
1715
1720
|
batch<T>(options: {
|
|
1716
1721
|
operation(scope: WorkspaceCompoundScope): T | Promise<T>;
|
|
1717
1722
|
maxOperations?: number;
|
|
1723
|
+
retain?: (value: T) => ReadonlyArray<ApplicationHandleInput>;
|
|
1718
1724
|
}): Promise<Readonly<WorkspaceCompoundResult<T>>>;
|
|
1719
1725
|
checkpoint(options: { handles: Iterable<ApplicationHandleInput> }): Promise<WorkspaceCheckpointResult>;
|
|
1720
1726
|
renew(): Promise<WorkspaceCheckpointResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git-stunts/git-cas",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.10",
|
|
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",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"docs/releases/v6.5.7.md",
|
|
47
47
|
"docs/releases/v6.5.8.md",
|
|
48
48
|
"docs/releases/v6.5.9.md",
|
|
49
|
+
"docs/releases/v6.5.10.md",
|
|
49
50
|
"docs/THREAT_MODEL.md",
|
|
50
51
|
"docs/VAULT_INTERNALS.md",
|
|
51
52
|
"docs/WALKTHROUGH.md",
|
|
@@ -48,6 +48,11 @@ export default class AssetService {
|
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** Internal batch path that joins an existing persistence write scope. */
|
|
52
|
+
async putBatchWithPersistence(options = {}, persistence) {
|
|
53
|
+
return await this.#putBatch(AssetService.#batchOptions(options), persistence);
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
async #putBatch(batch, scopedPersistence) {
|
|
52
57
|
const persistence = new BoundedWriteWavePersistence({
|
|
53
58
|
persistence: scopedPersistence,
|
|
@@ -70,7 +70,7 @@ export default class StagingWorkspaceRegistry {
|
|
|
70
70
|
this.#crypto = crypto;
|
|
71
71
|
this.#clock = clock;
|
|
72
72
|
this.#descriptorCodec = descriptorCodec;
|
|
73
|
-
this.#compound = new WorkspaceCompoundAdmission({ persistence, pages, bundles });
|
|
73
|
+
this.#compound = new WorkspaceCompoundAdmission({ persistence, assets, pages, bundles });
|
|
74
74
|
Object.freeze(this);
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import createCasError from '../errors/createCasError.js';
|
|
2
2
|
import { ErrorCodes } from '../errors/index.js';
|
|
3
|
+
import parseApplicationHandle from '../value-objects/ApplicationHandle.js';
|
|
3
4
|
import WorkspaceCompoundScope from './WorkspaceCompoundScope.js';
|
|
4
5
|
|
|
5
6
|
/** Executes one bounded provisional graph build before exact workspace retention. */
|
|
6
7
|
export default class WorkspaceCompoundAdmission {
|
|
8
|
+
#assets;
|
|
7
9
|
#bundles;
|
|
8
10
|
#pages;
|
|
9
11
|
#persistence;
|
|
10
12
|
|
|
11
|
-
constructor({ persistence, pages, bundles }) {
|
|
12
|
-
WorkspaceCompoundAdmission.#assertDependencies({ persistence, pages, bundles });
|
|
13
|
+
constructor({ persistence, assets, pages, bundles }) {
|
|
14
|
+
WorkspaceCompoundAdmission.#assertDependencies({ persistence, assets, pages, bundles });
|
|
13
15
|
this.#persistence = persistence;
|
|
16
|
+
this.#assets = assets;
|
|
14
17
|
this.#pages = pages;
|
|
15
18
|
this.#bundles = bundles;
|
|
16
19
|
Object.freeze(this);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
async admit({ operation, maxOperations, install } = {}) {
|
|
22
|
+
async admit({ operation, maxOperations, retain, install } = {}) {
|
|
20
23
|
if (typeof install !== 'function') {
|
|
21
24
|
throw createCasError(
|
|
22
25
|
'Workspace compound admission requires an installation callback',
|
|
@@ -25,20 +28,23 @@ export default class WorkspaceCompoundAdmission {
|
|
|
25
28
|
}
|
|
26
29
|
return await withWriteScope(this.#persistence, async (persistence) => {
|
|
27
30
|
const scope = new WorkspaceCompoundScope({
|
|
31
|
+
assets: this.#assets,
|
|
28
32
|
pages: this.#pages,
|
|
29
33
|
bundles: this.#bundles,
|
|
30
34
|
persistence,
|
|
31
35
|
maxOperations,
|
|
32
36
|
});
|
|
33
37
|
const prepared = await scope.execute(operation);
|
|
34
|
-
const
|
|
38
|
+
const selected = retainedArtifacts(prepared, retain);
|
|
39
|
+
const retention = await install(selected, persistence);
|
|
35
40
|
return Object.freeze({ value: prepared.value, retention });
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
static #assertDependencies({ persistence, pages, bundles }) {
|
|
44
|
+
static #assertDependencies({ persistence, assets, pages, bundles }) {
|
|
40
45
|
const missing = [
|
|
41
46
|
['persistence', persistence === null || typeof persistence !== 'object'],
|
|
47
|
+
['assets', assets === null || typeof assets !== 'object'],
|
|
42
48
|
['pages.putBatch', typeof pages?.putBatch !== 'function'],
|
|
43
49
|
['bundles', bundles === null || typeof bundles !== 'object'],
|
|
44
50
|
]
|
|
@@ -54,6 +60,75 @@ export default class WorkspaceCompoundAdmission {
|
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
function retainedArtifacts(prepared, retain) {
|
|
64
|
+
if (retain === undefined) {
|
|
65
|
+
return prepared.staged;
|
|
66
|
+
}
|
|
67
|
+
const requested = selectedInputs(prepared, retain);
|
|
68
|
+
const staged = new Map(prepared.staged.map((artifact) => [artifact.handle.toString(), artifact]));
|
|
69
|
+
const selected = [];
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
for (const input of requested) {
|
|
72
|
+
const handle = selectedHandle(input);
|
|
73
|
+
const key = handle.toString();
|
|
74
|
+
const artifact = staged.get(key);
|
|
75
|
+
if (artifact === undefined) {
|
|
76
|
+
throw createCasError(
|
|
77
|
+
'Workspace compound retention selector returned an unstaged handle',
|
|
78
|
+
ErrorCodes.INVALID_OPTIONS,
|
|
79
|
+
{ handle: key }
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (!seen.has(key)) {
|
|
83
|
+
selected.push(artifact);
|
|
84
|
+
seen.add(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return Object.freeze(selected);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function selectedInputs(prepared, retain) {
|
|
91
|
+
if (typeof retain !== 'function') {
|
|
92
|
+
throw createCasError(
|
|
93
|
+
'Workspace compound retention selector must be a function',
|
|
94
|
+
ErrorCodes.INVALID_OPTIONS
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const requested = retain(prepared.value);
|
|
98
|
+
if (!Array.isArray(requested)) {
|
|
99
|
+
throw createCasError(
|
|
100
|
+
'Workspace compound retention selector must synchronously return an array',
|
|
101
|
+
ErrorCodes.INVALID_OPTIONS
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (requested.length === 0) {
|
|
105
|
+
throw createCasError(
|
|
106
|
+
'Workspace compound retention selector must choose at least one staged handle',
|
|
107
|
+
ErrorCodes.INVALID_OPTIONS
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
if (requested.length > prepared.staged.length) {
|
|
111
|
+
throw createCasError(
|
|
112
|
+
'Workspace compound retention selector exceeds the staged handle count',
|
|
113
|
+
ErrorCodes.INVALID_OPTIONS,
|
|
114
|
+
{ requestedCount: requested.length, stagedCount: prepared.staged.length }
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
return requested;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function selectedHandle(input) {
|
|
121
|
+
try {
|
|
122
|
+
return parseApplicationHandle(input);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw createCasError(
|
|
125
|
+
'Workspace compound retention selector returned an invalid handle',
|
|
126
|
+
ErrorCodes.INVALID_OPTIONS,
|
|
127
|
+
{ originalError: error }
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
57
132
|
async function withWriteScope(persistence, operation) {
|
|
58
133
|
return typeof persistence.withWriteScope === 'function'
|
|
59
134
|
? await persistence.withWriteScope(operation)
|
|
@@ -4,9 +4,10 @@ import { ErrorCodes } from '../errors/index.js';
|
|
|
4
4
|
export const DEFAULT_WORKSPACE_COMPOUND_OPERATIONS = 64;
|
|
5
5
|
export const MAX_WORKSPACE_COMPOUND_OPERATIONS = 1_024;
|
|
6
6
|
|
|
7
|
-
/** Bounded provisional page and bundle writes owned by one compound admission. */
|
|
7
|
+
/** Bounded provisional asset, page, and bundle writes owned by one compound admission. */
|
|
8
8
|
export default class WorkspaceCompoundScope {
|
|
9
9
|
#active = true;
|
|
10
|
+
#assets;
|
|
10
11
|
#abortFailure;
|
|
11
12
|
#aborted = false;
|
|
12
13
|
#bundles;
|
|
@@ -20,13 +21,18 @@ export default class WorkspaceCompoundScope {
|
|
|
20
21
|
#staged = [];
|
|
21
22
|
#tail = Promise.resolve();
|
|
22
23
|
|
|
23
|
-
constructor({ pages, bundles, persistence, maxOperations }) {
|
|
24
|
-
WorkspaceCompoundScope.#assertDependencies({ pages, bundles, persistence });
|
|
24
|
+
constructor({ assets, pages, bundles, persistence, maxOperations }) {
|
|
25
|
+
WorkspaceCompoundScope.#assertDependencies({ assets, pages, bundles, persistence });
|
|
26
|
+
this.#assets = assets;
|
|
25
27
|
this.#pages = pages;
|
|
26
28
|
this.#bundles = bundles;
|
|
27
29
|
this.#persistence = persistence;
|
|
28
30
|
this.#maxOperations = WorkspaceCompoundScope.#operationLimit(maxOperations);
|
|
29
31
|
this.api = Object.freeze({
|
|
32
|
+
assets: Object.freeze({
|
|
33
|
+
putBatch: (options) =>
|
|
34
|
+
this.#enqueue('assets.putBatch', async () => await this.#putAssets(options)),
|
|
35
|
+
}),
|
|
30
36
|
pages: Object.freeze({
|
|
31
37
|
putBatch: (options) =>
|
|
32
38
|
this.#enqueue('pages.putBatch', async () => await this.#putPages(options)),
|
|
@@ -137,6 +143,18 @@ export default class WorkspaceCompoundScope {
|
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
145
|
|
|
146
|
+
async #putAssets(options) {
|
|
147
|
+
if (typeof this.#assets?.putBatchWithPersistence !== 'function') {
|
|
148
|
+
throw createCasError(
|
|
149
|
+
'Workspace compound asset batches are unavailable',
|
|
150
|
+
ErrorCodes.INVALID_OPTIONS,
|
|
151
|
+
{ method: 'assets.putBatch' }
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const staged = await this.#assets.putBatchWithPersistence(options, this.#persistence);
|
|
155
|
+
return this.#record(staged, 'asset');
|
|
156
|
+
}
|
|
157
|
+
|
|
140
158
|
async #putPages(options) {
|
|
141
159
|
const staged = await this.#pages.putBatchWithPersistence(options, this.#persistence);
|
|
142
160
|
return this.#record(staged, 'page');
|
|
@@ -171,8 +189,9 @@ export default class WorkspaceCompoundScope {
|
|
|
171
189
|
return limit;
|
|
172
190
|
}
|
|
173
191
|
|
|
174
|
-
static #assertDependencies({ pages, bundles, persistence }) {
|
|
192
|
+
static #assertDependencies({ assets, pages, bundles, persistence }) {
|
|
175
193
|
const missing = [
|
|
194
|
+
['assets', assets === null || typeof assets !== 'object'],
|
|
176
195
|
['pages.putBatchWithPersistence', typeof pages?.putBatchWithPersistence !== 'function'],
|
|
177
196
|
[
|
|
178
197
|
'bundles.putOrderedBatchWithPersistence',
|
package/src/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = '6.5.
|
|
1
|
+
export const PACKAGE_VERSION = '6.5.10';
|