@git-stunts/git-cas 5.3.2 → 6.0.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 (173) hide show
  1. package/ADVANCED_GUIDE.md +1006 -0
  2. package/ARCHITECTURE.md +514 -0
  3. package/CHANGELOG.md +393 -5
  4. package/CODE_OF_CONDUCT.md +33 -0
  5. package/GUIDE.md +872 -0
  6. package/README.md +219 -325
  7. package/SECURITY.md +993 -0
  8. package/SUPPORT.md +54 -0
  9. package/UPGRADING.md +299 -0
  10. package/bin/actions.js +70 -21
  11. package/bin/agent/cli.js +51 -0
  12. package/bin/agent/commands/doctor.js +99 -0
  13. package/bin/agent/commands/index.js +1489 -0
  14. package/bin/agent/input.js +619 -0
  15. package/bin/agent/passphrase-source.js +123 -0
  16. package/bin/agent/protocol.js +193 -0
  17. package/bin/build-version.js +64 -0
  18. package/bin/credentials.js +425 -0
  19. package/bin/git-cas.js +595 -449
  20. package/bin/passphrase-source.js +266 -0
  21. package/bin/restore-output-target.js +28 -0
  22. package/bin/ui/blocks/asset-card.js +109 -0
  23. package/bin/ui/blocks/health-dashboard.js +149 -0
  24. package/bin/ui/blocks/heatmap-block.js +67 -0
  25. package/bin/ui/blocks/merkle-explorer.js +163 -0
  26. package/bin/ui/blocks/operation-feed.js +176 -0
  27. package/bin/ui/blocks/wizard-block.js +168 -0
  28. package/bin/ui/components/short-sha.js +36 -0
  29. package/bin/ui/context.js +56 -1
  30. package/bin/ui/dashboard-cmds.js +1578 -13
  31. package/bin/ui/dashboard-view.js +612 -145
  32. package/bin/ui/dashboard.js +998 -214
  33. package/bin/ui/encryption-card.js +69 -26
  34. package/bin/ui/heatmap.js +26 -54
  35. package/bin/ui/history-timeline.js +51 -19
  36. package/bin/ui/manifest-view.js +115 -60
  37. package/bin/ui/merkle-dag.js +83 -0
  38. package/bin/ui/progress.js +15 -9
  39. package/bin/ui/repo-treemap.js +328 -0
  40. package/bin/ui/shaders/bak-sneppen.js +180 -0
  41. package/bin/ui/shaders/fractal-zoom.js +99 -0
  42. package/bin/ui/shaders/merkle-tree.js +142 -0
  43. package/bin/ui/shaders/organic-flow.js +96 -0
  44. package/bin/ui/shaders/phase-portrait.js +93 -0
  45. package/bin/ui/store-wizard.js +296 -0
  46. package/bin/ui/theme.js +155 -0
  47. package/bin/ui/vault-report.js +495 -0
  48. package/build-info.json +4 -0
  49. package/docs/API.md +2224 -0
  50. package/docs/ENCRYPTION_MODES.md +33 -0
  51. package/docs/EXTENDING.md +174 -0
  52. package/docs/STORE_RESTORE_PIPELINE.md +199 -0
  53. package/docs/THREAT_MODEL.md +269 -0
  54. package/docs/VAULT_INTERNALS.md +251 -0
  55. package/docs/WALKTHROUGH.md +1868 -0
  56. package/docs/demo.gif +0 -0
  57. package/docs/releases/v6.0.0.md +104 -0
  58. package/examples/README.md +260 -0
  59. package/index.d.ts +208 -65
  60. package/index.js +163 -54
  61. package/package.json +35 -6
  62. package/scripts/migrate-encryption.js +680 -0
  63. package/src/domain/bytes/ByteLayout.js +96 -0
  64. package/src/domain/encoding/base64.js +91 -0
  65. package/src/domain/encoding/hex.js +14 -0
  66. package/src/domain/encoding/utf8.js +123 -0
  67. package/src/domain/encryption/schemes.js +132 -0
  68. package/src/domain/errors/CannotRemoveLastRecipientError.js +10 -0
  69. package/src/domain/errors/CasError.d.ts +28 -0
  70. package/src/domain/errors/CasError.js +43 -6
  71. package/src/domain/errors/Codes.js +54 -0
  72. package/src/domain/errors/DekUnwrapFailedError.js +10 -0
  73. package/src/domain/errors/GitError.js +10 -0
  74. package/src/domain/errors/GitPlumbingInitializationError.js +10 -0
  75. package/src/domain/errors/IntegrityError.js +10 -0
  76. package/src/domain/errors/InvalidChunkingStrategyError.js +10 -0
  77. package/src/domain/errors/InvalidOidError.js +10 -0
  78. package/src/domain/errors/InvalidOptionsError.js +10 -0
  79. package/src/domain/errors/ManifestIntegrityError.js +10 -0
  80. package/src/domain/errors/ManifestNotFoundError.js +10 -0
  81. package/src/domain/errors/NoMatchingRecipientError.js +10 -0
  82. package/src/domain/errors/PersistenceCapabilityRequiredError.js +10 -0
  83. package/src/domain/errors/PortNotImplementedError.js +10 -0
  84. package/src/domain/errors/RecipientAlreadyExistsError.js +10 -0
  85. package/src/domain/errors/RecipientNotFoundError.js +10 -0
  86. package/src/domain/errors/RestoreTooLargeError.js +10 -0
  87. package/src/domain/errors/RotationNotSupportedError.js +10 -0
  88. package/src/domain/errors/createCasError.js +68 -0
  89. package/src/domain/errors/index.js +20 -0
  90. package/src/domain/helpers/buildKdfMetadata.js +4 -2
  91. package/src/domain/helpers/codecBytes.js +34 -0
  92. package/src/domain/helpers/gitRefErrors.js +84 -0
  93. package/src/domain/helpers/scryptMaxmem.js +22 -0
  94. package/src/domain/outcomes/RestoreFailure.js +15 -0
  95. package/src/domain/outcomes/RestoreOutcome.js +11 -0
  96. package/src/domain/outcomes/RestoreSuccess.js +34 -0
  97. package/src/domain/outcomes/StoreFailure.js +15 -0
  98. package/src/domain/outcomes/StoreOutcome.js +11 -0
  99. package/src/domain/outcomes/StoreSuccess.js +17 -0
  100. package/src/domain/schemas/ManifestSchema.d.ts +40 -9
  101. package/src/domain/schemas/ManifestSchema.js +67 -13
  102. package/src/domain/services/CasService.d.ts +123 -38
  103. package/src/domain/services/CasService.js +298 -834
  104. package/src/domain/services/ChunkRepository.js +230 -0
  105. package/src/domain/services/CompressionStreams.js +72 -0
  106. package/src/domain/services/ConvergentEncryption.js +128 -0
  107. package/src/domain/services/GitTreeBuilder.js +86 -0
  108. package/src/domain/services/IntegrityVerifier.js +199 -0
  109. package/src/domain/services/KeyResolver.js +49 -42
  110. package/src/domain/services/ManifestDiff.js +56 -0
  111. package/src/domain/services/ManifestRepository.js +286 -0
  112. package/src/domain/services/PrefetchWindow.js +48 -0
  113. package/src/domain/services/RecipientService.js +157 -0
  114. package/src/domain/services/RedactingObservability.js +169 -0
  115. package/src/domain/services/RestorePipeline.js +68 -0
  116. package/src/domain/services/StorePipeline.js +201 -0
  117. package/src/domain/services/VaultKeyVerifier.js +101 -0
  118. package/src/domain/services/VaultMetadataCodec.js +206 -0
  119. package/src/domain/services/VaultMutationRetryPolicy.js +105 -0
  120. package/src/domain/services/VaultPersistence.js +410 -0
  121. package/src/domain/services/VaultPrivacyIndex.js +191 -0
  122. package/src/domain/services/VaultService.js +749 -251
  123. package/src/domain/services/VaultStateCache.js +225 -0
  124. package/src/domain/services/VaultTreeCodec.js +121 -0
  125. package/src/domain/services/rotateVaultPassphrase.js +37 -20
  126. package/src/domain/strategies/Aad.js +39 -0
  127. package/src/domain/strategies/FramedRecordCodec.js +204 -0
  128. package/src/domain/strategies/RestoreCompressed.js +40 -0
  129. package/src/domain/strategies/RestoreConvergent.js +44 -0
  130. package/src/domain/strategies/RestoreFramed.js +55 -0
  131. package/src/domain/strategies/RestorePlain.js +37 -0
  132. package/src/domain/strategies/RestoreStrategy.js +35 -0
  133. package/src/domain/strategies/RestoreWhole.js +135 -0
  134. package/src/domain/strategies/StoreConvergent.js +28 -0
  135. package/src/domain/strategies/StoreFramed.js +39 -0
  136. package/src/domain/strategies/StorePlain.js +20 -0
  137. package/src/domain/strategies/StoreStrategy.js +61 -0
  138. package/src/domain/strategies/StoreWhole.js +34 -0
  139. package/src/domain/value-objects/Chunk.js +1 -2
  140. package/src/domain/value-objects/EncryptionMetadata.js +87 -0
  141. package/src/domain/value-objects/Manifest.d.ts +40 -4
  142. package/src/domain/value-objects/Manifest.js +61 -20
  143. package/src/domain/value-objects/Oid.js +45 -0
  144. package/src/domain/value-objects/Slug.js +124 -0
  145. package/src/domain/value-objects/StoreEncryptionConfig.js +114 -0
  146. package/src/helpers/aesGcmMeta.js +55 -0
  147. package/src/helpers/canonicalBase64.js +1 -0
  148. package/src/helpers/kdfPolicy.js +194 -0
  149. package/src/infrastructure/adapters/BunCryptoAdapter.js +124 -8
  150. package/src/infrastructure/adapters/FileIOHelper.js +178 -13
  151. package/src/infrastructure/adapters/GitPersistenceAdapter.js +235 -42
  152. package/src/infrastructure/adapters/GitPlumbingFactoryAdapter.js +62 -0
  153. package/src/infrastructure/adapters/GitRefAdapter.js +19 -6
  154. package/src/infrastructure/adapters/NodeCompressionAdapter.js +64 -0
  155. package/src/infrastructure/adapters/NodeCryptoAdapter.js +130 -10
  156. package/src/infrastructure/adapters/WebCryptoAdapter.js +187 -77
  157. package/src/infrastructure/chunkers/CdcChunker.js +53 -19
  158. package/src/infrastructure/chunkers/FixedChunker.js +15 -7
  159. package/src/infrastructure/chunkers/resolveChunker.js +3 -1
  160. package/src/infrastructure/codecs/CborCodec.js +3 -3
  161. package/src/infrastructure/codecs/JsonCodec.js +5 -5
  162. package/src/infrastructure/createGitPlumbing.js +22 -0
  163. package/src/package-version.js +1 -0
  164. package/src/ports/ChunkingPort.js +3 -3
  165. package/src/ports/CodecPort.js +4 -4
  166. package/src/ports/CompressionPort.js +57 -0
  167. package/src/ports/CryptoPort.js +138 -50
  168. package/src/ports/GitPersistencePort.js +32 -2
  169. package/src/ports/GitPlumbingFactoryPort.js +16 -0
  170. package/src/ports/GitRefPort.js +1 -1
  171. package/src/types/ambient.d.ts +10 -5
  172. package/test/CONVENTIONS.md +94 -0
  173. package/test/cycles/README.md +13 -0
package/README.md CHANGED
@@ -1,398 +1,292 @@
1
- # @git-stunts/git-cas
1
+ # git-cas
2
2
 
3
- <img width="420" alt="git-cas" src="https://github.com/user-attachments/assets/e7cb63b9-25b7-4369-b053-4a35962ccee4" />
3
+ > Modern open-source systems still rely on centralized infrastructure to distribute binary artifacts, even when their source code is fully decentralized. This creates a fragile dependency: if hosting endpoints are blocked, degraded, or removed, critical artifacts become unavailable or unverifiable.
4
+ >
5
+ > `git-cas` addresses this by making artifact distribution inherit Git’s existing replication model, allowing binaries to be stored, verified, and transported anywhere Git can operate, including mirrored networks, constrained environments, or fully offline contexts.
4
6
 
5
- ## JESSIE, STOP—
7
+ `git-cas` 6.0.0 is an industrial-grade Content-Addressable Storage (CAS) engine backed by Git’s object database. Its Security First posture makes explicit restore boundaries, bounded metadata reads, authenticated encryption, and legacy-scheme rejection the default. Stored content is chunked, deduplicated, and optionally encrypted — keeping high-fidelity assets and security-sensitive files directly within your repository history.
6
8
 
7
- > Hold on. He’s turning Git into a blob store. Let him cook.
9
+ `git-cas` is designed for the architect who demands mathematical certainty and the operator who needs a stable foundation for artifact storage. It scales from simple binary blob management to multi-recipient envelope-encrypted vaults with key rotation, privacy-mode slug hashing, and Merkle-style manifests for assets of any size.
8
10
 
9
- **Most potent clone available on GitHub (legally).**
11
+ [![npm version](https://img.shields.io/npm/v/@git-stunts/git-cas)](https://www.npmjs.com/package/@git-stunts/git-cas)
12
+ [![License](https://img.shields.io/github/license/git-stunts/git-cas)](./LICENSE)
10
13
 
11
- ### Git, freebased: pure CAS that’ll knock your SHAs off. LFS hates this repo.
14
+ ![git-cas demo](./docs/demo.gif)
12
15
 
13
- Git isn’t source control.
14
- Git is a content-addressed object database.
15
- We use the object database.
16
+ ## Why git-cas?
16
17
 
17
- `git-cas` chunks files into Git blobs (dedupe for free), optionally encrypts them, and emits a manifest + a real Git tree so you can commit/tag/ref it like any other artifact.
18
+ Unlike traditional LFS which moves files to external servers, `git-cas` treats the Git object database as a first-class storage substrate.
18
19
 
19
- ## What you get
20
+ - **Deduplication by Default**: Content-defined chunking (CDC) with Buzhash rolling hash identifies repeated patterns across files and versions, minimizing repository growth.
21
+ - **Cryptographic Trust**: Every chunk is verified against a SHA-256 digest. Optional AES-256-GCM encryption with multi-recipient envelope support ensures privacy at rest, and `framed` binds per-frame AAD to prevent cross-manifest blob swaps.
22
+ - **GC-Safe Vault**: Named assets are indexed through a stable ref (`refs/cas/vault`) with optimistic concurrency, preventing Git garbage collection from reclaiming referenced blobs.
23
+ - **Key Lifecycle**: Envelope encryption separates DEKs from KEKs. Rotate passphrases across an entire vault without re-encrypting data blobs. Privacy mode HMAC-hashes slug names to prevent metadata discovery.
24
+ - **Runtime-Adaptive**: A single core supports Node.js 22+, Bun, and Deno through a strict hexagonal port architecture with runtime-specific crypto adapters.
20
25
 
21
- - **Dedupe for free** Git already hashes objects. We just lean into it.
22
- - **Chunked storage** big files become stable, reusable blobs. Fixed-size or content-defined chunking (CDC).
23
- - **Optional AES-256-GCM encryption** store secrets without leaking plaintext into the ODB.
24
- - **Multi-recipient encryption** envelope model (DEK/KEK) — add/remove access without re-encrypting data.
25
- - **Key rotation** rotate keys without re-encrypting data blobs. Respond to compromise in seconds.
26
- - **Compression** gzip before encryption — smaller blobs, same round-trip.
27
- - **Passphrase encryption** derive keys from passphrases via PBKDF2 or scrypt — no raw key management.
28
- - **Merkle manifests** large files auto-split into sub-manifests for scalability.
29
- - **Manifests** a tiny explicit index of chunks + metadata (JSON/CBOR).
30
- - **Tree output** generates standard Git trees so assets snap into commits cleanly.
31
- - **Full round-trip** store, tree, and restore — get your bytes back, verified.
32
- - **Lifecycle management** `readManifest`, `inspectAsset`, `collectReferencedChunks` — inspect trees, plan deletions, audit storage.
33
- - **Vault** GC-safe ref-based storage. One ref (`refs/cas/vault`) indexes all assets by slug. No more silent data loss from `git gc`.
34
- - **Interactive dashboard** `git cas inspect` with chunk heatmap, animated progress bars, and rich manifest views.
35
- - **Verify & JSON output** `git cas verify` checks integrity; `--json` on all current human-facing commands provides convenient structured output for CI/scripting.
26
+ ## Quick Start
36
27
 
37
- **Use it for:** binary assets, build artifacts, model weights, data packs, secret bundles, weird experiments, etc.
28
+ Existing v5 users should read [UPGRADING.md](./UPGRADING.md) and run
29
+ `npm run upgrade` in dry-run mode before restoring old encrypted vault entries.
30
+ For the release overview, see the
31
+ [v6.0.0 Release Notes](./docs/releases/v6.0.0.md).
38
32
 
39
- <img src="./docs/demo.gif" alt="git-cas demo" />
33
+ ### 1. CLI Usage
40
34
 
41
- ## What's new in v5.3.1
42
-
43
- **Patch release — repeated chunk tree fix.**
44
-
45
- - **Unique chunk tree entries** — `createTree()` and `_createMerkleTree()` now emit one tree entry per unique chunk digest instead of repeating the same filename for repeated chunk occurrences.
46
- - **Manifest remains authoritative** — chunk order and multiplicity still come entirely from the manifest; restore behavior is unchanged.
47
- - **Clean `git fsck` on repetitive files** — repetitive content no longer yields duplicate tree filenames or `duplicateEntries` errors.
48
- - **New regressions** — unit and integration coverage now exercises repeated-chunk files and validates real Git tree integrity with `git fsck --full`.
49
-
50
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
51
-
52
- ## What's new in v5.3.0
53
-
54
- **M16 Capstone — audit remediation, CLI configuration, and security hardening.**
55
-
56
- - **`.casrc` config file** — JSON config at repo root sets defaults for all CLI flags (chunk size, strategy, concurrency, codec, compression, CDC params).
57
- - **CLI store/restore flags** — all library-level options now accessible from the command line: `--gzip`, `--strategy`, `--chunk-size`, `--concurrency`, `--codec`, `--merkle-threshold`, and CDC-specific flags.
58
- - **Passphrase-file support** — `--vault-passphrase-file <path>` on store, restore, and vault rotate (use `-` for stdin).
59
- - **Memory restore guard** — `maxRestoreBufferSize` (default 512 MiB) prevents unbounded memory allocation on encrypted/compressed restore.
60
- - **Web Crypto encryption buffer guard** — `maxEncryptionBufferSize` (default 512 MiB) for the one-shot AES-GCM API.
61
- - **Orphaned blob tracking** — `STREAM_ERROR` now includes `meta.orphanedBlobs` for cleanup after partial store failures.
62
- - **KDF brute-force awareness** — `decryption_failed` metric + CLI rate-limiting delay on `INTEGRITY_ERROR`.
63
- - **Encryption counter** — vault metadata tracks `encryptionCount` with observability warning near GCM nonce bound.
64
- - **Lifecycle method rename** — `inspectAsset()` / `collectReferencedChunks()` replace `deleteAsset()` / `findOrphanedChunks()` (old names preserved as deprecated aliases).
65
- - **FixedChunker O(n²) fix** — pre-allocated buffer replaces `Buffer.concat()` loop.
66
- - **Chunk size upper bound** — 100 MiB max enforced across all chunkers.
67
- - **Constructor validation** — `chunkSize`, `maxRestoreBufferSize`, `maxEncryptionBufferSize` validated at construction time.
68
- - **Cross-runtime portability** — `Error.captureStackTrace` guarded, crypto adapter contracts normalized.
69
-
70
- ## What's new in v5.2.3
71
-
72
- **Internal refactoring — no breaking API changes.** The facade, CasService, and crypto adapters were restructured for better separation of concerns:
73
-
74
- - **Consistent async `sha256()`** — `NodeCryptoAdapter.sha256()` now returns `Promise<string>` like Bun and Web adapters, fixing a Liskov Substitution violation.
75
- - **`KeyResolver` extracted** — ~170 lines of key resolution logic (DEK wrap/unwrap, passphrase derivation, envelope recipients) moved from CasService (1085 → 909 lines) into a dedicated `KeyResolver` service.
76
- - **Facade decomposed** — `createCryptoAdapter`, `resolveChunker`, `FileIOHelper`, `rotateVaultPassphrase`, and `buildKdfMetadata` extracted from the monolithic `index.js` into focused modules.
77
- - **Barrel re-exports** — 10 re-export-only modules converted to `export { default as X } from '...'` form.
78
-
79
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
80
-
81
- ## What's new in v5.2.1
82
-
83
- Bug fix: `rotateVaultPassphrase` now honours `kdfOptions.algorithm` — previously the `--algorithm` flag was silently ignored, always reusing the old KDF algorithm. CLI flag tables in `docs/API.md` are now split per command with `--cwd` documented.
84
-
85
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
86
-
87
- ## What's new in v5.2.0
88
-
89
- **Key rotation without re-encrypting data** — Rotate a recipient's key by re-wrapping the DEK. Data blobs are never touched. Respond to key compromise in seconds, not hours.
90
-
91
- ```js
92
- // Rotate a single recipient's key
93
- const rotated = await cas.rotateKey({
94
- manifest, oldKey: aliceOldKey, newKey: aliceNewKey, label: 'alice',
95
- });
96
-
97
- // Rotate the vault passphrase (all entries, atomic commit)
98
- const { commitOid, rotatedSlugs, skippedSlugs } = await cas.rotateVaultPassphrase({
99
- oldPassphrase: 'old-secret', newPassphrase: 'new-secret',
100
- });
101
- ```
35
+ Initialize a vault and store your first asset.
102
36
 
103
37
  ```bash
104
- # Rotate a recipient key
105
- git cas rotate --slug prod-secrets --old-key-file old.key --new-key-file new.key
106
-
107
- # Rotate vault passphrase
108
- git cas vault rotate --old-passphrase old-secret --new-passphrase new-secret
38
+ git init
39
+ git-cas vault init
40
+ git-cas store data.bin --slug assets/v1 --tree
41
+ git-cas restore --slug assets/v1 --out data-restored.bin
109
42
  ```
110
43
 
111
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
112
-
113
- ## What's new in v5.1.0
114
-
115
- **Multi-recipient envelope encryption** — Each file is encrypted with a random DEK; recipient KEKs wrap the DEK. Add or remove team members without re-encrypting data.
44
+ ### 2. TUI Cockpit
116
45
 
117
- ```js
118
- // API: store for multiple recipients
119
- const manifest = await cas.storeFile({
120
- filePath: './secrets.tar.gz',
121
- slug: 'prod-secrets',
122
- recipients: [
123
- { label: 'alice', key: aliceKey },
124
- { label: 'bob', key: bobKey },
125
- ],
126
- });
127
-
128
- // Add a recipient later (no re-encryption)
129
- const updated = await cas.addRecipient({
130
- manifest, existingKey: aliceKey, newRecipientKey: carolKey, label: 'carol',
131
- });
132
-
133
- // List / remove recipients
134
- const labels = await cas.listRecipients({ manifest });
135
- const trimmed = await cas.removeRecipient({ manifest, label: 'bob' });
136
- ```
46
+ Navigate your stored assets through the reader-first interactive dashboard.
137
47
 
138
48
  ```bash
139
- # CLI: store with multiple recipients
140
- git cas store ./secrets.tar.gz --slug prod-secrets \
141
- --recipient alice:./keys/alice.key \
142
- --recipient bob:./keys/bob.key --tree
143
-
144
- # Manage recipients
145
- git cas recipient list prod-secrets
146
- git cas recipient add prod-secrets --label carol --key-file ./keys/carol.key --existing-key-file ./keys/alice.key
147
- git cas recipient remove prod-secrets --label bob
49
+ git-cas vault dashboard
148
50
  ```
149
51
 
150
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
52
+ ### 3. Library Ingress
151
53
 
152
- ## What's new in v5.0.0
153
-
154
- **Content-defined chunking (CDC)** — Fixed-size chunking invalidates every chunk after an edit. CDC uses a buzhash rolling hash to find natural boundaries, limiting the blast radius to 1–2 chunks. Benchmarked at 98.4% chunk reuse on small edits vs 32% for fixed.
54
+ Integrate managed blob storage directly into your TypeScript or JavaScript application.
155
55
 
156
56
  ```js
157
- const cas = new ContentAddressableStore({
158
- plumbing,
159
- chunking: { strategy: 'cdc', targetChunkSize: 262144, minChunkSize: 65536, maxChunkSize: 1048576 },
160
- });
57
+ import ContentAddressableStore from '@git-stunts/git-cas';
58
+ const cas = await ContentAddressableStore.open({ cwd: '.' });
59
+ const manifest = await cas.storeFile({ filePath: './asset.bin', slug: 'app/asset' });
161
60
  ```
162
61
 
163
- **`ChunkingPort`** — new hexagonal port abstracts chunking strategy. `FixedChunker` and `CdcChunker` adapters ship out of the box. Bring your own chunker by extending `ChunkingPort`.
62
+ ## Feature Overview
164
63
 
165
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
64
+ ### Content-Addressed Storage
166
65
 
167
- ## What's new in v4.0.1
66
+ Every piece of stored content is broken into chunks and addressed by its SHA-256 digest. Identical content always produces the same address, giving you deduplication for free. Manifests record the ordered list of chunk digests so content can be reassembled faithfully, and every chunk is integrity-verified on read. New manifests are stamped with a `formatVersion` (semver from package.json) for forward-compatible schema evolution.
168
67
 
169
- **`git cas verify`** — verify stored asset integrity from the CLI without restoring (`git cas verify --slug my-asset`).
68
+ ### Chunking
170
69
 
171
- **`--json` everywhere** — all commands now support `--json` for structured output. Pipe `git cas vault list --json | jq` in CI.
70
+ Two chunking strategies are available, both with configurable size parameters:
172
71
 
173
- **CryptoPort base class** — shared key validation, metadata building, and KDF normalization. All three adapters (Node/Bun/Web) inherit from a single source of truth.
72
+ | Strategy | Algorithm | Default Target | Behavior |
73
+ |---|---|---|---|
74
+ | **Fixed-size** | Static split | 256 KiB | Deterministic, predictable chunk boundaries |
75
+ | **Content-Defined (CDC)** | Buzhash rolling hash | Configurable target/min/max | Shift-resistant boundaries that survive insertions and deletions |
174
76
 
175
- **Centralized error handling** — `runAction` wrapper with CasError codes and actionable hints (e.g., "Provide --key-file or --vault-passphrase").
77
+ CDC is the default for deduplication workloads. **FastCDC dual-mask normalization** is enabled by default, producing a tighter chunk-size distribution around the target size. Target, minimum, and maximum chunk sizes are all configurable.
176
78
 
177
- **Vault list filtering** — `git cas vault list --filter "photos/*"` with TTY-aware table formatting.
79
+ ### Encryption
178
80
 
179
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
81
+ Encryption uses **AES-256-GCM** with 16-byte authentication tags. `whole` and
82
+ `framed` use fresh random 96-bit nonces; `convergent` derives per-chunk keys
83
+ and nonces deterministically from the plaintext content hash to preserve
84
+ deduplication.
180
85
 
181
- ## What's new in v4.0.0
86
+ Three encryption schemes are supported:
182
87
 
183
- **ObservabilityPort** — `CasService` no longer extends `EventEmitter`. A new hexagonal `ObservabilityPort` decouples the domain from Node's event infrastructure. Three adapters ship out of the box: `SilentObserver` (no-op default), `EventEmitterObserver` (backward-compatible event bridge), and `StatsCollector` (metric accumulator).
88
+ | Scheme | Framing | AAD Binding | Notes |
89
+ |---|---|---|---|
90
+ | `whole` | Single ciphertext blob | Slug | AAD always bound to prevent cross-manifest blob swaps |
91
+ | `framed` | Bounded frames | Slug + frame index | Default for fixed-chunk encrypted stores — streaming decrypt with per-frame AAD binding |
92
+ | `convergent` | Per-chunk deterministic | Derived from content hash | **Default for CDC + encryption** — preserves deduplication across encrypted stores. Implemented as a standalone `ConvergentEncryption` service. |
184
93
 
185
- **Streaming restore** — `restoreStream()` returns an `AsyncIterable<Buffer>` with O(chunkSize) memory for unencrypted files. `restoreFile()` now writes via `createWriteStream` + `pipeline` instead of buffering.
94
+ See [Encryption Modes](./docs/ENCRYPTION_MODES.md) for scheme selection guidance.
186
95
 
187
- **Parallel chunk I/O** — new `concurrency` option gates store writes and restore reads through a counting semaphore. `concurrency: 4` can significantly speed up large-file operations.
96
+ Legacy schemes (`whole-v1`, `whole-v2`, `framed-v1`, `framed-v2`, `convergent-v1`) are no longer accepted and throw a `LEGACY_SCHEME` error. Run `npm run upgrade` (or `node scripts/migrate-encryption.js`) to migrate existing vault entries. The script auto-detects whether each entry needs a rename-only (fast) or full re-encryption (v1 schemes without AAD), accepts `--passphrase-file`, `--key-file`, or warning-emitting inline `--passphrase` for full migrations, supports privacy-vault key options, and defaults to dry-run mode.
188
97
 
189
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
98
+ **Envelope encryption** wraps a random Data Encryption Key (DEK) with one or more Key Encryption Keys (KEKs). Each recipient is labeled, enabling multi-recipient access to the same encrypted content. Key rotation replaces the KEK wrapping without re-encrypting data blobs.
190
99
 
191
- ## What's new in v3.1.0
100
+ ### Key Management
192
101
 
193
- **Interactive vault dashboard** — `git cas inspect --slug my-asset` renders a rich TUI with chunk heatmap, encryption card, and history timeline. Animated progress bars for long store/restore operations.
102
+ Multiple key sources are supported:
194
103
 
195
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
104
+ - **Raw keys**: 32-byte AES-256 key files read directly from disk.
105
+ - **Passphrase-derived keys (PBKDF2)**: PBKDF2-SHA512 with a default of 600,000 iterations. Policy-enforced minimum and maximum iteration bounds.
106
+ - **Passphrase-derived keys (scrypt)**: scrypt with default N=131072. Combined memory budget is capped at 1 GiB to prevent resource exhaustion.
107
+ - **OS keychain**: Passphrase sourced from the operating system's native keychain (macOS Keychain, Linux Secret Service, Windows Credential Manager) via `@git-stunts/vault`.
196
108
 
197
- ## What's new in v3.0.0
109
+ All KDF operations enforce a minimum 16-byte salt. Iteration counts and scrypt parameters are policy-bounded to prevent both weak derivation and denial-of-service.
198
110
 
199
- **Vault** — GC-safe ref-based storage under `refs/cas/vault`. Assets are indexed by slug and survive `git gc`. Full CLI: `git cas vault init`, `list`, `info`, `remove`, `history`. Store with `--tree` to vault automatically.
111
+ ### Compression
200
112
 
201
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
113
+ Content can be gzip-compressed before storage through the `CompressionPort` abstraction. The shipped `NodeCompressionAdapter` handles Node.js; other runtimes can plug in their own adapter. Compression composes cleanly with encryption — content is compressed, then encrypted. Plaintext + gzip restores now stream instead of buffering.
202
114
 
203
- ## What's new in v2.0.0
115
+ ### Manifests
204
116
 
205
- **Compression** — `compression: { algorithm: 'gzip' }` on `store()`. Compression runs before encryption. Decompression on `restore()` is automatic.
117
+ Two manifest versions handle assets of any size:
206
118
 
207
- **Passphrase-based encryption** — Pass `passphrase` instead of `encryptionKey`. Keys are derived via PBKDF2 (default) or scrypt. KDF parameters are stored in the manifest for deterministic re-derivation. Use `deriveKey()` directly for manual control.
119
+ - **Version 1**: A flat manifest blob listing all chunk digests. Suitable for most assets.
120
+ - **Version 2**: A Merkle-style manifest that splits the chunk list into
121
+ sub-manifests, each independently addressable and schema-validated.
122
+ Automatically engaged when chunk count exceeds 1,000 by default, with
123
+ per-operation `merkleThreshold` overrides available on store calls.
124
+ Sub-manifest arrays are capped at 10,000 entries.
208
125
 
209
- **Merkle tree manifests** — When chunk count exceeds `merkleThreshold` (default: 1000), manifests are automatically split into sub-manifests stored as separate blobs. `readManifest()` transparently reconstitutes them. Full backward compatibility with v1 manifests.
126
+ Every manifest carries an **integrity hash** — the SHA-256 of the codec-encoded content — verified on every read to detect corruption or tampering. Two codecs are available: **JSON** (human-readable, default) and **CBOR** (binary, compact).
210
127
 
211
- See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
128
+ Manifest diffing is available via `diffManifests()` for comparing two manifests and identifying changed, added, or removed chunks.
212
129
 
213
- ## Install
130
+ ### Vault
214
131
 
215
- ```bash
216
- npm install @git-stunts/git-cas
217
- ```
218
-
219
- ```bash
220
- npx jsr add @git-stunts/git-cas
221
- ```
222
-
223
- ## Usage (Node API)
224
-
225
- ```js
226
- import GitPlumbing from '@git-stunts/plumbing';
227
- import ContentAddressableStore from '@git-stunts/cas';
132
+ The vault is a GC-safe named asset index stored at `refs/cas/vault`. It is the control plane for managing stored content.
228
133
 
229
- const git = new GitPlumbing({ cwd: './assets-repo' });
230
- const cas = new ContentAddressableStore({ plumbing: git });
134
+ - **CRUD**: Add, remove, list, and resolve named entries.
135
+ - **Encryption**: Vault entries can be encrypted with a passphrase.
136
+ - **Privacy mode**: HMAC-hashed slug names prevent metadata discovery — an observer cannot determine what assets are stored without the passphrase.
137
+ - **Encryption count tracking**: The vault tracks how many times each entry has been encrypted under the current nonce context, issuing rotation warnings as limits approach.
138
+ - **Passphrase verifier**: Encrypted vault metadata authenticates the derived
139
+ vault key even before the first entry is added, so wrong passphrases fail
140
+ before empty-vault writes are accepted.
141
+ - **Passphrase rotation**: Rotate the vault passphrase across all entries in a single operation without re-encrypting data blobs.
142
+ - **Optimistic concurrency**: Vault writes use compare-and-swap semantics with automatic retry on conflict, ensuring safe concurrent access.
231
143
 
232
- // Store a file -> returns a manifest (chunk list + metadata)
233
- const manifest = await cas.storeFile({
234
- filePath: './image.png',
235
- slug: 'my-image',
236
- encryptionKey: myKeyBuffer, // optional (32 bytes)
237
- });
238
-
239
- // Turn the manifest into a Git tree OID
240
- const treeOid = await cas.createTree({ manifest });
144
+ ### Restore Modes
241
145
 
242
- // Restore later — get your bytes back, integrity-verified
243
- await cas.restoreFile({ manifest, outputPath: './restored.png' });
146
+ Three restore surfaces cover different memory and latency profiles:
244
147
 
245
- // Read the manifest back from a tree OID
246
- const m = await cas.readManifest({ treeOid });
148
+ | Method | Behavior | Bounded? |
149
+ |---|---|---|
150
+ | `restore()` | Buffered reassembly to memory | Yes — capped by `maxRestoreBufferSize` |
151
+ | `restoreFile()` | Atomic temp-file write with auth-then-rename | Yes — streams through disk for plaintext, framed, convergent, and uncompressed whole |
152
+ | `restoreStream()` | Async iterable yielding chunks | Yes — frame-by-frame for framed scheme |
247
153
 
248
- // Lifecycle: inspect deletion impact, collect referenced chunks
249
- const { slug, chunksOrphaned } = await cas.inspectAsset({ treeOid });
250
- const { referenced, total } = await cas.collectReferencedChunks({ treeOids: [treeOid] });
154
+ `restoreFile()` writes tentative plaintext to a temporary file, verifies authentication, and renames into place only after verification succeeds. For `framed`, all three surfaces provide true streaming restore with per-frame authentication. Parallel chunk restore is supported via a prefetch window (`PrefetchWindow`) when concurrency is greater than 1, enabling ordered parallel reads for faster restores.
251
155
 
252
- // v2.0.0: Compressed + passphrase-encrypted store
253
- const manifest2 = await cas.storeFile({
254
- filePath: './image.png',
255
- slug: 'my-image',
256
- passphrase: 'my secret passphrase',
257
- compression: { algorithm: 'gzip' },
156
+ ```js
157
+ await cas.restoreFile({
158
+ manifest,
159
+ outputPath: './restored.bin',
160
+ baseDirectory: process.cwd(),
258
161
  });
259
162
  ```
260
163
 
261
- ## CLI (git plugin)
164
+ ### CLI
165
+
166
+ The `git-cas` command-line interface exposes the full feature set:
167
+
168
+ | Command | Purpose |
169
+ |---|---|
170
+ | `git-cas store` | Store a file into the CAS |
171
+ | `git-cas tree` | Create a Git tree from a manifest JSON file |
172
+ | `git-cas inspect` | Inspect a stored manifest and optional chunk heatmap |
173
+ | `git-cas restore` | Restore content by vault slug or tree OID |
174
+ | `git-cas verify` | Verify chunk integrity for a stored asset |
175
+ | `git-cas doctor` | Diagnose vault health and integrity |
176
+ | `git-cas vault init` | Initialize a new vault |
177
+ | `git-cas vault list` | List vault entries |
178
+ | `git-cas vault stats` | Summarize vault size, dedupe, and encryption coverage |
179
+ | `git-cas vault remove` | Remove a vault entry |
180
+ | `git-cas vault info` | Show metadata for one vault entry |
181
+ | `git-cas vault history` | Show vault commit history |
182
+ | `git-cas vault rotate` | Rotate the vault passphrase |
183
+ | `git-cas vault dashboard` | Interactive TUI for vault navigation |
184
+ | `git-cas rotate` | Rotate an asset encryption key wrapper |
185
+ | `git-cas recipient add/remove/list` | Manage envelope encryption recipients |
186
+
187
+ `git-cas doctor` reports both chunk-reference dedupe and byte-level efficiency:
188
+ logical manifest size versus unique chunk bytes. For privacy-enabled vaults,
189
+ pass `--key-file`, `--vault-passphrase-file -`, or `--os-keychain-target` so the
190
+ doctor can decrypt the privacy index before scanning entries.
191
+
192
+ **Agent CLI**: `git-cas agent` exposes the same store/tree/restore/inspect/verify/doctor/rotate/recipient/vault surface through a newline-delimited protocol for CI/CD automation and programmatic integrations. Request payloads can be passed through `--request <json>` or stdin; responses stream back as JSON events on stdout.
193
+
194
+ ### Security Hardening
195
+
196
+ Beyond the core encryption primitives, `git-cas` enforces a set of defensive limits:
197
+
198
+ - **Hex validation**: All OID and digest fields are schema-validated as strict hexadecimal strings.
199
+ - **scrypt memory cap**: Combined scrypt memory budget is hard-capped at 1 GiB.
200
+ - **Sub-manifest array limit**: Merkle sub-manifests are capped at 10,000 entries.
201
+ - **Restore path boundary**: `restoreFile()` requires `baseDirectory` and refuses output paths that escape it.
202
+ - **Metadata blob cap**: Manifest and sub-manifest blob reads default to a
203
+ 10 MiB `maxBlobSize` safety limit. The default Git adapter honors the
204
+ facade/service `maxBlobSize` option through its adapter-level read limit.
205
+ - **Concurrency cap**: Parallel operations are bounded at 64.
206
+ - **Frame size cap**: `frameBytes` is capped at 64 MiB.
207
+ - **Timing oracle elimination**: Recipient trial decryption uses constant-time comparison to prevent timing-based key identification.
208
+ - **Source validation**: Async iterables passed to `store()` are validated before processing begins.
209
+ - **Salt enforcement**: KDF salts must be at least 16 bytes.
210
+ - **Nonce rotation**: Encryption count tracking warns before nonce reuse becomes a concern.
211
+ - **Legacy scheme rejection**: Attempting to use a legacy encryption scheme (`whole-v1`, `whole-v2`, `framed-v1`, `framed-v2`, `convergent-v1`) throws a `LEGACY_SCHEME` error with migration guidance (see [UPGRADING.md](./UPGRADING.md)).
212
+
213
+ ## Streaming Surface
214
+
215
+ | Surface | Streaming API? | Non-streaming API? | Notes |
216
+ |---|---|---|---|
217
+ | Write | `store({ source, ... })`, `storeFile(...)` | No dedicated non-streaming store facade | Write ingress is stream-based. CDC + encryption defaults to `convergent` (per-chunk deterministic encryption preserving dedup). Fixed + encryption defaults to `framed`. |
218
+ | Read: plaintext | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | True chunk-by-chunk streaming restore. |
219
+ | Read: encrypted `whole` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | `restoreStream()` is the buffered compatibility path. Uncompressed `restoreFile()` verifies chunks, streams tentative plaintext through whole-object AES-GCM decryption into a temp-file path, and renames into place only after auth succeeds. AAD (slug) is always bound. On Web Crypto runtimes this decrypt step is still one-shot internally, bounded by `maxDecryptionBufferSize`. |
220
+ | Read: encrypted `framed` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | True authenticated streaming restore. Plaintext is yielded frame-by-frame after each frame is verified. Per-frame AAD is always bound. |
221
+ | Read: compressed-only | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Plaintext + gzip now streams end-to-end. `restoreFile()` streams gunzip output through a bounded temp-file path. |
222
+ | Read: compressed + `whole` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Auth must complete before gunzip. `restoreFile()` therefore preserves the auth-before-decompress boundary and may buffer the encrypted compressed payload; use `framed` or `convergent` for large compressed encrypted assets. |
223
+ | Read: compressed + `framed` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Streaming decrypt, then streaming gunzip. |
224
+ | Read: encrypted `convergent` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | True per-chunk streaming restore. Each chunk is decrypted individually using a key derived from its content hash. Parallel chunk restore via prefetch window when concurrency > 1. |
225
+ | Read: compressed + `convergent` | `restoreStream(...)`, `restoreFile(...)` | `restore(...)` | Per-chunk convergent decrypt, then streaming gunzip. |
226
+ | Verify | No streaming verify surface | `verifyIntegrity(manifest, options?)` | Verifies chunk digests for all content. `whole` auth-checks the full ciphertext; `framed` parses and auth-checks every frame; `convergent` decrypts each chunk and verifies plaintext digests. |
227
+
228
+ Runtime note: `framed` is the honest cross-runtime streaming answer. On Node and Bun, `whole restoreFile()` has the stronger low-memory path; on Web Crypto runtimes such as Deno, `whole` remains bounded-buffer rather than true streaming.
229
+
230
+ ## Architecture
231
+
232
+ `git-cas` follows a strict hexagonal (ports and adapters) architecture. The domain core has zero knowledge of runtime-specific APIs.
262
233
 
263
- `git-cas` installs as a Git subcommand:
264
-
265
- ```bash
266
- # Store a file — prints manifest JSON
267
- git cas store ./image.png --slug my-image
268
-
269
- # Store and vault the tree OID (GC-safe)
270
- git cas store ./image.png --slug my-image --tree
271
-
272
- # Restore from a vault slug
273
- git cas restore --slug my-image --out ./restored.png
274
-
275
- # Restore from a direct tree OID
276
- git cas restore --oid <tree-oid> --out ./restored.png
277
-
278
- # Verify integrity without restoring
279
- git cas verify --slug my-image
280
-
281
- # Inspect manifest (interactive dashboard)
282
- git cas inspect --slug my-image
283
-
284
- # Vault management
285
- git cas vault init
286
- git cas vault list # TTY table
287
- git cas vault list --json # structured JSON
288
- git cas vault list --filter "photos/*" # glob filter
289
- git cas vault info my-image
290
- git cas vault remove my-image
291
- git cas vault history
292
-
293
- # Multi-recipient encryption
294
- git cas store ./secret.bin --slug shared \
295
- --recipient alice:./keys/alice.key \
296
- --recipient bob:./keys/bob.key --tree
297
- git cas recipient list shared
298
- git cas recipient add shared --label carol --key-file ./keys/carol.key --existing-key-file ./keys/alice.key
299
- git cas recipient remove shared --label bob
300
-
301
- # Key rotation (no re-encryption)
302
- git cas rotate --slug shared --old-key-file old.key --new-key-file new.key
303
- git cas rotate --slug shared --old-key-file old.key --new-key-file new.key --label alice
304
-
305
- # Vault passphrase rotation
306
- git cas vault rotate --old-passphrase old-secret --new-passphrase new-secret
307
-
308
- # Encrypted vault round-trip (passphrase via env var or --vault-passphrase flag)
309
- export GIT_CAS_PASSPHRASE="secret"
310
- git cas vault init
311
- git cas store ./secret.bin --slug vault-entry --tree
312
- git cas restore --slug vault-entry --out ./decrypted.bin
313
-
314
- # Compression, chunking, codec, concurrency
315
- git cas store ./data.bin --slug my-data --tree --gzip
316
- git cas store ./data.bin --slug my-data --tree --strategy cdc
317
- git cas store ./data.bin --slug my-data --tree --chunk-size 65536 --concurrency 4
318
- git cas store ./data.bin --slug my-data --tree --codec cbor
319
-
320
- # Restore with concurrency
321
- git cas restore --slug my-data --out ./data.bin --concurrency 4
322
-
323
- # JSON output on any command (for CI/scripting)
324
- git cas store ./data.bin --slug my-data --tree --json
325
234
  ```
326
-
327
- ### `.casrc` — Project Config File
328
-
329
- Place a `.casrc` JSON file at the repository root to set defaults for CLI flags.
330
- CLI flags always take precedence over `.casrc` values.
331
-
332
- ```json
333
- {
334
- "chunkSize": 65536,
335
- "strategy": "cdc",
336
- "concurrency": 4,
337
- "codec": "json",
338
- "compression": "gzip",
339
- "merkleThreshold": 500,
340
- "maxRestoreBufferSize": 1073741824,
341
- "cdc": {
342
- "minChunkSize": 8192,
343
- "targetChunkSize": 32768,
344
- "maxChunkSize": 131072
345
- }
346
- }
235
+ ┌─────────────────────┐
236
+ │ ContentAddressable │
237
+ │ Store (Facade) │
238
+ └──────────┬──────────┘
239
+ │
240
+ ┌──────────▼──────────┐
241
+ │ CasService │
242
+ │ (Domain Core) │
243
+ └──┬──┬──┬──┬──┬──┬───┘
244
+ │ │ │ │ │ │
245
+ ┌──────────────┘ │ │ │ │ └──────────────┐
246
+ │ ┌────────┘ │ │ └────────┐ │
247
+ ▼ ▼ ▼ ▼ ▼ ▼
248
+ ┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐
249
+ │Persist.││ Crypto ││ Codec ││Compress││Chunking││Observe.│
250
+ │ Port ││ Port ││ Port ││ Port ││ Port ││ Port │
251
+ └───┬────┘└───┬────┘└───┬────┘└───┬────┘└───┬────┘└───┬────┘
252
+ │ │ │ │ │ │
253
+ ▼ ▼ ▼ ▼ ▼ ▼
254
+ GitODB Node/Bun JSON or Node gzip Fixed or Event
255
+ /Deno CBOR adapter CDC/ Emitter
256
+ Crypto Buzhash
347
257
  ```
348
258
 
349
- ## Documentation
259
+ **Ports** define the contracts. **Adapters** implement them for specific runtimes. Swap any adapter without touching domain logic.
350
260
 
351
- - [Guide](./GUIDE.md) — progressive walkthrough
352
- - [API Reference](./docs/API.md) — full method documentation
353
- - [Architecture](./ARCHITECTURE.md) — hexagonal design overview
354
- - [Security](./SECURITY.md) — crypto design and threat model
261
+ The core byte contract is `Uint8Array`. Node `Buffer` values still work at the
262
+ Node boundary because `Buffer` extends `Uint8Array`, but the domain, ports,
263
+ chunkers, codecs, and shared helpers do not depend on Node-specific byte APIs.
355
264
 
356
- ## When to use git-cas (and when not to)
265
+ ## Multi-Runtime Support
357
266
 
358
- ### "I just want screenshots in my README"
267
+ | Runtime | Version | Crypto Backend | Status |
268
+ |---|---|---|---|
269
+ | **Node.js** | 22+ | `node:crypto` | Primary — full streaming support |
270
+ | **Bun** | Latest | `node:crypto` compat | Tested via Docker |
271
+ | **Deno** | Latest | Web Crypto API | Tested via Docker; `whole` decrypt is bounded-buffer |
359
272
 
360
- Use an **orphan branch**. Seriously. It's 5 git commands, zero dependencies, and GitHub renders the images inline. Google "git orphan branch assets" — that's all you need. git-cas is overkill for public images and demo GIFs.
273
+ All three runtimes are tested in CI on every push. The hexagonal architecture isolates runtime differences behind the `CryptoPort` boundary, so the domain core is runtime-agnostic.
361
274
 
362
- ### "I need encrypted secrets / large binaries / deduplicated assets in a Git repo"
363
-
364
- That's git-cas. The orphan branch gives you none of:
365
-
366
- | | Orphan branch | git-cas |
367
- |---|---|---|
368
- | **Encryption** | None — plaintext forever in history | AES-256-GCM + passphrase KDF + multi-recipient + key rotation |
369
- | **Large files** | Bloats `git clone` for everyone | Chunked, restored on demand |
370
- | **Dedup** | None | Chunk-level content addressing |
371
- | **Integrity** | Git SHA-1 | SHA-256 per chunk + GCM auth tag |
372
- | **Lifecycle** | `git rm` (still in reflog) | Vault with audit trail + `git gc` reclaims |
373
- | **Compression** | None | gzip before encryption |
374
-
375
- ### "Why not Git LFS?"
376
-
377
- Because sometimes you want the Git object database to be the store — deterministic, content-addressed, locally replicable, commit-addressable — with no external server, no LFS endpoint, and no second system to manage.
378
-
379
- If your team uses GitHub and needs file locking + web UI previews, use LFS. If you want encrypted, self-contained, server-free binary storage that travels with `git clone`, use git-cas.
380
-
381
- ---
382
-
383
- > _THIS HASH’LL KNOCK YOUR SHAs OFF! FIRST COMMIT’S FREE, MAN._
384
-
385
- <img width="420" alt="dhtux" src="https://github.com/user-attachments/assets/f2c13357-22c7-4685-83ce-7eccd747e2fe" />
386
-
387
- ---
388
-
389
- ## License
275
+ ## Documentation
390
276
 
391
- Apache-2.0
392
- Copyright © 2026 [James Ross](https://github.com/flyingrobots)
277
+ - **[Guide](./GUIDE.md)**: Productive path, library/CLI usage, vault workflows, and the feature coverage map.
278
+ - **[Advanced Guide](./ADVANCED_GUIDE.md)**: CDC internals, direct service contracts, security limits, operational tooling, and performance baselines.
279
+ - **[Architecture](./ARCHITECTURE.md)**: The authoritative system map — Facade, Domain, Ports, and Adapters.
280
+ - **[Extending](./docs/EXTENDING.md)**: Custom adapter contracts and extension-point checklist.
281
+ - **[Store/Restore Pipeline](./docs/STORE_RESTORE_PIPELINE.md)**: Maintainer state machines for byte storage, restore, tree publication, and vault boundaries.
282
+ - **[Vault Internals](./docs/VAULT_INTERNALS.md)**: Maintainer map for vault persistence, caching, codecs, privacy indexing, key verification, and retry policy.
283
+ - **[Security](./SECURITY.md)**: Threat models, trust boundaries, and encryption internals.
284
+ - **[Agent API](./docs/API.md)**: JSONL agent protocol for CI/CD automation.
285
+ - **[Workflow](https://github.com/git-stunts/git-cas/blob/main/WORKFLOW.md)**: Repo work doctrine, cycles, and invariants.
286
+ - **[Contributing](https://github.com/git-stunts/git-cas/blob/main/CONTRIBUTING.md)**, **[Code of Conduct](./CODE_OF_CONDUCT.md)**, and **[Support](./SUPPORT.md)**: Project participation and help paths.
287
+ - **[v6.0.0 Release Notes](./docs/releases/v6.0.0.md)**: Major-release summary, upgrade call-to-action, and publication notes.
288
+ - **[Upgrading](./UPGRADING.md)**: Migration guide for v5 → v6.
289
+ - **[Changelog](./CHANGELOG.md)**: Version history and migration notes.
393
290
 
394
291
  ---
395
-
396
- <p align="center">
397
- <sub>Built by <a href="https://github.com/flyingrobots">FLYING ROBOTS</a></sub>
398
- </p>
292
+ Built with terminal ambition by [FLYING ROBOTS](https://github.com/flyingrobots)