@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.
- package/ADVANCED_GUIDE.md +1006 -0
- package/ARCHITECTURE.md +514 -0
- package/CHANGELOG.md +393 -5
- package/CODE_OF_CONDUCT.md +33 -0
- package/GUIDE.md +872 -0
- package/README.md +219 -325
- package/SECURITY.md +993 -0
- package/SUPPORT.md +54 -0
- package/UPGRADING.md +299 -0
- package/bin/actions.js +70 -21
- package/bin/agent/cli.js +51 -0
- package/bin/agent/commands/doctor.js +99 -0
- package/bin/agent/commands/index.js +1489 -0
- package/bin/agent/input.js +619 -0
- package/bin/agent/passphrase-source.js +123 -0
- package/bin/agent/protocol.js +193 -0
- package/bin/build-version.js +64 -0
- package/bin/credentials.js +425 -0
- package/bin/git-cas.js +595 -449
- package/bin/passphrase-source.js +266 -0
- package/bin/restore-output-target.js +28 -0
- package/bin/ui/blocks/asset-card.js +109 -0
- package/bin/ui/blocks/health-dashboard.js +149 -0
- package/bin/ui/blocks/heatmap-block.js +67 -0
- package/bin/ui/blocks/merkle-explorer.js +163 -0
- package/bin/ui/blocks/operation-feed.js +176 -0
- package/bin/ui/blocks/wizard-block.js +168 -0
- package/bin/ui/components/short-sha.js +36 -0
- package/bin/ui/context.js +56 -1
- package/bin/ui/dashboard-cmds.js +1578 -13
- package/bin/ui/dashboard-view.js +612 -145
- package/bin/ui/dashboard.js +998 -214
- package/bin/ui/encryption-card.js +69 -26
- package/bin/ui/heatmap.js +26 -54
- package/bin/ui/history-timeline.js +51 -19
- package/bin/ui/manifest-view.js +115 -60
- package/bin/ui/merkle-dag.js +83 -0
- package/bin/ui/progress.js +15 -9
- package/bin/ui/repo-treemap.js +328 -0
- package/bin/ui/shaders/bak-sneppen.js +180 -0
- package/bin/ui/shaders/fractal-zoom.js +99 -0
- package/bin/ui/shaders/merkle-tree.js +142 -0
- package/bin/ui/shaders/organic-flow.js +96 -0
- package/bin/ui/shaders/phase-portrait.js +93 -0
- package/bin/ui/store-wizard.js +296 -0
- package/bin/ui/theme.js +155 -0
- package/bin/ui/vault-report.js +495 -0
- package/build-info.json +4 -0
- package/docs/API.md +2224 -0
- package/docs/ENCRYPTION_MODES.md +33 -0
- package/docs/EXTENDING.md +174 -0
- package/docs/STORE_RESTORE_PIPELINE.md +199 -0
- package/docs/THREAT_MODEL.md +269 -0
- package/docs/VAULT_INTERNALS.md +251 -0
- package/docs/WALKTHROUGH.md +1868 -0
- package/docs/demo.gif +0 -0
- package/docs/releases/v6.0.0.md +104 -0
- package/examples/README.md +260 -0
- package/index.d.ts +208 -65
- package/index.js +163 -54
- package/package.json +35 -6
- package/scripts/migrate-encryption.js +680 -0
- package/src/domain/bytes/ByteLayout.js +96 -0
- package/src/domain/encoding/base64.js +91 -0
- package/src/domain/encoding/hex.js +14 -0
- package/src/domain/encoding/utf8.js +123 -0
- package/src/domain/encryption/schemes.js +132 -0
- package/src/domain/errors/CannotRemoveLastRecipientError.js +10 -0
- package/src/domain/errors/CasError.d.ts +28 -0
- package/src/domain/errors/CasError.js +43 -6
- package/src/domain/errors/Codes.js +54 -0
- package/src/domain/errors/DekUnwrapFailedError.js +10 -0
- package/src/domain/errors/GitError.js +10 -0
- package/src/domain/errors/GitPlumbingInitializationError.js +10 -0
- package/src/domain/errors/IntegrityError.js +10 -0
- package/src/domain/errors/InvalidChunkingStrategyError.js +10 -0
- package/src/domain/errors/InvalidOidError.js +10 -0
- package/src/domain/errors/InvalidOptionsError.js +10 -0
- package/src/domain/errors/ManifestIntegrityError.js +10 -0
- package/src/domain/errors/ManifestNotFoundError.js +10 -0
- package/src/domain/errors/NoMatchingRecipientError.js +10 -0
- package/src/domain/errors/PersistenceCapabilityRequiredError.js +10 -0
- package/src/domain/errors/PortNotImplementedError.js +10 -0
- package/src/domain/errors/RecipientAlreadyExistsError.js +10 -0
- package/src/domain/errors/RecipientNotFoundError.js +10 -0
- package/src/domain/errors/RestoreTooLargeError.js +10 -0
- package/src/domain/errors/RotationNotSupportedError.js +10 -0
- package/src/domain/errors/createCasError.js +68 -0
- package/src/domain/errors/index.js +20 -0
- package/src/domain/helpers/buildKdfMetadata.js +4 -2
- package/src/domain/helpers/codecBytes.js +34 -0
- package/src/domain/helpers/gitRefErrors.js +84 -0
- package/src/domain/helpers/scryptMaxmem.js +22 -0
- package/src/domain/outcomes/RestoreFailure.js +15 -0
- package/src/domain/outcomes/RestoreOutcome.js +11 -0
- package/src/domain/outcomes/RestoreSuccess.js +34 -0
- package/src/domain/outcomes/StoreFailure.js +15 -0
- package/src/domain/outcomes/StoreOutcome.js +11 -0
- package/src/domain/outcomes/StoreSuccess.js +17 -0
- package/src/domain/schemas/ManifestSchema.d.ts +40 -9
- package/src/domain/schemas/ManifestSchema.js +67 -13
- package/src/domain/services/CasService.d.ts +123 -38
- package/src/domain/services/CasService.js +298 -834
- package/src/domain/services/ChunkRepository.js +230 -0
- package/src/domain/services/CompressionStreams.js +72 -0
- package/src/domain/services/ConvergentEncryption.js +128 -0
- package/src/domain/services/GitTreeBuilder.js +86 -0
- package/src/domain/services/IntegrityVerifier.js +199 -0
- package/src/domain/services/KeyResolver.js +49 -42
- package/src/domain/services/ManifestDiff.js +56 -0
- package/src/domain/services/ManifestRepository.js +286 -0
- package/src/domain/services/PrefetchWindow.js +48 -0
- package/src/domain/services/RecipientService.js +157 -0
- package/src/domain/services/RedactingObservability.js +169 -0
- package/src/domain/services/RestorePipeline.js +68 -0
- package/src/domain/services/StorePipeline.js +201 -0
- package/src/domain/services/VaultKeyVerifier.js +101 -0
- package/src/domain/services/VaultMetadataCodec.js +206 -0
- package/src/domain/services/VaultMutationRetryPolicy.js +105 -0
- package/src/domain/services/VaultPersistence.js +410 -0
- package/src/domain/services/VaultPrivacyIndex.js +191 -0
- package/src/domain/services/VaultService.js +749 -251
- package/src/domain/services/VaultStateCache.js +225 -0
- package/src/domain/services/VaultTreeCodec.js +121 -0
- package/src/domain/services/rotateVaultPassphrase.js +37 -20
- package/src/domain/strategies/Aad.js +39 -0
- package/src/domain/strategies/FramedRecordCodec.js +204 -0
- package/src/domain/strategies/RestoreCompressed.js +40 -0
- package/src/domain/strategies/RestoreConvergent.js +44 -0
- package/src/domain/strategies/RestoreFramed.js +55 -0
- package/src/domain/strategies/RestorePlain.js +37 -0
- package/src/domain/strategies/RestoreStrategy.js +35 -0
- package/src/domain/strategies/RestoreWhole.js +135 -0
- package/src/domain/strategies/StoreConvergent.js +28 -0
- package/src/domain/strategies/StoreFramed.js +39 -0
- package/src/domain/strategies/StorePlain.js +20 -0
- package/src/domain/strategies/StoreStrategy.js +61 -0
- package/src/domain/strategies/StoreWhole.js +34 -0
- package/src/domain/value-objects/Chunk.js +1 -2
- package/src/domain/value-objects/EncryptionMetadata.js +87 -0
- package/src/domain/value-objects/Manifest.d.ts +40 -4
- package/src/domain/value-objects/Manifest.js +61 -20
- package/src/domain/value-objects/Oid.js +45 -0
- package/src/domain/value-objects/Slug.js +124 -0
- package/src/domain/value-objects/StoreEncryptionConfig.js +114 -0
- package/src/helpers/aesGcmMeta.js +55 -0
- package/src/helpers/canonicalBase64.js +1 -0
- package/src/helpers/kdfPolicy.js +194 -0
- package/src/infrastructure/adapters/BunCryptoAdapter.js +124 -8
- package/src/infrastructure/adapters/FileIOHelper.js +178 -13
- package/src/infrastructure/adapters/GitPersistenceAdapter.js +235 -42
- package/src/infrastructure/adapters/GitPlumbingFactoryAdapter.js +62 -0
- package/src/infrastructure/adapters/GitRefAdapter.js +19 -6
- package/src/infrastructure/adapters/NodeCompressionAdapter.js +64 -0
- package/src/infrastructure/adapters/NodeCryptoAdapter.js +130 -10
- package/src/infrastructure/adapters/WebCryptoAdapter.js +187 -77
- package/src/infrastructure/chunkers/CdcChunker.js +53 -19
- package/src/infrastructure/chunkers/FixedChunker.js +15 -7
- package/src/infrastructure/chunkers/resolveChunker.js +3 -1
- package/src/infrastructure/codecs/CborCodec.js +3 -3
- package/src/infrastructure/codecs/JsonCodec.js +5 -5
- package/src/infrastructure/createGitPlumbing.js +22 -0
- package/src/package-version.js +1 -0
- package/src/ports/ChunkingPort.js +3 -3
- package/src/ports/CodecPort.js +4 -4
- package/src/ports/CompressionPort.js +57 -0
- package/src/ports/CryptoPort.js +138 -50
- package/src/ports/GitPersistencePort.js +32 -2
- package/src/ports/GitPlumbingFactoryPort.js +16 -0
- package/src/ports/GitRefPort.js +1 -1
- package/src/types/ambient.d.ts +10 -5
- package/test/CONVENTIONS.md +94 -0
- package/test/cycles/README.md +13 -0
package/README.md
CHANGED
|
@@ -1,398 +1,292 @@
|
|
|
1
|
-
#
|
|
1
|
+
# git-cas
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
[](https://www.npmjs.com/package/@git-stunts/git-cas)
|
|
12
|
+
[](./LICENSE)
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+

|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
Git is a content-addressed object database.
|
|
15
|
-
We use the object database.
|
|
16
|
+
## Why git-cas?
|
|
16
17
|
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33
|
+
### 1. CLI Usage
|
|
40
34
|
|
|
41
|
-
|
|
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
|
-
|
|
105
|
-
git
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
+
### 3. Library Ingress
|
|
151
53
|
|
|
152
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
62
|
+
## Feature Overview
|
|
164
63
|
|
|
165
|
-
|
|
64
|
+
### Content-Addressed Storage
|
|
166
65
|
|
|
167
|
-
|
|
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
|
-
|
|
68
|
+
### Chunking
|
|
170
69
|
|
|
171
|
-
|
|
70
|
+
Two chunking strategies are available, both with configurable size parameters:
|
|
172
71
|
|
|
173
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
79
|
+
### Encryption
|
|
178
80
|
|
|
179
|
-
|
|
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
|
-
|
|
86
|
+
Three encryption schemes are supported:
|
|
182
87
|
|
|
183
|
-
|
|
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
|
-
|
|
94
|
+
See [Encryption Modes](./docs/ENCRYPTION_MODES.md) for scheme selection guidance.
|
|
186
95
|
|
|
187
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
+
### Key Management
|
|
192
101
|
|
|
193
|
-
|
|
102
|
+
Multiple key sources are supported:
|
|
194
103
|
|
|
195
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
+
### Compression
|
|
200
112
|
|
|
201
|
-
|
|
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
|
-
|
|
115
|
+
### Manifests
|
|
204
116
|
|
|
205
|
-
|
|
117
|
+
Two manifest versions handle assets of any size:
|
|
206
118
|
|
|
207
|
-
|
|
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
|
-
|
|
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
|
-
|
|
128
|
+
Manifest diffing is available via `diffManifests()` for comparing two manifests and identifying changed, added, or removed chunks.
|
|
212
129
|
|
|
213
|
-
|
|
130
|
+
### Vault
|
|
214
131
|
|
|
215
|
-
|
|
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
|
-
|
|
230
|
-
|
|
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
|
-
|
|
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
|
-
|
|
243
|
-
await cas.restoreFile({ manifest, outputPath: './restored.png' });
|
|
146
|
+
Three restore surfaces cover different memory and latency profiles:
|
|
244
147
|
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
|
|
259
|
+
**Ports** define the contracts. **Adapters** implement them for specific runtimes. Swap any adapter without touching domain logic.
|
|
350
260
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
##
|
|
265
|
+
## Multi-Runtime Support
|
|
357
266
|
|
|
358
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
392
|
-
|
|
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)
|