@git-stunts/git-cas 6.2.0 → 6.3.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 +16 -8
- package/CHANGELOG.md +37 -0
- package/README.md +13 -4
- package/UPGRADING.md +32 -0
- package/build-info.json +2 -2
- package/docs/API.md +124 -8
- package/docs/releases/v6.3.0.md +96 -0
- package/index.d.ts +95 -2
- package/package.json +2 -1
- package/src/domain/errors/Codes.js +4 -0
- package/src/domain/services/CacheAcquisitionInventory.js +123 -0
- package/src/domain/services/CacheAcquisitionRegistry.js +188 -0
- package/src/domain/services/CacheSet.js +56 -5
- package/src/domain/services/CacheSetRegistry.js +7 -0
- package/src/domain/services/RepositoryDoctor.js +30 -3
- package/src/domain/value-objects/CacheAcquisition.js +88 -0
- package/src/domain/value-objects/CacheAcquisitionRef.js +129 -0
- package/src/domain/value-objects/RetentionWitness.js +6 -1
- package/src/infrastructure/adapters/GitRefAdapter.js +312 -2
- package/src/infrastructure/adapters/GitRepositoryInspectionAdapter.js +28 -10
- package/src/package-version.js +1 -1
- package/src/ports/GitRefPort.js +45 -0
- package/src/ports/RepositoryInspectionPort.js +5 -2
package/ARCHITECTURE.md
CHANGED
|
@@ -187,7 +187,10 @@ The facade is orchestration glue. It is not the storage engine itself.
|
|
|
187
187
|
- **`CacheSetRegistry` and `CacheSet`** — own cache index generations,
|
|
188
188
|
compare-and-swap replacement, TTL, entry and logical-byte limits,
|
|
189
189
|
approximate-LRU sweeps, coalesced touches, doctor, and authoritative repair
|
|
190
|
-
under `refs/cas/caches/*`.
|
|
190
|
+
under `refs/cas/caches/*`. `CacheAcquisitionRegistry` atomically verifies a
|
|
191
|
+
selected cache generation and creates a scoped anchor under
|
|
192
|
+
`refs/cas/cache-acquisitions/*`; acquisition release is explicit,
|
|
193
|
+
idempotent, and generation-checked.
|
|
191
194
|
|
|
192
195
|
- **`ExpiringSetRegistry` and `ExpiringSet`** — own digest-only replay markers
|
|
193
196
|
under `refs/cas/expiring/*`. Admission is atomic, membership reads are
|
|
@@ -447,21 +450,26 @@ make objects Git-reachable, but they encode different lifecycle contracts:
|
|
|
447
450
|
| --- | --- | --- |
|
|
448
451
|
| RootSet | `refs/cas/rootsets/*` | Caller-managed current generation |
|
|
449
452
|
| CacheSet | `refs/cas/caches/*` | TTL/capacity/approximate-LRU managed cache |
|
|
453
|
+
| Cache acquisition | `refs/cas/cache-acquisitions/*` | Explicit caller scope over one cache generation |
|
|
450
454
|
| ExpiringSet | `refs/cas/expiring/*` | Expiry-only replay protection |
|
|
451
455
|
| Publication | Caller-allowlisted ref | Application-controlled causal history |
|
|
452
456
|
| Vault | `refs/cas/vault` | History-preserving named assets |
|
|
453
457
|
|
|
454
|
-
High-level retention, CacheSet, ExpiringSet, and application
|
|
455
|
-
operations return generation-scoped retention evidence. Replacing
|
|
456
|
-
current-generation head releases old edges when no other ref or
|
|
457
|
-
them; Git's normal grace and pruning policy still controls
|
|
458
|
+
High-level retention, CacheSet, cache acquisition, ExpiringSet, and application
|
|
459
|
+
publication operations return generation-scoped retention evidence. Replacing
|
|
460
|
+
a parentless current-generation head releases old edges when no other ref or
|
|
461
|
+
reflog reaches them; Git's normal grace and pruning policy still controls
|
|
462
|
+
physical deletion. A cache acquisition temporarily retains the complete
|
|
463
|
+
selected generation, not only the requested target, and must be released when
|
|
464
|
+
consumption ends.
|
|
458
465
|
|
|
459
466
|
### Repository Diagnostics
|
|
460
467
|
|
|
461
468
|
`cas.diagnostics.doctor()` reports total, anchored, orphaned, volatile, and
|
|
462
|
-
unreachable object evidence plus managed-storage summaries
|
|
463
|
-
|
|
464
|
-
prune dry-run output for the
|
|
469
|
+
unreachable object evidence plus managed-storage summaries, including active
|
|
470
|
+
cache-acquisition count and age. Ref and reflog reachability defines anchored
|
|
471
|
+
objects; volatile objects come only from safe prune dry-run output for the
|
|
472
|
+
selected expiry cutoff.
|
|
465
473
|
|
|
466
474
|
The report names limits Git cannot prove exactly, including per-owner
|
|
467
475
|
deduplicated physical bytes and packed-object age. The inspection surface has
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.3.0] — 2026-07-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Scoped cache acquisitions** — `CacheSet.acquire()` now performs a bounded,
|
|
15
|
+
reference-only lookup and atomically anchors the selected cache generation
|
|
16
|
+
for an explicit caller lifetime. Acquisitions carry separate pinned
|
|
17
|
+
retention evidence, release idempotently with a generation check, expose
|
|
18
|
+
bounded inspection and operational cleanup, and appear in repository doctor
|
|
19
|
+
with count and age evidence. Clock skew leaves structurally valid retention
|
|
20
|
+
healthy while reporting an unknown age and explicit diagnostic issue.
|
|
21
|
+
Real-Git coverage proves active acquisitions
|
|
22
|
+
survive aggressive prune without making lookup reads scale with target graph
|
|
23
|
+
size. Canonical one-segment namespace refs, symbolic-ref preflight,
|
|
24
|
+
no-dereference mutations across ordinary managed refs and acquisition refs,
|
|
25
|
+
post-conflict ref-type checks, and hard Git inventory limits preserve
|
|
26
|
+
ownership boundaries under hostile or malformed refs. Unknown ref-type
|
|
27
|
+
evidence fails doctor health closed. Acquisition capabilities remain optional
|
|
28
|
+
on the base Git ref port, the existing retention-kind and diagnostic-kind
|
|
29
|
+
unions remain unchanged, and the new doctor group is type-optional for
|
|
30
|
+
compatibility with existing consumers. Production Git checked-delete
|
|
31
|
+
conflicts fail closed because Git 2.43 cannot atomically prove that a missing
|
|
32
|
+
direct ref is not an enumerator-invisible dangling symbolic ref.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **Pre-push Git environment isolation** — repository-local `GIT_*` variables
|
|
37
|
+
exported by Git hooks are cleared before lint and tests run, so child
|
|
38
|
+
processes can create and inspect independent temporary repositories. The
|
|
39
|
+
hook fails closed if Git cannot enumerate the local variables.
|
|
40
|
+
|
|
41
|
+
### Documentation
|
|
42
|
+
|
|
43
|
+
- **v6.2.0 publication evidence** — records the signed tag identity, successful
|
|
44
|
+
release workflow, npm integrity and SLSA provenance, final GitHub Release,
|
|
45
|
+
and the registry gate that unlocks downstream application adoption.
|
|
46
|
+
|
|
10
47
|
## [6.2.0] — 2026-07-13
|
|
11
48
|
|
|
12
49
|
### Added
|
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ Unlike traditional LFS which moves files to external servers, `git-cas` treats t
|
|
|
25
25
|
without vault history retaining every prior generation.
|
|
26
26
|
- **Managed Cache Sets**: Applications can store handles under
|
|
27
27
|
`refs/cas/caches/*` with TTL, entry and logical-byte limits, approximate LRU
|
|
28
|
-
eviction, immutable retention evidence, bounded inspection, and
|
|
28
|
+
eviction, immutable retention evidence, bounded inspection, repair, and
|
|
29
|
+
scoped acquisitions that keep a selected generation reachable during use.
|
|
29
30
|
Cache indexes and object reachability remain git-cas responsibilities.
|
|
30
31
|
- **Expiry-Safe Replay Sets**: Security-sensitive markers can live under
|
|
31
32
|
`refs/cas/expiring/*` with atomic add-if-absent, digest-only metadata, and
|
|
@@ -43,7 +44,7 @@ Unlike traditional LFS which moves files to external servers, `git-cas` treats t
|
|
|
43
44
|
Existing v5 users should read [UPGRADING.md](./UPGRADING.md) and run
|
|
44
45
|
`npm run upgrade` in dry-run mode before restoring old encrypted vault entries.
|
|
45
46
|
For the release overview, see the
|
|
46
|
-
[v6.
|
|
47
|
+
[v6.3.0 Release Notes](./docs/releases/v6.3.0.md).
|
|
47
48
|
|
|
48
49
|
### 1. CLI Usage
|
|
49
50
|
|
|
@@ -103,6 +104,7 @@ The README is the front door. Detailed mechanics live in the guide set:
|
|
|
103
104
|
| Assets, pages, bundles, retention, and publication | [Application storage](./docs/API.md#application-storage) |
|
|
104
105
|
| GC retention for caches and derived state | [Root Sets](./docs/API.md#root-sets) |
|
|
105
106
|
| Managed TTL and capacity caches | [Cache Sets](./docs/API.md#cache-sets) |
|
|
107
|
+
| Scoped protection while consuming a cache hit | [Cache acquisitions](./docs/API.md#acquire-and-release) |
|
|
106
108
|
| Durable replay markers with expiry-only release | [Expiring Sets](./docs/API.md#expiring-sets) |
|
|
107
109
|
| Repository reachability and git-cas usage evidence | [Repository Diagnostics](./docs/API.md#repository-diagnostics) |
|
|
108
110
|
| v5 to v6 migration | [Upgrading](./UPGRADING.md) |
|
|
@@ -126,6 +128,10 @@ Core capabilities:
|
|
|
126
128
|
compare-and-swap replacement, expiry, capacity eviction, retention
|
|
127
129
|
witnesses, diagnostics, and repair. Reads do not write access metadata;
|
|
128
130
|
callers opt into coalesced access updates with `touch()`.
|
|
131
|
+
- **Scoped cache acquisitions**: `cache.acquire()` performs a reference-only
|
|
132
|
+
lookup and atomically anchors the selected cache generation for the caller's
|
|
133
|
+
explicit lifetime. `release()` is idempotent, while inspection and checked
|
|
134
|
+
cleanup make abandoned acquisition refs observable and recoverable.
|
|
129
135
|
- **Expiry-safe replay lifecycle**: `expiringSets.open()` atomically retains
|
|
130
136
|
digest-only replay markers through their declared window. `contains()` is
|
|
131
137
|
read-only, and `sweep()` can release only markers whose expiry has passed.
|
|
@@ -137,8 +143,9 @@ Core capabilities:
|
|
|
137
143
|
avoid re-encrypting data blobs.
|
|
138
144
|
- **Operational diagnostics**: `cas.diagnostics.doctor()` streams repository
|
|
139
145
|
object/ref evidence, classifies anchored, orphaned, and volatile objects,
|
|
140
|
-
and summarizes CacheSet, RootSet, ExpiringSet, and Vault
|
|
141
|
-
mutating Git. The `git-cas doctor` CLI continues to validate
|
|
146
|
+
and summarizes cache acquisitions, CacheSet, RootSet, ExpiringSet, and Vault
|
|
147
|
+
usage without mutating Git. The `git-cas doctor` CLI continues to validate
|
|
148
|
+
vault health.
|
|
142
149
|
|
|
143
150
|
## Safety Snapshot
|
|
144
151
|
|
|
@@ -186,6 +193,8 @@ All three runtimes are tested in CI on every push. The hexagonal architecture is
|
|
|
186
193
|
- **[v6.2.0 Release Notes](./docs/releases/v6.2.0.md)**: Opaque application
|
|
187
194
|
storage, managed cache and replay lifecycles, retention evidence, and
|
|
188
195
|
repository diagnostics.
|
|
196
|
+
- **[v6.3.0 Release Notes](./docs/releases/v6.3.0.md)**: Lifetime-safe,
|
|
197
|
+
reference-only cache acquisitions with explicit release and doctor evidence.
|
|
189
198
|
- **[Upgrading](./UPGRADING.md)**: Migration guide for v5 → v6.
|
|
190
199
|
- **[Changelog](./CHANGELOG.md)**: Version history and migration notes.
|
|
191
200
|
|
package/UPGRADING.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
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.2.0 To v6.3.0
|
|
6
|
+
|
|
7
|
+
v6.3.0 is API-additive and does not require stored-data migration. It adds
|
|
8
|
+
scoped cache acquisitions for consumers that must keep a cache hit reachable
|
|
9
|
+
between lookup and use.
|
|
10
|
+
|
|
11
|
+
`CacheSet.get()` retains its existing complete-validation semantics, but a
|
|
12
|
+
returned hit is only an observation. Use `acquire()` when consumption may
|
|
13
|
+
overlap replacement, expiry, eviction, removal, or destructive Git cleanup:
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
const acquisition = await cache.acquire(materializationKey);
|
|
17
|
+
if (acquisition) {
|
|
18
|
+
try {
|
|
19
|
+
await consume(acquisition.hit.handle);
|
|
20
|
+
} finally {
|
|
21
|
+
await acquisition.release();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
An acquisition anchors the exact observed cache generation until explicit,
|
|
27
|
+
idempotent release. It intentionally has no automatic TTL: age is diagnostic
|
|
28
|
+
evidence, not proof that a consumer is dead. Recovery tooling can use
|
|
29
|
+
`cache.inspectAcquisitions({ limit })` and generation-checked
|
|
30
|
+
`cache.releaseAcquisition(...)`; `cas.diagnostics.doctor()` reports bounded
|
|
31
|
+
count, age, truncation, malformed-ref, and clock-skew evidence.
|
|
32
|
+
|
|
33
|
+
See [v6.3.0 Release Notes](./docs/releases/v6.3.0.md) and
|
|
34
|
+
[Acquire And Release](./docs/API.md#acquire-and-release) for the complete
|
|
35
|
+
lifetime and recovery contract.
|
|
36
|
+
|
|
5
37
|
## v6.1.0 To v6.2.0
|
|
6
38
|
|
|
7
39
|
v6.2.0 is API-additive and does not require stored-data migration. It adds
|
package/build-info.json
CHANGED
package/docs/API.md
CHANGED
|
@@ -1511,6 +1511,71 @@ generation, and immutable retention evidence.
|
|
|
1511
1511
|
`accessedAt` is at least `accessResolutionMs` old, coalescing approximate-LRU
|
|
1512
1512
|
updates without turning every read into a Git ref mutation.
|
|
1513
1513
|
|
|
1514
|
+
### acquire And release
|
|
1515
|
+
|
|
1516
|
+
Use `acquire(key)` when the caller will consume a cached handle while another
|
|
1517
|
+
writer may replace, remove, expire, or sweep that cache entry:
|
|
1518
|
+
|
|
1519
|
+
```javascript
|
|
1520
|
+
const acquisition = await cache.acquire('optic:user:alice');
|
|
1521
|
+
if (acquisition) {
|
|
1522
|
+
try {
|
|
1523
|
+
await consume(acquisition.hit.handle);
|
|
1524
|
+
} finally {
|
|
1525
|
+
await acquisition.release();
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
`acquire()` returns an immutable `CacheAcquisition` or `null`. It performs a
|
|
1531
|
+
reference-only cache lookup: the operation reads the bounded index path and
|
|
1532
|
+
does not recursively materialize or validate the target handle graph. It then
|
|
1533
|
+
atomically verifies the observed cache ref generation and creates a unique ref
|
|
1534
|
+
under `refs/cas/cache-acquisitions/<encoded-namespace>/*` that names that
|
|
1535
|
+
generation. The namespace occupies exactly one encoded ref segment, preventing
|
|
1536
|
+
parent and child cache namespaces from overlapping during inspection.
|
|
1537
|
+
If a writer changes the cache generation during this transaction, acquisition
|
|
1538
|
+
retries against a fresh bounded lookup up to five times and then fails with
|
|
1539
|
+
`CACHE_ACQUISITION_CONFLICT`.
|
|
1540
|
+
|
|
1541
|
+
The acquisition carries the original `hit`, a separate pinned retention
|
|
1542
|
+
`evidence` witness, its opaque `id`, and `acquiredAt`. The witness keeps the
|
|
1543
|
+
existing `cache-set` root kind because the retained object is a cache-set
|
|
1544
|
+
generation; its acquisition ref identifies the scoped retention mechanism.
|
|
1545
|
+
This preserves the public closed `RetentionRootKind` union. The ref temporarily
|
|
1546
|
+
keeps the complete selected cache generation reachable, including the requested
|
|
1547
|
+
target. This is intentionally stronger than a bare cache observation and must
|
|
1548
|
+
not be left open after consumption.
|
|
1549
|
+
|
|
1550
|
+
`release()` preflights and rejects a symbolic acquisition ref that is already
|
|
1551
|
+
observable, then generation-checks a no-dereference deletion. Git 2.43 cannot
|
|
1552
|
+
atomically assert both ref type and OID. If another process installs a same-OID
|
|
1553
|
+
symbolic ref after preflight, Git may delete that managed ref name; `--no-deref`
|
|
1554
|
+
ensures it never deletes or updates the symbolic referent. This API claims
|
|
1555
|
+
authority containment under that race, not race-free ref-type rejection.
|
|
1556
|
+
Release through one `CacheAcquisition` object is idempotent: the call that
|
|
1557
|
+
deletes the ref reports `changed: true`; later calls reuse its receipt and report
|
|
1558
|
+
`changed: false`. Concurrent calls on that object share one operation. A
|
|
1559
|
+
mismatched or otherwise unprovable direct generation fails closed with
|
|
1560
|
+
`CACHE_ACQUISITION_RELEASE_CONFLICT`.
|
|
1561
|
+
There is no implicit TTL because elapsed time alone cannot prove that a live
|
|
1562
|
+
caller has finished using the handle.
|
|
1563
|
+
|
|
1564
|
+
The production Git adapter applies the same authority boundary to ordinary
|
|
1565
|
+
managed RootSet, publication, and vault ref movement: it rejects a symbolic ref
|
|
1566
|
+
observed before mutation and always invokes `git update-ref --no-deref`. A
|
|
1567
|
+
post-probe ref-type race may replace the managed name itself, but cannot redirect
|
|
1568
|
+
the update into a symbolic referent.
|
|
1569
|
+
|
|
1570
|
+
Existing custom ref and crypto adapters remain valid for `get()`, `put()`,
|
|
1571
|
+
`replace()`, `remove()`, `sweep()`, and `touch()`. Acquisition operations add
|
|
1572
|
+
capability requirements only when invoked: atomic `anchorRef`, checked
|
|
1573
|
+
`deleteRef`, streaming `iterateRefs`, and 16-byte `randomBytes`. A missing
|
|
1574
|
+
capability fails the acquisition operation with `CACHE_ACQUISITION_INVALID`;
|
|
1575
|
+
it does not prevent the cache from opening or change existing operations. The
|
|
1576
|
+
three ref capabilities remain optional on the public base port so existing
|
|
1577
|
+
structural adapters continue to type-check.
|
|
1578
|
+
|
|
1514
1579
|
### remove And sweep
|
|
1515
1580
|
|
|
1516
1581
|
```javascript
|
|
@@ -1538,6 +1603,7 @@ Logical-byte accounting is versioned and deterministic:
|
|
|
1538
1603
|
```javascript
|
|
1539
1604
|
const first = await cache.inspect({ limit: 100 });
|
|
1540
1605
|
const next = await cache.inspect({ limit: 100, cursor: first.nextCursor });
|
|
1606
|
+
const active = await cache.inspectAcquisitions({ limit: 100 });
|
|
1541
1607
|
const report = await cache.doctor();
|
|
1542
1608
|
```
|
|
1543
1609
|
|
|
@@ -1548,6 +1614,26 @@ parentless generation, RootSet edge, structured bundle support graph, key
|
|
|
1548
1614
|
digests, target handles, canonical metadata, accounting version, persisted
|
|
1549
1615
|
summary, and capacity posture.
|
|
1550
1616
|
|
|
1617
|
+
`inspectAcquisitions()` streams only this cache namespace's acquisition refs.
|
|
1618
|
+
It returns opaque IDs, generation OIDs, acquisition timestamps, and key digests
|
|
1619
|
+
from a work-bounded first page of at most 1,000 entries; it does not disclose
|
|
1620
|
+
original cache keys. The result's `truncated` flag means at least one more entry
|
|
1621
|
+
exists. Cleanup releases the returned entries and repeats inspection while
|
|
1622
|
+
`truncated` is true. There is intentionally no cursor that can scan through an
|
|
1623
|
+
unbounded skipped prefix. Operational repair releases an abandoned acquisition
|
|
1624
|
+
with an explicit generation check:
|
|
1625
|
+
|
|
1626
|
+
```javascript
|
|
1627
|
+
await cache.releaseAcquisition({
|
|
1628
|
+
id: active.entries[0].id,
|
|
1629
|
+
expectedGeneration: active.entries[0].generation,
|
|
1630
|
+
});
|
|
1631
|
+
```
|
|
1632
|
+
|
|
1633
|
+
Normal callers should retain the `CacheAcquisition` object and call its
|
|
1634
|
+
`release()` method. The lower-level cleanup method exists for doctor/repair
|
|
1635
|
+
workflows and refuses to delete a ref whose generation no longer matches.
|
|
1636
|
+
|
|
1551
1637
|
### repair
|
|
1552
1638
|
|
|
1553
1639
|
```javascript
|
|
@@ -1698,17 +1784,19 @@ const report = await cas.diagnostics.doctor({
|
|
|
1698
1784
|
});
|
|
1699
1785
|
|
|
1700
1786
|
console.log(report.repository.objects);
|
|
1787
|
+
console.log(report.usage.acquisitions);
|
|
1701
1788
|
console.log(report.usage.caches);
|
|
1702
1789
|
console.log(report.limitations);
|
|
1703
1790
|
```
|
|
1704
1791
|
|
|
1705
1792
|
Pass either `gracePeriodMs` or an exact canonical `expiresBefore` UTC timestamp,
|
|
1706
1793
|
not both. The default grace period is 14 days. `maxCollectionsPerKind` bounds
|
|
1707
|
-
detailed CacheSet, RootSet, and ExpiringSet rows from 1
|
|
1708
|
-
is 100. Every managed collection
|
|
1709
|
-
in `totals`. Coverage reports
|
|
1710
|
-
`complete`, so detail truncation is
|
|
1711
|
-
managed refs or undercounting repository
|
|
1794
|
+
detailed cache-acquisition, CacheSet, RootSet, and ExpiringSet rows from 1
|
|
1795
|
+
through 1000; its default is 100. Every managed collection or acquisition is
|
|
1796
|
+
still inspected sequentially and included in `totals`. Coverage reports
|
|
1797
|
+
`observed`, `inspected`, `detailed`, and `complete`, so detail truncation is
|
|
1798
|
+
visible instead of silently dropping managed refs or undercounting repository
|
|
1799
|
+
usage.
|
|
1712
1800
|
|
|
1713
1801
|
The reachability classes have precise operational meanings:
|
|
1714
1802
|
|
|
@@ -1735,12 +1823,32 @@ in its inventory, while object disk sizes exclude pack indexes, bitmaps, and
|
|
|
1735
1823
|
other repository metadata. These facts appear in `limitations` rather than
|
|
1736
1824
|
being estimated.
|
|
1737
1825
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1826
|
+
Acquisition summaries report active count, oldest and newest acquisition time,
|
|
1827
|
+
and maximum age; detailed entries expose opaque IDs and never original cache
|
|
1828
|
+
keys. If an acquisition timestamp is later than the doctor clock, the direct
|
|
1829
|
+
retention ref remains healthy, `ageMs` is `null`, and the entry reports
|
|
1830
|
+
`CACHE_ACQUISITION_CLOCK_SKEW`; elapsed time is evidence, not ref validity.
|
|
1831
|
+
`maxAgeMs` is `null` when any active acquisition age is incomparable. Cache
|
|
1832
|
+
summaries report entry count, deterministic logical bytes, age,
|
|
1833
|
+
expiry, capacity policy, and pinned/evictable counts. RootSet policy counts and
|
|
1834
|
+
Vault entry counts are reported independently from reachability. A privacy-mode
|
|
1741
1835
|
vault remains healthy but reports `entryCount: null` because repository doctor
|
|
1742
1836
|
does not request or retain vault key material.
|
|
1743
1837
|
|
|
1838
|
+
Git's `for-each-ref` does not enumerate dangling symbolic refs. Repository
|
|
1839
|
+
doctor therefore reports symbolic acquisition refs that Git returns, but does
|
|
1840
|
+
not claim exhaustive inventory of dangling symbolic acquisition refs. An
|
|
1841
|
+
inspection adapter that omits `symref` evidence makes the acquisition group and
|
|
1842
|
+
overall doctor report unhealthy rather than treating unknown ref type as a
|
|
1843
|
+
regular ref. Direct acquire, release, and cleanup operations independently
|
|
1844
|
+
preflight with `symbolic-ref`; no-dereference mutations contain post-probe races
|
|
1845
|
+
to the managed ref name. After a checked-delete conflict, release probes ref
|
|
1846
|
+
type and direct-ref inventory for diagnostic evidence, then fails closed. Git
|
|
1847
|
+
2.43 cannot atomically prove that an absent direct ref is not an
|
|
1848
|
+
enumerator-invisible dangling symbolic ref, so the production adapter does not
|
|
1849
|
+
infer an idempotent miss from that conflict. Recovery code can re-inspect the
|
|
1850
|
+
bounded acquisition namespace before deciding that cleanup is complete.
|
|
1851
|
+
|
|
1744
1852
|
Object and ref inventories are consumed as streams, and managed collections are
|
|
1745
1853
|
inspected one at a time. Runtime memory is bounded by stream windows,
|
|
1746
1854
|
`maxCollectionsPerKind`, and existing per-collection/blob safety limits;
|
|
@@ -2657,6 +2765,10 @@ for await (const oid of port.iterateReachableObjectIds()) {
|
|
|
2657
2765
|
for await (const object of port.iteratePrunableObjects({ expiresBefore })) {
|
|
2658
2766
|
// safe dry-run evidence only
|
|
2659
2767
|
}
|
|
2768
|
+
|
|
2769
|
+
for await (const ref of port.iterateRefs({ prefix: 'refs/cas/cache-acquisitions/' })) {
|
|
2770
|
+
// streamed repository diagnostics; ref.symref exposes symbolic targets
|
|
2771
|
+
}
|
|
2660
2772
|
```
|
|
2661
2773
|
|
|
2662
2774
|
`GitRepositoryInspectionAdapter` requires `@git-stunts/plumbing` 3.1.0 or
|
|
@@ -3061,8 +3173,12 @@ new CasError({ message, code, meta, documentationUrl });
|
|
|
3061
3173
|
| `CACHE_ENTRY_INVALID` | Entry metadata, retention, expiry, handle identity, or key digest is invalid | CacheSet writes and reads |
|
|
3062
3174
|
| `CACHE_STATE_INVALID` | Cache state, structured index, counts, or namespace is inconsistent | CacheSet reads, `doctor()`, and `repair()` |
|
|
3063
3175
|
| `CACHE_POLICY_INVALID` | Cache entry, byte, access-resolution, or repair bound is invalid | `caches.open()`, CacheSet policy operations |
|
|
3176
|
+
| `CACHE_ACQUISITION_INVALID` | Acquisition identity, timestamp, dependency, or inspection option is invalid | `acquire()`, acquisition inspection, and release |
|
|
3177
|
+
| `CACHE_ACQUISITION_CONFLICT` | Cache generation changed throughout bounded acquisition retries | `acquire()` |
|
|
3178
|
+
| `CACHE_ACQUISITION_RELEASE_CONFLICT` | Acquisition ref no longer names the generation supplied for checked cleanup | `release()` and `releaseAcquisition()` |
|
|
3064
3179
|
| `CACHE_LOGICAL_SIZE_UNKNOWN` | A target has no deterministic safe-integer logical size | `put()`, `replace()`, accounting, and repair |
|
|
3065
3180
|
| `CACHE_CONFLICT` | Concurrent cache update exhausted bounded compare-and-swap retries | CacheSet mutations and repair |
|
|
3181
|
+
| `GIT_REF_CONFLICT` | A checked Git ref deletion observed an unexpected target | Semantic ref adapters and checked acquisition cleanup |
|
|
3066
3182
|
| `RETENTION_WITNESS_INVALID` | Witness policy, reachability, root evidence, generation, or timestamp is invalid | `RetentionWitness` |
|
|
3067
3183
|
| `PUBLICATION_INVALID` | Publication message, parent list, expected head, dependency, or clock input is invalid | `publications.commit()` |
|
|
3068
3184
|
| `PUBLICATION_REF_FORBIDDEN` | Target ref is invalid, reserved, or outside configured application namespaces | `publications.commit()` |
|
|
@@ -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.
|
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 =
|
|
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,16 @@ 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
|
+
limit: number;
|
|
560
|
+
}): AsyncIterable<{ ref: string; oid: string; symref: string | null }>;
|
|
518
561
|
}
|
|
519
562
|
|
|
520
563
|
/** Git-backed implementation of the persistence port. */
|
|
@@ -526,6 +569,16 @@ export declare class GitPersistenceAdapter extends GitPersistencePortBase {
|
|
|
526
569
|
/** Git-backed implementation of the ref port. */
|
|
527
570
|
export declare class GitRefAdapter extends GitRefPortBase {
|
|
528
571
|
constructor(options: { plumbing: unknown; policy?: unknown });
|
|
572
|
+
anchorRef(options: {
|
|
573
|
+
sourceRef: string;
|
|
574
|
+
expectedSourceOid: string;
|
|
575
|
+
targetRef: string;
|
|
576
|
+
}): Promise<boolean>;
|
|
577
|
+
deleteRef(options: { ref: string; expectedOldOid: string }): Promise<boolean>;
|
|
578
|
+
iterateRefs(options: {
|
|
579
|
+
prefix?: string;
|
|
580
|
+
limit: number;
|
|
581
|
+
}): AsyncIterable<{ ref: string; oid: string; symref: string | null }>;
|
|
529
582
|
}
|
|
530
583
|
|
|
531
584
|
export type RepositoryObjectType = 'blob' | 'tree' | 'commit' | 'tag';
|
|
@@ -537,6 +590,13 @@ export interface RepositoryObjectRecord {
|
|
|
537
590
|
readonly physicalBytes: number;
|
|
538
591
|
}
|
|
539
592
|
|
|
593
|
+
export interface RepositoryRefRecord {
|
|
594
|
+
readonly ref: string;
|
|
595
|
+
readonly oid: string;
|
|
596
|
+
/** Present when the inspection adapter can distinguish symbolic refs. */
|
|
597
|
+
readonly symref?: string | null;
|
|
598
|
+
}
|
|
599
|
+
|
|
540
600
|
/** Abstract non-mutating repository inspection port. */
|
|
541
601
|
export declare class RepositoryInspectionPort {
|
|
542
602
|
iterateObjects(): AsyncIterable<RepositoryObjectRecord>;
|
|
@@ -544,7 +604,9 @@ export declare class RepositoryInspectionPort {
|
|
|
544
604
|
iteratePrunableObjects(options: {
|
|
545
605
|
expiresBefore: string;
|
|
546
606
|
}): AsyncIterable<Pick<RepositoryObjectRecord, 'oid' | 'type'>>;
|
|
547
|
-
iterateRefs(
|
|
607
|
+
iterateRefs(options?: {
|
|
608
|
+
prefix?: string;
|
|
609
|
+
}): AsyncIterable<RepositoryRefRecord>;
|
|
548
610
|
reachablePhysicalBytes(): Promise<number>;
|
|
549
611
|
}
|
|
550
612
|
|
|
@@ -834,6 +896,14 @@ export declare class CacheSet {
|
|
|
834
896
|
private constructor();
|
|
835
897
|
readonly ref: string;
|
|
836
898
|
get(key: string): Promise<CacheHit | null>;
|
|
899
|
+
acquire(key: string): Promise<CacheAcquisition | null>;
|
|
900
|
+
inspectAcquisitions(options?: {
|
|
901
|
+
limit?: number;
|
|
902
|
+
}): Promise<CacheAcquisitionInspection>;
|
|
903
|
+
releaseAcquisition(options: {
|
|
904
|
+
id: string;
|
|
905
|
+
expectedGeneration: string;
|
|
906
|
+
}): Promise<CacheAcquisitionRelease>;
|
|
837
907
|
put(key: string, handle: ApplicationHandleInput, options?: CacheEntryOptions): Promise<CacheStoreResult>;
|
|
838
908
|
replace(key: string, handle: ApplicationHandleInput, options?: CacheEntryOptions): Promise<CacheStoreResult>;
|
|
839
909
|
remove(key: string): Promise<CacheMutationResult & { readonly removed: CacheHit | null }>;
|
|
@@ -1126,6 +1196,17 @@ export interface RepositoryCacheUsage {
|
|
|
1126
1196
|
readonly issues: ReadonlyArray<Record<string, unknown>>;
|
|
1127
1197
|
}
|
|
1128
1198
|
|
|
1199
|
+
export interface RepositoryCacheAcquisitionUsage {
|
|
1200
|
+
readonly id?: string;
|
|
1201
|
+
readonly namespace?: string;
|
|
1202
|
+
readonly ref?: string;
|
|
1203
|
+
readonly generation: string;
|
|
1204
|
+
readonly acquiredAt?: string;
|
|
1205
|
+
readonly ageMs?: number | null;
|
|
1206
|
+
readonly healthy: boolean;
|
|
1207
|
+
readonly issues: ReadonlyArray<Record<string, unknown>>;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1129
1210
|
export interface RepositoryRootSetUsage {
|
|
1130
1211
|
readonly ref: string;
|
|
1131
1212
|
readonly generation: string;
|
|
@@ -1196,6 +1277,18 @@ export interface RepositoryDoctorReport {
|
|
|
1196
1277
|
};
|
|
1197
1278
|
};
|
|
1198
1279
|
readonly usage: {
|
|
1280
|
+
/** Present in reports produced by git-cas v6.3.0 and later. */
|
|
1281
|
+
readonly acquisitions?: {
|
|
1282
|
+
readonly healthy: boolean;
|
|
1283
|
+
readonly coverage: RepositoryCollectionCoverage;
|
|
1284
|
+
readonly totals: {
|
|
1285
|
+
readonly activeCount: number;
|
|
1286
|
+
readonly oldestAcquiredAt: string | null;
|
|
1287
|
+
readonly newestAcquiredAt: string | null;
|
|
1288
|
+
readonly maxAgeMs: number | null;
|
|
1289
|
+
};
|
|
1290
|
+
readonly entries: ReadonlyArray<RepositoryCacheAcquisitionUsage>;
|
|
1291
|
+
};
|
|
1199
1292
|
readonly caches: {
|
|
1200
1293
|
readonly healthy: boolean;
|
|
1201
1294
|
readonly coverage: RepositoryCollectionCoverage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git-stunts/git-cas",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.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",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"docs/releases/v6.0.0.md",
|
|
35
35
|
"docs/releases/v6.1.0.md",
|
|
36
36
|
"docs/releases/v6.2.0.md",
|
|
37
|
+
"docs/releases/v6.3.0.md",
|
|
37
38
|
"docs/THREAT_MODEL.md",
|
|
38
39
|
"docs/VAULT_INTERNALS.md",
|
|
39
40
|
"docs/WALKTHROUGH.md",
|