@git-stunts/git-cas 6.2.0 → 6.4.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.
@@ -0,0 +1,96 @@
1
+ # git-cas v6.3.0 Release Notes
2
+
3
+ `v6.3.0` closes the lifetime gap between observing a CacheSet hit and consuming
4
+ its handle. Applications can now retain a bounded cache hit for exactly one
5
+ explicit scope without learning Git refs or recursively validating a large
6
+ target graph during lookup.
7
+
8
+ ## Scoped Cache Acquisitions
9
+
10
+ ```javascript
11
+ const acquisition = await cache.acquire(materializationKey);
12
+ if (acquisition) {
13
+ try {
14
+ await consume(acquisition.hit.handle);
15
+ } finally {
16
+ await acquisition.release();
17
+ }
18
+ }
19
+ ```
20
+
21
+ `acquire()` reads only the cache index path needed for the requested key. An
22
+ atomic Git ref transaction verifies the observed cache generation and creates a
23
+ unique acquisition ref that anchors that generation. Replacement, expiry,
24
+ capacity eviction, or explicit removal may then publish a newer cache
25
+ generation without making the acquired target collectible during use.
26
+
27
+ The returned `CacheAcquisition` contains:
28
+
29
+ - the immutable `CacheHit` observation;
30
+ - separate pinned `RetentionWitness` evidence for the active acquisition;
31
+ - an opaque acquisition ID and canonical acquisition time;
32
+ - an idempotent, generation-checked `release()` operation.
33
+
34
+ An acquisition retains the selected cache generation, not only one target.
35
+ Callers must release it in `finally`. The API intentionally supplies no
36
+ automatic TTL because age cannot prove that an active consumer is dead.
37
+
38
+ ## Operations And Diagnostics
39
+
40
+ `cache.inspectAcquisitions({ limit })` reads at most `limit + 1` refs from one
41
+ exact cache namespace and reports `truncated` without disclosing original cache
42
+ keys. Recovery tooling releases the returned entries with
43
+ `cache.releaseAcquisition({ id, expectedGeneration })`, then repeats inspection
44
+ when `truncated` is true. Cleanup refuses an unexpected generation or symbolic
45
+ ref observed at preflight. Every mutation uses no-dereference mode, so a
46
+ post-probe symbolic-ref race can affect only the managed acquisition ref name,
47
+ never its referent. Ordinary RootSet, publication, and vault ref updates now use
48
+ the same preflight and no-dereference boundary, closing a pre-existing path that
49
+ could otherwise follow a managed symbolic ref into an external referent.
50
+
51
+ `cas.diagnostics.doctor()` now reports active acquisition count, oldest and
52
+ newest acquisition timestamps, maximum age, bounded detail coverage, and
53
+ malformed acquisition refs. This exposes abandoned anchors before destructive
54
+ repository maintenance. A future-dated but structurally valid direct ref remains
55
+ healthy with `ageMs: null` and a `CACHE_ACQUISITION_CLOCK_SKEW` issue; clock
56
+ order is not treated as retention authority. Git does not enumerate dangling
57
+ symbolic refs through `for-each-ref`, so doctor cannot claim exhaustive dangling-symref inventory;
58
+ missing ref-type evidence is unhealthy, and direct mutation paths independently
59
+ preflight symbolic refs before no-dereference updates. Checked deletion gathers
60
+ ref-type evidence after a transaction conflict and then fails closed. Git 2.43
61
+ cannot atomically prove that an absent direct ref is not a dangling symbolic ref,
62
+ so recovery code must re-inspect the bounded namespace before declaring cleanup
63
+ complete.
64
+
65
+ ## Compatibility
66
+
67
+ This minor release is API-additive. Existing CacheSet `get()`, `put()`, `replace()`,
68
+ `remove()`, `sweep()`, `touch()`, doctor, repair, stored generations, and ref
69
+ stored formats remain compatible. Acquisition ref namespaces are canonical
70
+ encoded path segments, pre-existing symbolic refs are rejected, and concurrent
71
+ ref-type races cannot redirect mutations to symbolic referents. Existing custom
72
+ Git ref ports remain structurally compatible because acquisition-only
73
+ capabilities are optional until invoked. The existing `RetentionRootKind` union
74
+ is unchanged, and the new doctor acquisition group is declaration-optional for
75
+ structural compatibility. The existing diagnostic limitation `kind` union is
76
+ also unchanged; acquisition-detail truncation uses its own open string error
77
+ code. `get()` retains its existing complete target
78
+ validation semantics; applications that need a lifetime-safe, bounded hot path
79
+ should adopt `acquire()`.
80
+
81
+ ## Verification
82
+
83
+ Focused unit and real-Git integration coverage proves bounded lookup,
84
+ generation-race retry, explicit and checked release, doctor inventory, and
85
+ survival across `git prune --expire=now`, namespace isolation, symbolic-ref
86
+ authority safety, work-bounded inventory, and legacy adapter type compatibility.
87
+ The release-candidate verifier passed 14/14 local gates and observed 6,325
88
+ tests across Node, Bun, and Deno. Its npm dry run contained 242 files;
89
+ the non-packaged verification witness records the exact byte receipt without
90
+ making the package describe its own compressed size. CI, self-review, Code
91
+ Rabbit, and independent Code Lawyer remain mandatory gates before tagging.
92
+
93
+ See [Scoped Cache Acquisitions](../API.md#acquire-and-release) for the complete
94
+ API contract and
95
+ [PERF-0048](https://github.com/git-stunts/git-cas/blob/main/docs/design/0048-scoped-cache-acquisitions/scoped-cache-acquisitions.md)
96
+ for the design and proof obligations.
@@ -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.
package/index.d.ts CHANGED
@@ -266,7 +266,11 @@ export declare class StagedBundle {
266
266
 
267
267
  export type RetentionPolicy = 'pinned' | 'evictable';
268
268
  export type RetentionReachability = 'anchored' | 'orphaned' | 'volatile';
269
- export type RetentionRootKind = 'root-set' | 'publication' | 'cache-set' | 'expiring-set';
269
+ export type RetentionRootKind =
270
+ | 'root-set'
271
+ | 'publication'
272
+ | 'cache-set'
273
+ | 'expiring-set';
270
274
 
271
275
  export interface RetentionRoot {
272
276
  kind: RetentionRootKind;
@@ -358,6 +362,35 @@ export declare class CacheHit {
358
362
  toJSON(): CacheHitData;
359
363
  }
360
364
 
365
+ export interface CacheAcquisitionRelease {
366
+ readonly id: string;
367
+ readonly generation: string;
368
+ readonly changed: boolean;
369
+ readonly releasedAt: string;
370
+ }
371
+
372
+ /** Active, explicitly releasable retention scope for one cache hit. */
373
+ export interface CacheAcquisition {
374
+ readonly id: string;
375
+ readonly hit: CacheHit;
376
+ readonly evidence: RetentionWitness;
377
+ readonly acquiredAt: string;
378
+ release(): Promise<CacheAcquisitionRelease>;
379
+ }
380
+
381
+ export interface CacheAcquisitionInspectionEntry {
382
+ readonly id: string;
383
+ readonly generation: string;
384
+ readonly acquiredAt: string;
385
+ readonly keyDigest: string;
386
+ }
387
+
388
+ export interface CacheAcquisitionInspection {
389
+ readonly namespace: string;
390
+ readonly entries: ReadonlyArray<CacheAcquisitionInspectionEntry>;
391
+ readonly truncated: boolean;
392
+ }
393
+
361
394
  export interface ExpiringMarkerData {
362
395
  version: 1;
363
396
  keyDigest: string;
@@ -515,6 +548,18 @@ export declare class GitRefPortBase {
515
548
  /** Expected current OID for CAS; null means the ref must not exist. */
516
549
  expectedOldOid?: string | null;
517
550
  }): Promise<void>;
551
+ anchorRef?(options: {
552
+ sourceRef: string;
553
+ expectedSourceOid: string;
554
+ targetRef: string;
555
+ }): Promise<boolean>;
556
+ deleteRef?(options: { ref: string; expectedOldOid: string }): Promise<boolean>;
557
+ iterateRefs?(options: {
558
+ prefix?: string;
559
+ /** Exclusive opaque continuation returned by a previous bounded inventory. */
560
+ after?: string | null;
561
+ limit: number;
562
+ }): AsyncIterable<{ ref: string; oid: string; symref: string | null }>;
518
563
  }
519
564
 
520
565
  /** Git-backed implementation of the persistence port. */
@@ -526,6 +571,18 @@ export declare class GitPersistenceAdapter extends GitPersistencePortBase {
526
571
  /** Git-backed implementation of the ref port. */
527
572
  export declare class GitRefAdapter extends GitRefPortBase {
528
573
  constructor(options: { plumbing: unknown; policy?: unknown });
574
+ anchorRef(options: {
575
+ sourceRef: string;
576
+ expectedSourceOid: string;
577
+ targetRef: string;
578
+ }): Promise<boolean>;
579
+ deleteRef(options: { ref: string; expectedOldOid: string }): Promise<boolean>;
580
+ iterateRefs(options: {
581
+ prefix?: string;
582
+ /** Exclusive opaque continuation returned by a previous bounded inventory. */
583
+ after?: string | null;
584
+ limit: number;
585
+ }): AsyncIterable<{ ref: string; oid: string; symref: string | null }>;
529
586
  }
530
587
 
531
588
  export type RepositoryObjectType = 'blob' | 'tree' | 'commit' | 'tag';
@@ -537,6 +594,13 @@ export interface RepositoryObjectRecord {
537
594
  readonly physicalBytes: number;
538
595
  }
539
596
 
597
+ export interface RepositoryRefRecord {
598
+ readonly ref: string;
599
+ readonly oid: string;
600
+ /** Present when the inspection adapter can distinguish symbolic refs. */
601
+ readonly symref?: string | null;
602
+ }
603
+
540
604
  /** Abstract non-mutating repository inspection port. */
541
605
  export declare class RepositoryInspectionPort {
542
606
  iterateObjects(): AsyncIterable<RepositoryObjectRecord>;
@@ -544,7 +608,9 @@ export declare class RepositoryInspectionPort {
544
608
  iteratePrunableObjects(options: {
545
609
  expiresBefore: string;
546
610
  }): AsyncIterable<Pick<RepositoryObjectRecord, 'oid' | 'type'>>;
547
- iterateRefs(): AsyncIterable<{ readonly ref: string; readonly oid: string }>;
611
+ iterateRefs(options?: {
612
+ prefix?: string;
613
+ }): AsyncIterable<RepositoryRefRecord>;
548
614
  reachablePhysicalBytes(): Promise<number>;
549
615
  }
550
616
 
@@ -834,6 +900,14 @@ export declare class CacheSet {
834
900
  private constructor();
835
901
  readonly ref: string;
836
902
  get(key: string): Promise<CacheHit | null>;
903
+ acquire(key: string): Promise<CacheAcquisition | null>;
904
+ inspectAcquisitions(options?: {
905
+ limit?: number;
906
+ }): Promise<CacheAcquisitionInspection>;
907
+ releaseAcquisition(options: {
908
+ id: string;
909
+ expectedGeneration: string;
910
+ }): Promise<CacheAcquisitionRelease>;
837
911
  put(key: string, handle: ApplicationHandleInput, options?: CacheEntryOptions): Promise<CacheStoreResult>;
838
912
  replace(key: string, handle: ApplicationHandleInput, options?: CacheEntryOptions): Promise<CacheStoreResult>;
839
913
  remove(key: string): Promise<CacheMutationResult & { readonly removed: CacheHit | null }>;
@@ -1126,6 +1200,17 @@ export interface RepositoryCacheUsage {
1126
1200
  readonly issues: ReadonlyArray<Record<string, unknown>>;
1127
1201
  }
1128
1202
 
1203
+ export interface RepositoryCacheAcquisitionUsage {
1204
+ readonly id?: string;
1205
+ readonly namespace?: string;
1206
+ readonly ref?: string;
1207
+ readonly generation: string;
1208
+ readonly acquiredAt?: string;
1209
+ readonly ageMs?: number | null;
1210
+ readonly healthy: boolean;
1211
+ readonly issues: ReadonlyArray<Record<string, unknown>>;
1212
+ }
1213
+
1129
1214
  export interface RepositoryRootSetUsage {
1130
1215
  readonly ref: string;
1131
1216
  readonly generation: string;
@@ -1160,6 +1245,32 @@ export interface RepositoryExpiringSetUsage {
1160
1245
  readonly issues: ReadonlyArray<Record<string, unknown>>;
1161
1246
  }
1162
1247
 
1248
+ export interface RepositoryWorkspaceUsage {
1249
+ readonly namespace: string | null;
1250
+ readonly ref: string;
1251
+ readonly generation: string;
1252
+ readonly healthy: boolean;
1253
+ readonly entryCount: number | null;
1254
+ readonly logicalBytes: number | null;
1255
+ /** Sum of unique direct Git root object sizes; excludes transitive support and pack overhead. */
1256
+ readonly rootObjectBytes: number | null;
1257
+ readonly physicalBytes: null;
1258
+ readonly retention: {
1259
+ readonly pinnedEntries: 0;
1260
+ readonly evictableEntries: number;
1261
+ } | null;
1262
+ readonly reachability: 'anchored';
1263
+ readonly age: {
1264
+ readonly createdAt: string | null;
1265
+ readonly ageMs: number | null;
1266
+ } | null;
1267
+ readonly expiry: {
1268
+ readonly expiresAt: string | null;
1269
+ readonly posture: 'active' | 'expired' | 'invalid';
1270
+ } | null;
1271
+ readonly issues: ReadonlyArray<Record<string, unknown>>;
1272
+ }
1273
+
1163
1274
  export interface RepositoryVaultUsage {
1164
1275
  readonly ref: string;
1165
1276
  readonly present: boolean;
@@ -1196,6 +1307,18 @@ export interface RepositoryDoctorReport {
1196
1307
  };
1197
1308
  };
1198
1309
  readonly usage: {
1310
+ /** Present in reports produced by git-cas v6.3.0 and later. */
1311
+ readonly acquisitions?: {
1312
+ readonly healthy: boolean;
1313
+ readonly coverage: RepositoryCollectionCoverage;
1314
+ readonly totals: {
1315
+ readonly activeCount: number;
1316
+ readonly oldestAcquiredAt: string | null;
1317
+ readonly newestAcquiredAt: string | null;
1318
+ readonly maxAgeMs: number | null;
1319
+ };
1320
+ readonly entries: ReadonlyArray<RepositoryCacheAcquisitionUsage>;
1321
+ };
1199
1322
  readonly caches: {
1200
1323
  readonly healthy: boolean;
1201
1324
  readonly coverage: RepositoryCollectionCoverage;
@@ -1228,6 +1351,18 @@ export interface RepositoryDoctorReport {
1228
1351
  };
1229
1352
  readonly entries: ReadonlyArray<RepositoryExpiringSetUsage>;
1230
1353
  };
1354
+ readonly workspaces: {
1355
+ readonly healthy: boolean;
1356
+ readonly coverage: RepositoryCollectionCoverage;
1357
+ readonly totals: {
1358
+ readonly entryCount: number | null;
1359
+ readonly logicalBytes: number | null;
1360
+ readonly rootObjectBytes: number | null;
1361
+ readonly activeWorkspaces: number | null;
1362
+ readonly expiredWorkspaces: number | null;
1363
+ };
1364
+ readonly entries: ReadonlyArray<RepositoryWorkspaceUsage>;
1365
+ };
1231
1366
  readonly vault: RepositoryVaultUsage;
1232
1367
  };
1233
1368
  readonly limitations: ReadonlyArray<RepositoryDiagnosticLimitation>;
@@ -1242,6 +1377,14 @@ export declare class RepositoryDoctor {
1242
1377
  expiringSets: {
1243
1378
  open(options: { namespace: string }): ExpiringSet | Promise<ExpiringSet>;
1244
1379
  };
1380
+ /** Optional only for backwards-compatible direct construction; workspace refs report unhealthy when absent. */
1381
+ workspaces?: {
1382
+ inspectRecord(record: {
1383
+ ref: string;
1384
+ oid: string;
1385
+ symref: string | null;
1386
+ }): Promise<WorkspaceInspectionRecord>;
1387
+ };
1245
1388
  vault: Pick<VaultService, 'getVaultMetadata' | 'readState'>;
1246
1389
  clock?: { now(): Date };
1247
1390
  });
@@ -1359,6 +1502,146 @@ export interface ExpiringSetCapability {
1359
1502
  }): Promise<ExpiringSet>;
1360
1503
  }
1361
1504
 
1505
+ export interface WorkspaceRetention {
1506
+ readonly policy: 'evictable';
1507
+ readonly reachability: 'anchored';
1508
+ readonly protection: 'workspace';
1509
+ }
1510
+
1511
+ export type WorkspaceRetainedData<T> = Omit<T, 'state' | 'retention'> & {
1512
+ state: 'retained';
1513
+ retention: WorkspaceRetention;
1514
+ witness: RetentionWitnessData;
1515
+ };
1516
+
1517
+ export type WorkspaceRetainedAsset = Omit<StagedAsset, 'state' | 'retention' | 'toJSON'> & {
1518
+ readonly state: 'retained';
1519
+ readonly retention: WorkspaceRetention;
1520
+ readonly witness: RetentionWitness;
1521
+ toJSON(): WorkspaceRetainedData<StagedAssetData>;
1522
+ };
1523
+
1524
+ export type WorkspaceRetainedPage = Omit<StagedPage, 'state' | 'retention' | 'toJSON'> & {
1525
+ readonly state: 'retained';
1526
+ readonly retention: WorkspaceRetention;
1527
+ readonly witness: RetentionWitness;
1528
+ toJSON(): WorkspaceRetainedData<StagedPageData>;
1529
+ };
1530
+
1531
+ export type WorkspaceRetainedBundle = Omit<StagedBundle, 'state' | 'retention' | 'toJSON'> & {
1532
+ readonly state: 'retained';
1533
+ readonly retention: WorkspaceRetention;
1534
+ readonly witness: RetentionWitness;
1535
+ toJSON(): WorkspaceRetainedData<StagedBundleData>;
1536
+ };
1537
+
1538
+ export interface WorkspaceCheckpointResult {
1539
+ readonly changed: boolean;
1540
+ readonly ref: string;
1541
+ readonly generation: string;
1542
+ readonly expiresAt: string;
1543
+ readonly handles: ReadonlyArray<ApplicationHandle>;
1544
+ readonly witnesses: ReadonlyArray<RetentionWitness>;
1545
+ }
1546
+
1547
+ export interface WorkspaceReleaseResult {
1548
+ readonly changed: boolean;
1549
+ readonly ref: string;
1550
+ readonly generation: string | null;
1551
+ }
1552
+
1553
+ export interface WorkspaceInspectionRecord {
1554
+ readonly id: string | null;
1555
+ readonly namespace: string | null;
1556
+ readonly ref: string;
1557
+ readonly generation: string;
1558
+ readonly symref: string | null;
1559
+ readonly rootCount: number | null;
1560
+ readonly logicalBytes: number | null;
1561
+ /** Sum of unique direct Git root object sizes; excludes transitive support and pack overhead. */
1562
+ readonly rootObjectBytes: number | null;
1563
+ readonly createdAt: string | null;
1564
+ readonly ageMs: number | null;
1565
+ readonly expiresAt: string | null;
1566
+ readonly posture: 'active' | 'expired' | 'invalid';
1567
+ readonly issue: Readonly<{ code: string; message: string }> | null;
1568
+ }
1569
+
1570
+ export interface WorkspaceInspection {
1571
+ readonly namespace: string;
1572
+ readonly returned: number;
1573
+ readonly truncated: boolean;
1574
+ /** Opaque continuation for the next bounded inspect or sweep call. */
1575
+ readonly nextCursor: string | null;
1576
+ readonly workspaces: ReadonlyArray<WorkspaceInspectionRecord>;
1577
+ }
1578
+
1579
+ export interface WorkspaceSweepResult {
1580
+ readonly namespace: string;
1581
+ readonly inspected: number;
1582
+ readonly changed: number;
1583
+ readonly conflicted: number;
1584
+ readonly missing: number;
1585
+ readonly truncated: boolean;
1586
+ /** Opaque continuation for the next bounded sweep call. */
1587
+ readonly nextCursor: string | null;
1588
+ readonly results: ReadonlyArray<Readonly<{
1589
+ id: string | null;
1590
+ ref: string;
1591
+ generation: string;
1592
+ changed: boolean;
1593
+ conflict: boolean;
1594
+ }>>;
1595
+ }
1596
+
1597
+ /** One renewable, RootSet-backed scope for multi-object staging. */
1598
+ export declare class StagingWorkspace {
1599
+ private constructor();
1600
+ readonly id: string;
1601
+ readonly namespace: string;
1602
+ readonly createdAt: string;
1603
+ readonly expiresAt: string | null;
1604
+ readonly assets: {
1605
+ put(options: AssetPutOptions): Promise<WorkspaceRetainedAsset>;
1606
+ adopt(options: { treeOid: string }): Promise<WorkspaceRetainedAsset>;
1607
+ };
1608
+ readonly pages: {
1609
+ put(options: { source: PageSource; maxBytes?: number }): Promise<WorkspaceRetainedPage>;
1610
+ };
1611
+ readonly bundles: {
1612
+ put(options: Parameters<BundleCapability['put']>[0]): Promise<WorkspaceRetainedBundle>;
1613
+ putOrdered(options: Parameters<BundleCapability['putOrdered']>[0]): Promise<WorkspaceRetainedBundle>;
1614
+ };
1615
+ checkpoint(options: { handles: Iterable<ApplicationHandleInput> }): Promise<WorkspaceCheckpointResult>;
1616
+ renew(): Promise<WorkspaceCheckpointResult>;
1617
+ promoteToCache(options: {
1618
+ cache: CacheSet;
1619
+ key: string;
1620
+ handle: ApplicationHandleInput;
1621
+ options?: CacheEntryOptions;
1622
+ }): Promise<Readonly<{ destination: CacheStoreResult; release: WorkspaceReleaseResult }>>;
1623
+ promoteToPublication(options: {
1624
+ handle: ApplicationHandleInput;
1625
+ commit: { message: string; parents?: string[] };
1626
+ ref: { name: string; expected: string | null };
1627
+ }): Promise<Readonly<{ destination: PublicationResult; release: WorkspaceReleaseResult }>>;
1628
+ release(): Promise<WorkspaceReleaseResult>;
1629
+ }
1630
+
1631
+ export interface WorkspaceCapability {
1632
+ open(options: { namespace: string; ttlMs?: number }): Promise<StagingWorkspace>;
1633
+ inspect(options: {
1634
+ namespace: string;
1635
+ limit?: number;
1636
+ cursor?: string | null;
1637
+ }): Promise<WorkspaceInspection>;
1638
+ sweep(options: {
1639
+ namespace: string;
1640
+ limit?: number;
1641
+ cursor?: string | null;
1642
+ }): Promise<WorkspaceSweepResult>;
1643
+ }
1644
+
1362
1645
  export interface DiagnosticsCapability {
1363
1646
  doctor(options?: RepositoryDoctorOptions): Promise<RepositoryDoctorReport>;
1364
1647
  }
@@ -1412,6 +1695,7 @@ export default class ContentAddressableStore {
1412
1695
 
1413
1696
  readonly caches: CacheCapability;
1414
1697
  readonly expiringSets: ExpiringSetCapability;
1698
+ readonly workspaces: WorkspaceCapability;
1415
1699
  readonly diagnostics: DiagnosticsCapability;
1416
1700
 
1417
1701
  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
  });
@@ -239,6 +247,8 @@ export default class ContentAddressableStore {
239
247
  #cacheSetRegistry = null;
240
248
  /** @type {ExpiringSetRegistry|null} */
241
249
  #expiringSetRegistry = null;
250
+ /** @type {StagingWorkspaceRegistry|null} */
251
+ #stagingWorkspaceRegistry = null;
242
252
  /** @type {RepositoryDoctor|null} */
243
253
  #repositoryDoctor = null;
244
254
  #servicePromise = null;
@@ -313,6 +323,7 @@ export default class ContentAddressableStore {
313
323
  rootSets: this.#rootSetRegistry,
314
324
  caches: this.#cacheSetRegistry,
315
325
  expiringSets: this.#expiringSetRegistry,
326
+ workspaces: this.#stagingWorkspaceRegistry,
316
327
  vault: this.#vault,
317
328
  clock: cfg.clock,
318
329
  });
@@ -336,6 +347,17 @@ export default class ContentAddressableStore {
336
347
  crypto,
337
348
  clock: cfg.clock,
338
349
  });
350
+ this.#stagingWorkspaceRegistry = new StagingWorkspaceRegistry({
351
+ persistence,
352
+ ref,
353
+ assets: this.#assetService,
354
+ pages: this.#pageService,
355
+ bundles: this.#bundleService,
356
+ publications: this.#publicationService,
357
+ resolveHandle: (handle) => this.#resolveApplicationRoot(handle),
358
+ crypto,
359
+ clock: cfg.clock,
360
+ });
339
361
  }
340
362
 
341
363
  #initApplicationServices({ ref, cfg }) {
@@ -401,6 +423,12 @@ export default class ContentAddressableStore {
401
423
  return this.#expiringSetRegistry;
402
424
  }
403
425
 
426
+ /** @returns {Promise<StagingWorkspaceRegistry>} */
427
+ async #getStagingWorkspaceRegistry() {
428
+ await this.#getService();
429
+ return this.#stagingWorkspaceRegistry;
430
+ }
431
+
404
432
  /** @returns {Promise<RepositoryDoctor>} */
405
433
  async #getRepositoryDoctor() {
406
434
  await this.#getService();