@git-stunts/git-cas 6.3.0 → 6.5.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/ARCHITECTURE.md +2 -0
- package/CHANGELOG.md +57 -0
- package/README.md +29 -20
- package/UPGRADING.md +106 -19
- package/build-info.json +2 -2
- package/docs/API.md +204 -17
- package/docs/releases/v6.4.0.md +128 -0
- package/docs/releases/v6.5.0.md +140 -0
- package/index.d.ts +205 -2
- package/index.js +38 -0
- package/package.json +3 -1
- package/src/domain/errors/Codes.js +10 -0
- package/src/domain/services/BundleService.js +32 -3
- package/src/domain/services/RepositoryDoctor.js +97 -2
- package/src/domain/services/RootSetPersistence.js +89 -9
- package/src/domain/services/StagingWorkspace.js +530 -0
- package/src/domain/services/StagingWorkspaceRegistry.js +545 -0
- package/src/domain/services/WorkspaceDescriptorCodec.js +144 -0
- package/src/domain/value-objects/WorkspaceRef.js +151 -0
- package/src/helpers/boundedPromiseCache.js +108 -0
- package/src/infrastructure/adapters/GitPersistenceAdapter.js +58 -27
- package/src/infrastructure/adapters/GitRefAdapter.js +56 -14
- package/src/package-version.js +1 -1
- package/src/ports/GitRefPort.js +1 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# git-cas v6.4.0 Release Notes
|
|
2
|
+
|
|
3
|
+
`v6.4.0` adds a temporary reachability scope for multi-step application-storage
|
|
4
|
+
composition. Applications can build page shards, chunked assets, and structured
|
|
5
|
+
bundles without managing Git refs or paying the index and acquisition lifecycle
|
|
6
|
+
cost of using a general CacheSet as scratch storage.
|
|
7
|
+
|
|
8
|
+
## Scoped Staging Workspaces
|
|
9
|
+
|
|
10
|
+
```javascript
|
|
11
|
+
const workspace = await cas.workspaces.open({
|
|
12
|
+
namespace: 'git-warp/materializations',
|
|
13
|
+
ttlMs: 2 * 60 * 60 * 1000,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const page = await workspace.pages.put({ source: encodedShard });
|
|
18
|
+
const bundle = await workspace.bundles.putOrdered({
|
|
19
|
+
members: [['shards/page.cbor', page.handle]],
|
|
20
|
+
});
|
|
21
|
+
await workspace.checkpoint({ handles: [bundle.handle] });
|
|
22
|
+
return await workspace.promoteToCache({
|
|
23
|
+
cache,
|
|
24
|
+
key: materializationKey,
|
|
25
|
+
handle: bundle.handle,
|
|
26
|
+
});
|
|
27
|
+
} finally {
|
|
28
|
+
await workspace.release();
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Workspace capabilities mirror `assets.put()`, `assets.adopt()`, `pages.put()`,
|
|
33
|
+
`bundles.put()`, and `bundles.putOrdered()`. Each call writes through the
|
|
34
|
+
existing application-storage service and returns only after an exact workspace
|
|
35
|
+
generation directly reaches the typed result handle. Mutations serialize within
|
|
36
|
+
one workspace, so concurrent staging cannot replace rather than accumulate
|
|
37
|
+
roots.
|
|
38
|
+
|
|
39
|
+
`checkpoint()` replaces accumulated roots after an aggregate handle makes its
|
|
40
|
+
components transitively reachable. `renew()` extends the current generation's
|
|
41
|
+
lease. `release()` is idempotent and deletes only the exact observed generation;
|
|
42
|
+
symbolic refs and generation races fail closed.
|
|
43
|
+
|
|
44
|
+
## Promotion And Failure Ordering
|
|
45
|
+
|
|
46
|
+
`promoteToCache()` and `promoteToPublication()` require a handle retained by the
|
|
47
|
+
active workspace. They establish destination retention before releasing the
|
|
48
|
+
temporary root. The destination must return an anchored witness for the exact
|
|
49
|
+
handle, ref, and generation. Rejection, malformed evidence, or destination
|
|
50
|
+
failure leaves the workspace reachable and reports
|
|
51
|
+
`WORKSPACE_PROMOTION_NOT_RETAINED` where applicable. A cleanup conflict after
|
|
52
|
+
destination success reports
|
|
53
|
+
`WORKSPACE_PROMOTION_CLEANUP_PENDING`, preserving evidence that the durable
|
|
54
|
+
destination succeeded while temporary cleanup remains due.
|
|
55
|
+
|
|
56
|
+
Workspace expiry never revokes reachability automatically. Operators inspect
|
|
57
|
+
and sweep one bounded namespace explicitly:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
let cursor = null;
|
|
61
|
+
do {
|
|
62
|
+
const cleanup = await cas.workspaces.sweep({
|
|
63
|
+
namespace,
|
|
64
|
+
limit: 100,
|
|
65
|
+
cursor,
|
|
66
|
+
});
|
|
67
|
+
cursor = cleanup.nextCursor;
|
|
68
|
+
} while (cursor !== null);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Sweep removes only expired direct refs whose generation still matches the
|
|
72
|
+
inspection. Active, invalid, symbolic, and concurrently renewed workspaces are
|
|
73
|
+
not deleted. When a result is truncated, pass its opaque `nextCursor` to the
|
|
74
|
+
next bounded call so cleanup continues beyond the first page.
|
|
75
|
+
|
|
76
|
+
## Diagnostics
|
|
77
|
+
|
|
78
|
+
Workspace inspection and repository doctor report root count, creation time,
|
|
79
|
+
age, expiry, active or expired posture, and invalid persisted state. Byte
|
|
80
|
+
accounting keeps two meanings separate:
|
|
81
|
+
|
|
82
|
+
- `logicalBytes` is validated semantic content size across retained typed
|
|
83
|
+
handles;
|
|
84
|
+
- `rootObjectBytes` is the loose logical size of unique direct Git root objects.
|
|
85
|
+
|
|
86
|
+
Neither value claims packed physical residency or unique ownership across
|
|
87
|
+
deduplicated support graphs. Inspection validates target names, handles, OIDs,
|
|
88
|
+
Git types, and complete application graphs before reporting either count.
|
|
89
|
+
|
|
90
|
+
## Compatibility
|
|
91
|
+
|
|
92
|
+
This minor release is API-additive. Existing assets, pages, bundles,
|
|
93
|
+
publications, RootSets, CacheSets, ExpiringSets, Vault behavior, and stored
|
|
94
|
+
formats remain unchanged. `RepositoryDoctor` keeps its workspace collaborator
|
|
95
|
+
optional for direct-constructor compatibility. Workspace witnesses use the
|
|
96
|
+
existing `root-set` root kind, while staged-result retention reports
|
|
97
|
+
`protection: 'workspace'`; closed retention and diagnostic discriminant unions
|
|
98
|
+
remain unchanged for exhaustive TypeScript consumers.
|
|
99
|
+
|
|
100
|
+
Like all Git-backed composition, the interval between writing a new object and
|
|
101
|
+
publishing the workspace ref depends on Git's ordinary unreachable-object grace
|
|
102
|
+
period. Immediate-expiry prune running concurrently inside that interval is not
|
|
103
|
+
supported.
|
|
104
|
+
|
|
105
|
+
## Verification
|
|
106
|
+
|
|
107
|
+
Unit coverage proves exact-generation retention, concurrent staging,
|
|
108
|
+
checkpoint compaction, renewal-versus-sweep races, destination-first promotion,
|
|
109
|
+
idempotent release, canonical descriptors and refs, date-range bounds,
|
|
110
|
+
corruption detection, byte accounting, facade wiring, declarations, and doctor
|
|
111
|
+
inventory. Real-Git integration runs `git prune --expire=now` after returned
|
|
112
|
+
operations and proves survival through page, asset, and bundle composition,
|
|
113
|
+
promotion, expiry, sweep, and release.
|
|
114
|
+
|
|
115
|
+
The final release-candidate verifier passed 14/14 steps with 6,538 observed
|
|
116
|
+
tests: 1,993 Node unit tests, 1,992 Bun unit tests, 1,983 Deno unit tests, and
|
|
117
|
+
190 integration tests on each runtime. npm pack and JSR publish dry-runs also
|
|
118
|
+
passed. Twenty repeated real-Git ExpiringSet runs verify that concurrent
|
|
119
|
+
duplicate-writer behavior remains stable after the RootSet retry correction.
|
|
120
|
+
|
|
121
|
+
The unchanged downstream `git-warp` ten-second integration hook remains the
|
|
122
|
+
release adoption gate after package publication. CI, self-review, Code Rabbit,
|
|
123
|
+
and independent Code Lawyer review remain mandatory before tagging.
|
|
124
|
+
|
|
125
|
+
See [Scoped Staging Workspaces](../API.md#scoped-staging-workspaces) for the
|
|
126
|
+
complete API contract and
|
|
127
|
+
[PERF-0049](https://github.com/git-stunts/git-cas/blob/main/docs/design/0049-scoped-staging-workspaces/scoped-staging-workspaces.md)
|
|
128
|
+
for the design and proof obligations.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# git-cas v6.5.0 Release Notes
|
|
2
|
+
|
|
3
|
+
v6.5.0 adds bounded direct bundle-reference reads for applications that need to
|
|
4
|
+
locate or enumerate retained materialization handles without recursively
|
|
5
|
+
hydrating every referenced support graph. It also adds bounded reuse for
|
|
6
|
+
immutable Git metadata and bundle descriptors, and repairs two concurrency
|
|
7
|
+
edge cases found while proving the new path under stress.
|
|
8
|
+
|
|
9
|
+
This release is API-additive. It does not change persisted bundle formats and
|
|
10
|
+
does not require stored-data migration.
|
|
11
|
+
|
|
12
|
+
## Direct Bundle References
|
|
13
|
+
|
|
14
|
+
Read one exact member descriptor without opening its payload or recursively
|
|
15
|
+
resolving the member's complete support graph:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
const reference = await cas.bundles.getMemberReference({
|
|
19
|
+
handle: materializationBundle,
|
|
20
|
+
path: 'nodes/user-alice.cbor',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (reference) {
|
|
24
|
+
console.log(reference.handle);
|
|
25
|
+
console.log(reference.type);
|
|
26
|
+
console.log(reference.size);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Stream canonical member descriptors without collecting the whole bundle:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
for await (const reference of cas.bundles.iterateMemberReferences({
|
|
34
|
+
handle: materializationBundle,
|
|
35
|
+
})) {
|
|
36
|
+
await indexReference(reference);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Each `BundleMemberReference` contains:
|
|
41
|
+
|
|
42
|
+
- `version: 1`;
|
|
43
|
+
- the canonical member `path`;
|
|
44
|
+
- the typed application `handle`;
|
|
45
|
+
- the direct Git object `type`; and
|
|
46
|
+
- the declared byte `size`, or `null` for structured tree members.
|
|
47
|
+
|
|
48
|
+
The existing `getMember()` and `iterateMembers()` APIs retain complete recursive
|
|
49
|
+
validation semantics and include computed `logicalBytes`.
|
|
50
|
+
|
|
51
|
+
## Integrity Boundary
|
|
52
|
+
|
|
53
|
+
The direct path validates:
|
|
54
|
+
|
|
55
|
+
- the bundle handle codec and root tree type;
|
|
56
|
+
- the root descriptor and persisted read limits;
|
|
57
|
+
- every descriptor and summary along the selected path, or across the streamed
|
|
58
|
+
structural traversal;
|
|
59
|
+
- every traversed fanout tree edge;
|
|
60
|
+
- the selected or enumerated leaf edge; and
|
|
61
|
+
- each direct target Git object type.
|
|
62
|
+
|
|
63
|
+
It does not recursively validate a selected page, asset, or nested bundle's
|
|
64
|
+
complete support graph. Callers that require that stronger proof must continue
|
|
65
|
+
to use `getMember()` or `iterateMembers()`.
|
|
66
|
+
|
|
67
|
+
A reference is also not a retention witness. The containing bundle must remain
|
|
68
|
+
reachable through a workspace, RootSet, cache acquisition, publication, or
|
|
69
|
+
other documented lifetime while the reference is consumed.
|
|
70
|
+
|
|
71
|
+
## Bounded Immutable Reuse
|
|
72
|
+
|
|
73
|
+
Repeated exact tree-entry and object-info reads now share successful in-flight
|
|
74
|
+
and completed work inside each Git persistence adapter. The default metadata
|
|
75
|
+
cache retains at most 2,048 immutable entries and can be lowered with the
|
|
76
|
+
`metadataCacheEntries` constructor option.
|
|
77
|
+
|
|
78
|
+
Bundle descriptors use a separate cache bounded by both 1,024 entries and 16
|
|
79
|
+
MiB. Returned byte arrays and mutable metadata records are copied for callers.
|
|
80
|
+
Rejected work removes itself so a later read can retry. Values larger than the
|
|
81
|
+
descriptor byte budget are returned to the current caller but are not retained
|
|
82
|
+
and do not evict unrelated residents.
|
|
83
|
+
|
|
84
|
+
These caches contain immutable Git metadata and structural descriptors only.
|
|
85
|
+
They do not retain application payload bytes, mutable refs, cache indexes, or
|
|
86
|
+
root-set state.
|
|
87
|
+
|
|
88
|
+
## Concurrency Repairs
|
|
89
|
+
|
|
90
|
+
The RootSet compare-and-swap classifier now recovers exact failed
|
|
91
|
+
`git update-ref --no-deref` races when Git exits fatally without diagnostic
|
|
92
|
+
text, provided an independent ref read proves that the managed head advanced.
|
|
93
|
+
OID comparisons use canonical lowercase values, avoiding false conflicts from
|
|
94
|
+
case-only differences. A checked-in real-Git diagnostic passed 500/500
|
|
95
|
+
two-writer replacement races after the repair.
|
|
96
|
+
|
|
97
|
+
The bounded promise cache now removes rejected work before the returned promise
|
|
98
|
+
settles, preserving immediate retry semantics. Individually oversized resolved
|
|
99
|
+
values are discarded before weight-based eviction runs, preserving unrelated
|
|
100
|
+
residents.
|
|
101
|
+
|
|
102
|
+
## Performance Evidence
|
|
103
|
+
|
|
104
|
+
The stable regression contract counts real Git commands rather than asserting
|
|
105
|
+
portable wall-clock latency:
|
|
106
|
+
|
|
107
|
+
- a cold direct read must perform metadata work;
|
|
108
|
+
- an identical warm direct read must perform zero additional Git metadata
|
|
109
|
+
commands; and
|
|
110
|
+
- direct reference iteration must issue fewer total and object-inspection
|
|
111
|
+
commands than complete recursive validation.
|
|
112
|
+
|
|
113
|
+
On the recorded four-node git-warp fixture, the final direct-reference and
|
|
114
|
+
descriptor-cache path reduced one selected read from 192 Git commands to 69,
|
|
115
|
+
approximately 64 percent. The same host sample reduced the observed wall time
|
|
116
|
+
from approximately 3-5 seconds to 1.291 seconds. These timings are diagnostic,
|
|
117
|
+
not cross-machine promises; command-count integration is the merge gate.
|
|
118
|
+
|
|
119
|
+
## Verification
|
|
120
|
+
|
|
121
|
+
The final release candidate passed 14/14 verifier steps with 6,625 observed
|
|
122
|
+
tests:
|
|
123
|
+
|
|
124
|
+
- Node.js: 2,020 unit tests and 192 real-Git integration tests;
|
|
125
|
+
- Bun: 2,019 unit tests and 192 real-Git integration tests; and
|
|
126
|
+
- Deno: 2,010 unit tests and 192 real-Git integration tests.
|
|
127
|
+
|
|
128
|
+
The verifier also passed lint, examples, public type compatibility, build
|
|
129
|
+
stamping, npm package inspection, and the JSR publish dry-run. The checked-in
|
|
130
|
+
RootSet race diagnostic passed 500/500 two-writer replacement races.
|
|
131
|
+
|
|
132
|
+
## Upgrade Notes
|
|
133
|
+
|
|
134
|
+
No stored-data migration is required. Existing complete-validation calls keep
|
|
135
|
+
their behavior. Applications may adopt the new reference APIs selectively where
|
|
136
|
+
their own retained lifetime already guarantees that recursive support remains
|
|
137
|
+
available.
|
|
138
|
+
|
|
139
|
+
See [UPGRADING.md](../../UPGRADING.md) for the adoption decision and
|
|
140
|
+
[Application Storage](../API.md#application-storage) for the full API contract.
|
package/index.d.ts
CHANGED
|
@@ -556,13 +556,19 @@ export declare class GitRefPortBase {
|
|
|
556
556
|
deleteRef?(options: { ref: string; expectedOldOid: string }): Promise<boolean>;
|
|
557
557
|
iterateRefs?(options: {
|
|
558
558
|
prefix?: string;
|
|
559
|
+
/** Exclusive opaque continuation returned by a previous bounded inventory. */
|
|
560
|
+
after?: string | null;
|
|
559
561
|
limit: number;
|
|
560
562
|
}): AsyncIterable<{ ref: string; oid: string; symref: string | null }>;
|
|
561
563
|
}
|
|
562
564
|
|
|
563
565
|
/** Git-backed implementation of the persistence port. */
|
|
564
566
|
export declare class GitPersistenceAdapter extends GitPersistencePortBase {
|
|
565
|
-
constructor(options: {
|
|
567
|
+
constructor(options: {
|
|
568
|
+
plumbing: unknown;
|
|
569
|
+
policy?: unknown;
|
|
570
|
+
metadataCacheEntries?: number;
|
|
571
|
+
});
|
|
566
572
|
setMaxBlobSize(maxBlobSize: number): void;
|
|
567
573
|
}
|
|
568
574
|
|
|
@@ -577,6 +583,8 @@ export declare class GitRefAdapter extends GitRefPortBase {
|
|
|
577
583
|
deleteRef(options: { ref: string; expectedOldOid: string }): Promise<boolean>;
|
|
578
584
|
iterateRefs(options: {
|
|
579
585
|
prefix?: string;
|
|
586
|
+
/** Exclusive opaque continuation returned by a previous bounded inventory. */
|
|
587
|
+
after?: string | null;
|
|
580
588
|
limit: number;
|
|
581
589
|
}): AsyncIterable<{ ref: string; oid: string; symref: string | null }>;
|
|
582
590
|
}
|
|
@@ -1241,6 +1249,32 @@ export interface RepositoryExpiringSetUsage {
|
|
|
1241
1249
|
readonly issues: ReadonlyArray<Record<string, unknown>>;
|
|
1242
1250
|
}
|
|
1243
1251
|
|
|
1252
|
+
export interface RepositoryWorkspaceUsage {
|
|
1253
|
+
readonly namespace: string | null;
|
|
1254
|
+
readonly ref: string;
|
|
1255
|
+
readonly generation: string;
|
|
1256
|
+
readonly healthy: boolean;
|
|
1257
|
+
readonly entryCount: number | null;
|
|
1258
|
+
readonly logicalBytes: number | null;
|
|
1259
|
+
/** Sum of unique direct Git root object sizes; excludes transitive support and pack overhead. */
|
|
1260
|
+
readonly rootObjectBytes: number | null;
|
|
1261
|
+
readonly physicalBytes: null;
|
|
1262
|
+
readonly retention: {
|
|
1263
|
+
readonly pinnedEntries: 0;
|
|
1264
|
+
readonly evictableEntries: number;
|
|
1265
|
+
} | null;
|
|
1266
|
+
readonly reachability: 'anchored';
|
|
1267
|
+
readonly age: {
|
|
1268
|
+
readonly createdAt: string | null;
|
|
1269
|
+
readonly ageMs: number | null;
|
|
1270
|
+
} | null;
|
|
1271
|
+
readonly expiry: {
|
|
1272
|
+
readonly expiresAt: string | null;
|
|
1273
|
+
readonly posture: 'active' | 'expired' | 'invalid';
|
|
1274
|
+
} | null;
|
|
1275
|
+
readonly issues: ReadonlyArray<Record<string, unknown>>;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1244
1278
|
export interface RepositoryVaultUsage {
|
|
1245
1279
|
readonly ref: string;
|
|
1246
1280
|
readonly present: boolean;
|
|
@@ -1321,6 +1355,18 @@ export interface RepositoryDoctorReport {
|
|
|
1321
1355
|
};
|
|
1322
1356
|
readonly entries: ReadonlyArray<RepositoryExpiringSetUsage>;
|
|
1323
1357
|
};
|
|
1358
|
+
readonly workspaces: {
|
|
1359
|
+
readonly healthy: boolean;
|
|
1360
|
+
readonly coverage: RepositoryCollectionCoverage;
|
|
1361
|
+
readonly totals: {
|
|
1362
|
+
readonly entryCount: number | null;
|
|
1363
|
+
readonly logicalBytes: number | null;
|
|
1364
|
+
readonly rootObjectBytes: number | null;
|
|
1365
|
+
readonly activeWorkspaces: number | null;
|
|
1366
|
+
readonly expiredWorkspaces: number | null;
|
|
1367
|
+
};
|
|
1368
|
+
readonly entries: ReadonlyArray<RepositoryWorkspaceUsage>;
|
|
1369
|
+
};
|
|
1324
1370
|
readonly vault: RepositoryVaultUsage;
|
|
1325
1371
|
};
|
|
1326
1372
|
readonly limitations: ReadonlyArray<RepositoryDiagnosticLimitation>;
|
|
@@ -1335,6 +1381,14 @@ export declare class RepositoryDoctor {
|
|
|
1335
1381
|
expiringSets: {
|
|
1336
1382
|
open(options: { namespace: string }): ExpiringSet | Promise<ExpiringSet>;
|
|
1337
1383
|
};
|
|
1384
|
+
/** Optional only for backwards-compatible direct construction; workspace refs report unhealthy when absent. */
|
|
1385
|
+
workspaces?: {
|
|
1386
|
+
inspectRecord(record: {
|
|
1387
|
+
ref: string;
|
|
1388
|
+
oid: string;
|
|
1389
|
+
symref: string | null;
|
|
1390
|
+
}): Promise<WorkspaceInspectionRecord>;
|
|
1391
|
+
};
|
|
1338
1392
|
vault: Pick<VaultService, 'getVaultMetadata' | 'readState'>;
|
|
1339
1393
|
clock?: { now(): Date };
|
|
1340
1394
|
});
|
|
@@ -1406,12 +1460,15 @@ export type BundleMemberInput =
|
|
|
1406
1460
|
| PageSource
|
|
1407
1461
|
| { source: PageSource; maxBytes?: number };
|
|
1408
1462
|
|
|
1409
|
-
export interface
|
|
1463
|
+
export interface BundleMemberReference {
|
|
1410
1464
|
readonly version: 1;
|
|
1411
1465
|
readonly path: string;
|
|
1412
1466
|
readonly handle: ApplicationHandle;
|
|
1413
1467
|
readonly type: 'blob' | 'tree';
|
|
1414
1468
|
readonly size: number | null;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
export interface BundleMember extends BundleMemberReference {
|
|
1415
1472
|
readonly logicalBytes: number;
|
|
1416
1473
|
}
|
|
1417
1474
|
|
|
@@ -1433,6 +1490,11 @@ export interface BundleCapability {
|
|
|
1433
1490
|
handle: BundleHandleInput;
|
|
1434
1491
|
path: string;
|
|
1435
1492
|
}): Promise<BundleMember | null>;
|
|
1493
|
+
getMemberReference(options: {
|
|
1494
|
+
handle: BundleHandleInput;
|
|
1495
|
+
path: string;
|
|
1496
|
+
}): Promise<BundleMemberReference | null>;
|
|
1497
|
+
iterateMemberReferences(options: { handle: BundleHandleInput }): AsyncIterable<BundleMemberReference>;
|
|
1436
1498
|
iterateMembers(options: { handle: BundleHandleInput }): AsyncIterable<BundleMember>;
|
|
1437
1499
|
openMember(options: { handle: BundleHandleInput; path: string }): AsyncIterable<Uint8Array>;
|
|
1438
1500
|
}
|
|
@@ -1452,6 +1514,146 @@ export interface ExpiringSetCapability {
|
|
|
1452
1514
|
}): Promise<ExpiringSet>;
|
|
1453
1515
|
}
|
|
1454
1516
|
|
|
1517
|
+
export interface WorkspaceRetention {
|
|
1518
|
+
readonly policy: 'evictable';
|
|
1519
|
+
readonly reachability: 'anchored';
|
|
1520
|
+
readonly protection: 'workspace';
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
export type WorkspaceRetainedData<T> = Omit<T, 'state' | 'retention'> & {
|
|
1524
|
+
state: 'retained';
|
|
1525
|
+
retention: WorkspaceRetention;
|
|
1526
|
+
witness: RetentionWitnessData;
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1529
|
+
export type WorkspaceRetainedAsset = Omit<StagedAsset, 'state' | 'retention' | 'toJSON'> & {
|
|
1530
|
+
readonly state: 'retained';
|
|
1531
|
+
readonly retention: WorkspaceRetention;
|
|
1532
|
+
readonly witness: RetentionWitness;
|
|
1533
|
+
toJSON(): WorkspaceRetainedData<StagedAssetData>;
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
export type WorkspaceRetainedPage = Omit<StagedPage, 'state' | 'retention' | 'toJSON'> & {
|
|
1537
|
+
readonly state: 'retained';
|
|
1538
|
+
readonly retention: WorkspaceRetention;
|
|
1539
|
+
readonly witness: RetentionWitness;
|
|
1540
|
+
toJSON(): WorkspaceRetainedData<StagedPageData>;
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
export type WorkspaceRetainedBundle = Omit<StagedBundle, 'state' | 'retention' | 'toJSON'> & {
|
|
1544
|
+
readonly state: 'retained';
|
|
1545
|
+
readonly retention: WorkspaceRetention;
|
|
1546
|
+
readonly witness: RetentionWitness;
|
|
1547
|
+
toJSON(): WorkspaceRetainedData<StagedBundleData>;
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
export interface WorkspaceCheckpointResult {
|
|
1551
|
+
readonly changed: boolean;
|
|
1552
|
+
readonly ref: string;
|
|
1553
|
+
readonly generation: string;
|
|
1554
|
+
readonly expiresAt: string;
|
|
1555
|
+
readonly handles: ReadonlyArray<ApplicationHandle>;
|
|
1556
|
+
readonly witnesses: ReadonlyArray<RetentionWitness>;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
export interface WorkspaceReleaseResult {
|
|
1560
|
+
readonly changed: boolean;
|
|
1561
|
+
readonly ref: string;
|
|
1562
|
+
readonly generation: string | null;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
export interface WorkspaceInspectionRecord {
|
|
1566
|
+
readonly id: string | null;
|
|
1567
|
+
readonly namespace: string | null;
|
|
1568
|
+
readonly ref: string;
|
|
1569
|
+
readonly generation: string;
|
|
1570
|
+
readonly symref: string | null;
|
|
1571
|
+
readonly rootCount: number | null;
|
|
1572
|
+
readonly logicalBytes: number | null;
|
|
1573
|
+
/** Sum of unique direct Git root object sizes; excludes transitive support and pack overhead. */
|
|
1574
|
+
readonly rootObjectBytes: number | null;
|
|
1575
|
+
readonly createdAt: string | null;
|
|
1576
|
+
readonly ageMs: number | null;
|
|
1577
|
+
readonly expiresAt: string | null;
|
|
1578
|
+
readonly posture: 'active' | 'expired' | 'invalid';
|
|
1579
|
+
readonly issue: Readonly<{ code: string; message: string }> | null;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
export interface WorkspaceInspection {
|
|
1583
|
+
readonly namespace: string;
|
|
1584
|
+
readonly returned: number;
|
|
1585
|
+
readonly truncated: boolean;
|
|
1586
|
+
/** Opaque continuation for the next bounded inspect or sweep call. */
|
|
1587
|
+
readonly nextCursor: string | null;
|
|
1588
|
+
readonly workspaces: ReadonlyArray<WorkspaceInspectionRecord>;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
export interface WorkspaceSweepResult {
|
|
1592
|
+
readonly namespace: string;
|
|
1593
|
+
readonly inspected: number;
|
|
1594
|
+
readonly changed: number;
|
|
1595
|
+
readonly conflicted: number;
|
|
1596
|
+
readonly missing: number;
|
|
1597
|
+
readonly truncated: boolean;
|
|
1598
|
+
/** Opaque continuation for the next bounded sweep call. */
|
|
1599
|
+
readonly nextCursor: string | null;
|
|
1600
|
+
readonly results: ReadonlyArray<Readonly<{
|
|
1601
|
+
id: string | null;
|
|
1602
|
+
ref: string;
|
|
1603
|
+
generation: string;
|
|
1604
|
+
changed: boolean;
|
|
1605
|
+
conflict: boolean;
|
|
1606
|
+
}>>;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
/** One renewable, RootSet-backed scope for multi-object staging. */
|
|
1610
|
+
export declare class StagingWorkspace {
|
|
1611
|
+
private constructor();
|
|
1612
|
+
readonly id: string;
|
|
1613
|
+
readonly namespace: string;
|
|
1614
|
+
readonly createdAt: string;
|
|
1615
|
+
readonly expiresAt: string | null;
|
|
1616
|
+
readonly assets: {
|
|
1617
|
+
put(options: AssetPutOptions): Promise<WorkspaceRetainedAsset>;
|
|
1618
|
+
adopt(options: { treeOid: string }): Promise<WorkspaceRetainedAsset>;
|
|
1619
|
+
};
|
|
1620
|
+
readonly pages: {
|
|
1621
|
+
put(options: { source: PageSource; maxBytes?: number }): Promise<WorkspaceRetainedPage>;
|
|
1622
|
+
};
|
|
1623
|
+
readonly bundles: {
|
|
1624
|
+
put(options: Parameters<BundleCapability['put']>[0]): Promise<WorkspaceRetainedBundle>;
|
|
1625
|
+
putOrdered(options: Parameters<BundleCapability['putOrdered']>[0]): Promise<WorkspaceRetainedBundle>;
|
|
1626
|
+
};
|
|
1627
|
+
checkpoint(options: { handles: Iterable<ApplicationHandleInput> }): Promise<WorkspaceCheckpointResult>;
|
|
1628
|
+
renew(): Promise<WorkspaceCheckpointResult>;
|
|
1629
|
+
promoteToCache(options: {
|
|
1630
|
+
cache: CacheSet;
|
|
1631
|
+
key: string;
|
|
1632
|
+
handle: ApplicationHandleInput;
|
|
1633
|
+
options?: CacheEntryOptions;
|
|
1634
|
+
}): Promise<Readonly<{ destination: CacheStoreResult; release: WorkspaceReleaseResult }>>;
|
|
1635
|
+
promoteToPublication(options: {
|
|
1636
|
+
handle: ApplicationHandleInput;
|
|
1637
|
+
commit: { message: string; parents?: string[] };
|
|
1638
|
+
ref: { name: string; expected: string | null };
|
|
1639
|
+
}): Promise<Readonly<{ destination: PublicationResult; release: WorkspaceReleaseResult }>>;
|
|
1640
|
+
release(): Promise<WorkspaceReleaseResult>;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
export interface WorkspaceCapability {
|
|
1644
|
+
open(options: { namespace: string; ttlMs?: number }): Promise<StagingWorkspace>;
|
|
1645
|
+
inspect(options: {
|
|
1646
|
+
namespace: string;
|
|
1647
|
+
limit?: number;
|
|
1648
|
+
cursor?: string | null;
|
|
1649
|
+
}): Promise<WorkspaceInspection>;
|
|
1650
|
+
sweep(options: {
|
|
1651
|
+
namespace: string;
|
|
1652
|
+
limit?: number;
|
|
1653
|
+
cursor?: string | null;
|
|
1654
|
+
}): Promise<WorkspaceSweepResult>;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1455
1657
|
export interface DiagnosticsCapability {
|
|
1456
1658
|
doctor(options?: RepositoryDoctorOptions): Promise<RepositoryDoctorReport>;
|
|
1457
1659
|
}
|
|
@@ -1505,6 +1707,7 @@ export default class ContentAddressableStore {
|
|
|
1505
1707
|
|
|
1506
1708
|
readonly caches: CacheCapability;
|
|
1507
1709
|
readonly expiringSets: ExpiringSetCapability;
|
|
1710
|
+
readonly workspaces: WorkspaceCapability;
|
|
1508
1711
|
readonly diagnostics: DiagnosticsCapability;
|
|
1509
1712
|
|
|
1510
1713
|
readonly assets: AssetCapability;
|
package/index.js
CHANGED
|
@@ -16,6 +16,8 @@ import CacheSet from './src/domain/services/CacheSet.js';
|
|
|
16
16
|
import CacheSetRegistry from './src/domain/services/CacheSetRegistry.js';
|
|
17
17
|
import ExpiringSet from './src/domain/services/ExpiringSet.js';
|
|
18
18
|
import ExpiringSetRegistry from './src/domain/services/ExpiringSetRegistry.js';
|
|
19
|
+
import StagingWorkspace from './src/domain/services/StagingWorkspace.js';
|
|
20
|
+
import StagingWorkspaceRegistry from './src/domain/services/StagingWorkspaceRegistry.js';
|
|
19
21
|
import RepositoryDoctor from './src/domain/services/RepositoryDoctor.js';
|
|
20
22
|
import PageService from './src/domain/services/PageService.js';
|
|
21
23
|
import PublicationService from './src/domain/services/PublicationService.js';
|
|
@@ -69,6 +71,7 @@ export {
|
|
|
69
71
|
RootSetRegistry,
|
|
70
72
|
CacheSet,
|
|
71
73
|
ExpiringSet,
|
|
74
|
+
StagingWorkspace,
|
|
72
75
|
RepositoryDoctor,
|
|
73
76
|
GitPersistenceAdapter,
|
|
74
77
|
GitRefAdapter,
|
|
@@ -191,6 +194,11 @@ export default class ContentAddressableStore {
|
|
|
191
194
|
this.expiringSets = Object.freeze({
|
|
192
195
|
open: async (options) => (await this.#getExpiringSetRegistry()).open(options),
|
|
193
196
|
});
|
|
197
|
+
this.workspaces = Object.freeze({
|
|
198
|
+
open: async (options) => (await this.#getStagingWorkspaceRegistry()).open(options),
|
|
199
|
+
inspect: async (options) => (await this.#getStagingWorkspaceRegistry()).inspect(options),
|
|
200
|
+
sweep: async (options) => (await this.#getStagingWorkspaceRegistry()).sweep(options),
|
|
201
|
+
});
|
|
194
202
|
this.diagnostics = Object.freeze({
|
|
195
203
|
doctor: async (options) => (await this.#getRepositoryDoctor()).doctor(options),
|
|
196
204
|
});
|
|
@@ -208,7 +216,11 @@ export default class ContentAddressableStore {
|
|
|
208
216
|
put: async (options) => (await this.#getBundleService()).put(options),
|
|
209
217
|
putOrdered: async (options) => (await this.#getBundleService()).putOrdered(options),
|
|
210
218
|
getMember: async (options) => (await this.#getBundleService()).getMember(options),
|
|
219
|
+
getMemberReference: async (options) => (
|
|
220
|
+
await this.#getBundleService()
|
|
221
|
+
).getMemberReference(options),
|
|
211
222
|
iterateMembers: (options) => this.#iterateBundleMembers(options),
|
|
223
|
+
iterateMemberReferences: (options) => this.#iterateBundleMemberReferences(options),
|
|
212
224
|
openMember: (options) => this.#openBundleMember(options),
|
|
213
225
|
});
|
|
214
226
|
this.retention = Object.freeze({
|
|
@@ -239,6 +251,8 @@ export default class ContentAddressableStore {
|
|
|
239
251
|
#cacheSetRegistry = null;
|
|
240
252
|
/** @type {ExpiringSetRegistry|null} */
|
|
241
253
|
#expiringSetRegistry = null;
|
|
254
|
+
/** @type {StagingWorkspaceRegistry|null} */
|
|
255
|
+
#stagingWorkspaceRegistry = null;
|
|
242
256
|
/** @type {RepositoryDoctor|null} */
|
|
243
257
|
#repositoryDoctor = null;
|
|
244
258
|
#servicePromise = null;
|
|
@@ -313,6 +327,7 @@ export default class ContentAddressableStore {
|
|
|
313
327
|
rootSets: this.#rootSetRegistry,
|
|
314
328
|
caches: this.#cacheSetRegistry,
|
|
315
329
|
expiringSets: this.#expiringSetRegistry,
|
|
330
|
+
workspaces: this.#stagingWorkspaceRegistry,
|
|
316
331
|
vault: this.#vault,
|
|
317
332
|
clock: cfg.clock,
|
|
318
333
|
});
|
|
@@ -336,6 +351,17 @@ export default class ContentAddressableStore {
|
|
|
336
351
|
crypto,
|
|
337
352
|
clock: cfg.clock,
|
|
338
353
|
});
|
|
354
|
+
this.#stagingWorkspaceRegistry = new StagingWorkspaceRegistry({
|
|
355
|
+
persistence,
|
|
356
|
+
ref,
|
|
357
|
+
assets: this.#assetService,
|
|
358
|
+
pages: this.#pageService,
|
|
359
|
+
bundles: this.#bundleService,
|
|
360
|
+
publications: this.#publicationService,
|
|
361
|
+
resolveHandle: (handle) => this.#resolveApplicationRoot(handle),
|
|
362
|
+
crypto,
|
|
363
|
+
clock: cfg.clock,
|
|
364
|
+
});
|
|
339
365
|
}
|
|
340
366
|
|
|
341
367
|
#initApplicationServices({ ref, cfg }) {
|
|
@@ -401,6 +427,12 @@ export default class ContentAddressableStore {
|
|
|
401
427
|
return this.#expiringSetRegistry;
|
|
402
428
|
}
|
|
403
429
|
|
|
430
|
+
/** @returns {Promise<StagingWorkspaceRegistry>} */
|
|
431
|
+
async #getStagingWorkspaceRegistry() {
|
|
432
|
+
await this.#getService();
|
|
433
|
+
return this.#stagingWorkspaceRegistry;
|
|
434
|
+
}
|
|
435
|
+
|
|
404
436
|
/** @returns {Promise<RepositoryDoctor>} */
|
|
405
437
|
async #getRepositoryDoctor() {
|
|
406
438
|
await this.#getService();
|
|
@@ -458,6 +490,12 @@ export default class ContentAddressableStore {
|
|
|
458
490
|
yield* bundles.openMember(options);
|
|
459
491
|
}
|
|
460
492
|
|
|
493
|
+
/** @returns {AsyncIterable<object>} */
|
|
494
|
+
async *#iterateBundleMemberReferences(options) {
|
|
495
|
+
const bundles = await this.#getBundleService();
|
|
496
|
+
yield* bundles.iterateMemberReferences(options);
|
|
497
|
+
}
|
|
498
|
+
|
|
461
499
|
/** @returns {AsyncIterable<object>} */
|
|
462
500
|
async *#iterateBundleMembers(options) {
|
|
463
501
|
const bundles = await this.#getBundleService();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git-stunts/git-cas",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
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",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"docs/releases/v6.1.0.md",
|
|
36
36
|
"docs/releases/v6.2.0.md",
|
|
37
37
|
"docs/releases/v6.3.0.md",
|
|
38
|
+
"docs/releases/v6.4.0.md",
|
|
39
|
+
"docs/releases/v6.5.0.md",
|
|
38
40
|
"docs/THREAT_MODEL.md",
|
|
39
41
|
"docs/VAULT_INTERNALS.md",
|
|
40
42
|
"docs/WALKTHROUGH.md",
|
|
@@ -100,6 +100,16 @@ const ErrorCodes = Object.freeze({
|
|
|
100
100
|
VAULT_REF_MISSING: 'VAULT_REF_MISSING',
|
|
101
101
|
VAULT_REF_UPDATE_FAILED: 'VAULT_REF_UPDATE_FAILED',
|
|
102
102
|
VAULT_RETRY_POLICY_INVALID: 'VAULT_RETRY_POLICY_INVALID',
|
|
103
|
+
WORKSPACE_CONFLICT: 'WORKSPACE_CONFLICT',
|
|
104
|
+
WORKSPACE_DESCRIPTOR_INVALID: 'WORKSPACE_DESCRIPTOR_INVALID',
|
|
105
|
+
WORKSPACE_HANDLE_NOT_RETAINED: 'WORKSPACE_HANDLE_NOT_RETAINED',
|
|
106
|
+
WORKSPACE_PROMOTION_CLEANUP_PENDING: 'WORKSPACE_PROMOTION_CLEANUP_PENDING',
|
|
107
|
+
WORKSPACE_PROMOTION_NOT_RETAINED: 'WORKSPACE_PROMOTION_NOT_RETAINED',
|
|
108
|
+
WORKSPACE_REF_INVALID: 'WORKSPACE_REF_INVALID',
|
|
109
|
+
WORKSPACE_RELEASED: 'WORKSPACE_RELEASED',
|
|
110
|
+
WORKSPACE_RETENTION_FAILED: 'WORKSPACE_RETENTION_FAILED',
|
|
111
|
+
WORKSPACE_STATE_INVALID: 'WORKSPACE_STATE_INVALID',
|
|
112
|
+
WORKSPACE_TTL_INVALID: 'WORKSPACE_TTL_INVALID',
|
|
103
113
|
});
|
|
104
114
|
|
|
105
115
|
export { ErrorCodes };
|