@git-stunts/git-cas 6.1.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.
Files changed (69) hide show
  1. package/ARCHITECTURE.md +116 -3
  2. package/CHANGELOG.md +117 -2
  3. package/GUIDE.md +114 -13
  4. package/README.md +60 -4
  5. package/UPGRADING.md +75 -0
  6. package/build-info.json +2 -2
  7. package/docs/API.md +867 -16
  8. package/docs/releases/v6.2.0.md +131 -0
  9. package/docs/releases/v6.3.0.md +96 -0
  10. package/index.d.ts +972 -2
  11. package/index.js +326 -1
  12. package/package.json +4 -2
  13. package/src/domain/errors/Codes.js +39 -0
  14. package/src/domain/helpers/assertCanonicalTimestamp.js +15 -0
  15. package/src/domain/helpers/handleTarget.js +48 -0
  16. package/src/domain/helpers/isCanonicalCollectionKey.js +35 -0
  17. package/src/domain/services/AssetService.js +213 -0
  18. package/src/domain/services/BundleDescriptorCodec.js +286 -0
  19. package/src/domain/services/BundleFanoutBuilder.js +247 -0
  20. package/src/domain/services/BundleService.js +848 -0
  21. package/src/domain/services/CacheAcquisitionInventory.js +123 -0
  22. package/src/domain/services/CacheAcquisitionRegistry.js +188 -0
  23. package/src/domain/services/CacheCandidateHeap.js +71 -0
  24. package/src/domain/services/CacheIndex.js +362 -0
  25. package/src/domain/services/CacheMetadataCodec.js +164 -0
  26. package/src/domain/services/CachePolicyEnforcer.js +144 -0
  27. package/src/domain/services/CacheSet.js +754 -0
  28. package/src/domain/services/CacheSetRegistry.js +95 -0
  29. package/src/domain/services/CasService.d.ts +2 -1
  30. package/src/domain/services/ExpiringSet.js +496 -0
  31. package/src/domain/services/ExpiringSetIndex.js +254 -0
  32. package/src/domain/services/ExpiringSetMetadataCodec.js +160 -0
  33. package/src/domain/services/ExpiringSetRegistry.js +101 -0
  34. package/src/domain/services/PageService.js +175 -0
  35. package/src/domain/services/PublicationService.js +315 -0
  36. package/src/domain/services/RepositoryDoctor.js +676 -0
  37. package/src/domain/services/RetentionService.js +120 -0
  38. package/src/domain/services/RootSet.js +10 -6
  39. package/src/domain/services/RootSetMetadataCodec.js +8 -2
  40. package/src/domain/services/RootSetPersistence.js +3 -2
  41. package/src/domain/services/StagingEvidence.js +39 -0
  42. package/src/domain/value-objects/ApplicationHandle.js +40 -0
  43. package/src/domain/value-objects/AssetHandle.js +163 -0
  44. package/src/domain/value-objects/BundleHandle.js +32 -0
  45. package/src/domain/value-objects/BundleLimits.js +80 -0
  46. package/src/domain/value-objects/BundlePath.js +78 -0
  47. package/src/domain/value-objects/CacheAcquisition.js +88 -0
  48. package/src/domain/value-objects/CacheAcquisitionRef.js +129 -0
  49. package/src/domain/value-objects/CacheHit.js +93 -0
  50. package/src/domain/value-objects/CacheKey.js +32 -0
  51. package/src/domain/value-objects/CachePolicy.js +59 -0
  52. package/src/domain/value-objects/CacheSetRef.js +40 -0
  53. package/src/domain/value-objects/CollectionNamespace.js +54 -0
  54. package/src/domain/value-objects/ExpiringMarker.js +81 -0
  55. package/src/domain/value-objects/ExpiringSetKey.js +28 -0
  56. package/src/domain/value-objects/ExpiringSetRef.js +42 -0
  57. package/src/domain/value-objects/OpaqueHandle.js +171 -0
  58. package/src/domain/value-objects/PageHandle.js +34 -0
  59. package/src/domain/value-objects/RetentionWitness.js +106 -0
  60. package/src/domain/value-objects/StagedAsset.js +63 -0
  61. package/src/domain/value-objects/StagedBundle.js +66 -0
  62. package/src/domain/value-objects/StagedPage.js +47 -0
  63. package/src/infrastructure/adapters/GitPersistenceAdapter.js +48 -20
  64. package/src/infrastructure/adapters/GitRefAdapter.js +318 -7
  65. package/src/infrastructure/adapters/GitRepositoryInspectionAdapter.js +182 -0
  66. package/src/package-version.js +1 -1
  67. package/src/ports/GitPersistencePort.js +11 -1
  68. package/src/ports/GitRefPort.js +46 -0
  69. package/src/ports/RepositoryInspectionPort.js +36 -0
@@ -0,0 +1,131 @@
1
+ # git-cas v6.2.0 Release Notes
2
+
3
+ `v6.2.0` makes `git-cas` the storage and cache lifecycle owner for application
4
+ packages. Applications can define domain keys, payload schemas, causal
5
+ publication rules, and retention intent without constructing Git trees,
6
+ persisting naked object IDs, or maintaining a second cache protocol.
7
+
8
+ ## The Contract
9
+
10
+ > A handle is not a durability claim.
11
+
12
+ `cas.assets`, `cas.pages`, and `cas.bundles` return immutable opaque handles.
13
+ The staged result explicitly reports that no root was created. A caller then
14
+ chooses how the handle graph should live:
15
+
16
+ | Policy surface | Intended lifecycle | Git reachability behavior |
17
+ | --- | --- | --- |
18
+ | `cas.retention` / RootSet | Caller-managed current set | Anchored while present |
19
+ | `cas.caches` | TTL/capacity/approximate-LRU cache | Anchored until managed eviction |
20
+ | `cas.expiringSets` | Security replay window | Anchored until expiry; no early eviction |
21
+ | `cas.publications` | Application causal history | Anchored by the allowlisted application ref |
22
+ | Vault | History-preserving named assets | Anchored by `refs/cas/vault` history |
23
+
24
+ Successful retention and publication operations return a `RetentionWitness`
25
+ that identifies the exact ref generation and tree edge that established
26
+ reachability.
27
+
28
+ ## Application Storage
29
+
30
+ ```javascript
31
+ const staged = await cas.assets.put({
32
+ source,
33
+ slug: 'warp/materialization',
34
+ filename: 'materialization.bin',
35
+ });
36
+
37
+ const retained = await cas.retention.retain({
38
+ handle: staged.handle,
39
+ root: {
40
+ ref: 'refs/cas/rootsets/git-warp/materializations',
41
+ name: materializationKey,
42
+ },
43
+ policy: 'evictable',
44
+ });
45
+
46
+ console.log(retained.witness.root.generation);
47
+ ```
48
+
49
+ - Asset writes stream through the existing chunking, deduplication,
50
+ compression, encryption, manifest, and tree pipeline.
51
+ - Pages store bounded immutable blobs and expose targeted streams.
52
+ - Bundles build deterministic bounded-fanout trees from named streams or
53
+ nested handles.
54
+ - `bundles.iterateMembers()` streams descriptors, while `getMember()` and
55
+ `openMember()` traverse only the requested descriptor path and payload.
56
+ - `cas.publications.commit()` validates an entire handle graph, ordered commit
57
+ parents, an explicit ref allowlist, and expected-head compare-and-swap state
58
+ before changing a ref.
59
+
60
+ Handles contain no repository path and support canonical SHA-1 and SHA-256
61
+ object IDs. Importing a handle validates that its graph exists and has the
62
+ expected Git object and codec shape.
63
+
64
+ ## Managed Cache And Replay Lifecycles
65
+
66
+ `cas.caches.open()` owns immutable cache indexes under `refs/cas/caches/*`.
67
+ CacheSet handles TTL, entry and logical-byte limits, approximate-LRU sweeps,
68
+ coalesced touches, retention witnesses, bounded inspection, doctor, and repair.
69
+ A cache miss is read-only.
70
+
71
+ `cas.expiringSets.open()` owns digest-only replay markers under
72
+ `refs/cas/expiring/*`. `addIfAbsent()` is atomic across writers, `contains()` is
73
+ read-only, and `sweep()` can release only entries whose expiry has passed. The
74
+ surface intentionally has no remove, repair, capacity, or recency eviction
75
+ operation that could shorten a security acceptance window.
76
+
77
+ Both services publish parentless current-generation commits. Superseded
78
+ generations do not remain reachable through their own storage history.
79
+
80
+ ## Repository Diagnostics
81
+
82
+ ```javascript
83
+ const report = await cas.diagnostics.doctor({
84
+ gracePeriodMs: 14 * 24 * 60 * 60 * 1000,
85
+ });
86
+ ```
87
+
88
+ The report streams Git object, ref, and reflog-reachability inventories;
89
+ classifies anchored, orphaned, grace-expired volatile, and total unreachable
90
+ objects; and summarizes CacheSet, RootSet, ExpiringSet, and Vault usage. It
91
+ fails closed if concurrent writes make derived arithmetic inconsistent.
92
+
93
+ Diagnostics use plumbing's exact prune dry-run contract for volatile objects.
94
+ The doctor does not run `git gc` or destructive prune and exposes no object or
95
+ ref mutation operation. Shared deduplicated bytes, packed-object age, reflog
96
+ entry count, alternate-store attribution, and pack metadata overhead remain
97
+ explicitly reported limitations rather than guessed values.
98
+
99
+ ## Compatibility And Upgrade
100
+
101
+ This release is API-additive. Existing CAS manifests, RootSets, Vaults, refs,
102
+ and low-level `createTree()` callers remain compatible; no stored-data
103
+ migration is required. Repository diagnostics require
104
+ `@git-stunts/plumbing` 3.1.0 or newer.
105
+
106
+ Applications that currently store tree or blob IDs only in JSON should adopt
107
+ every still-live object into a RootSet or rebuild it through the matching
108
+ high-level capability before destructive Git cleanup. An object that Git
109
+ already pruned cannot be recovered by doctor or repair.
110
+
111
+ See [UPGRADING.md](../../UPGRADING.md) for the adoption sequence,
112
+ [Application Storage](../API.md#application-storage) for API contracts, and
113
+ [Repository Diagnostics](../API.md#repository-diagnostics) for report fields
114
+ and limitations.
115
+
116
+ ## Verification
117
+
118
+ `pnpm run release:verify` passed 13/13 steps with 6,124 observed tests:
119
+
120
+ | Suite | Tests |
121
+ | --- | ---: |
122
+ | Node unit | 1,871 |
123
+ | Bun unit | 1,870 |
124
+ | Deno unit | 1,861 |
125
+ | Node integration | 174 |
126
+ | Bun integration | 174 |
127
+ | Deno integration | 174 |
128
+
129
+ The same run passed ESLint, all three runnable examples, build metadata
130
+ stamping, npm package-content inspection, and a JSR publish dry-run. GitHub CI,
131
+ self-review, and Code Lawyer review remain mandatory before tagging.
@@ -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.