@git-stunts/git-cas 5.3.2 → 6.0.1
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 +1027 -0
- package/ARCHITECTURE.md +514 -0
- package/CHANGELOG.md +449 -5
- package/CODE_OF_CONDUCT.md +33 -0
- package/GUIDE.md +926 -0
- package/README.md +106 -366
- 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 +1255 -212
- 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 +367 -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 +2254 -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 +273 -80
- package/index.js +220 -59
- 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 +153 -53
- package/src/domain/services/CasService.js +322 -837
- package/src/domain/services/ChunkRepository.js +268 -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 +180 -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 +10 -6
- 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,138 @@
|
|
|
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` 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
|
-
|
|
151
|
-
|
|
152
|
-
## What's new in v5.0.0
|
|
52
|
+
### 3. Library Ingress
|
|
153
53
|
|
|
154
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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';
|
|
228
|
-
|
|
229
|
-
const git = new GitPlumbing({ cwd: './assets-repo' });
|
|
230
|
-
const cas = new ContentAddressableStore({ plumbing: git });
|
|
231
|
-
|
|
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 });
|
|
241
|
-
|
|
242
|
-
// Restore later — get your bytes back, integrity-verified
|
|
243
|
-
await cas.restoreFile({ manifest, outputPath: './restored.png' });
|
|
244
|
-
|
|
245
|
-
// Read the manifest back from a tree OID
|
|
246
|
-
const m = await cas.readManifest({ treeOid });
|
|
247
|
-
|
|
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] });
|
|
251
|
-
|
|
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' },
|
|
258
|
-
});
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## CLI (git plugin)
|
|
262
|
-
|
|
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
|
-
```
|
|
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
|
-
}
|
|
347
|
-
```
|
|
62
|
+
## Capability Map
|
|
63
|
+
|
|
64
|
+
The README is the front door. Detailed mechanics live in the guide set:
|
|
65
|
+
|
|
66
|
+
| Need | Start Here |
|
|
67
|
+
| ------------------------------------------------------- | ------------------------------------------------------------ |
|
|
68
|
+
| Productive library and CLI workflows | [Developer Guide](./GUIDE.md) |
|
|
69
|
+
| Restore memory behavior | [Streaming and restore matrix](./GUIDE.md#streaming-surface) |
|
|
70
|
+
| Encryption scheme selection | [Encryption Modes](./docs/ENCRYPTION_MODES.md) |
|
|
71
|
+
| CDC internals, Merkle manifests, KDF policy, and tuning | [Advanced Guide](./ADVANCED_GUIDE.md) |
|
|
72
|
+
| Ports, adapters, and collaborator boundaries | [Architecture](./ARCHITECTURE.md) |
|
|
73
|
+
| v5 to v6 migration | [Upgrading](./UPGRADING.md) |
|
|
74
|
+
|
|
75
|
+
Core capabilities:
|
|
76
|
+
|
|
77
|
+
- **Content-addressed storage**: chunks are addressed by SHA-256 digest and
|
|
78
|
+
integrity-verified on read.
|
|
79
|
+
- **Deduplication**: fixed chunking and content-defined chunking (CDC) support
|
|
80
|
+
predictable or shift-resistant chunk boundaries.
|
|
81
|
+
- **Encryption**: AES-256-GCM with authenticated metadata. `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.
|
|
85
|
+
- **Vault indexing**: named assets live under `refs/cas/vault` so Git garbage
|
|
86
|
+
collection does not reclaim referenced blobs.
|
|
87
|
+
- **Envelope recipients**: multi-recipient key wrapping and recipient rotation
|
|
88
|
+
avoid re-encrypting data blobs.
|
|
89
|
+
- **Operational diagnostics**: `git-cas doctor` validates vault health and
|
|
90
|
+
reports deduplication efficiency.
|
|
91
|
+
|
|
92
|
+
## Safety Snapshot
|
|
93
|
+
|
|
94
|
+
The v6 line is Security First by default:
|
|
95
|
+
|
|
96
|
+
- `restoreFile()` requires `baseDirectory` and refuses output paths that escape
|
|
97
|
+
it.
|
|
98
|
+
- Manifest and sub-manifest blob reads default to a 10 MiB `maxBlobSize` safety
|
|
99
|
+
limit.
|
|
100
|
+
- Legacy encryption scheme identifiers throw `LEGACY_SCHEME` with migration
|
|
101
|
+
guidance.
|
|
102
|
+
- KDF parameters, salts, frame sizes, restore buffers, and concurrency are
|
|
103
|
+
policy-bounded.
|
|
104
|
+
- Recipient trial decryption and vault verifier checks use constant-time
|
|
105
|
+
comparisons.
|
|
106
|
+
|
|
107
|
+
For the full hardening table, see
|
|
108
|
+
[Advanced Guide: Security Hardening Summary](./ADVANCED_GUIDE.md#security-hardening-summary).
|
|
109
|
+
|
|
110
|
+
## Runtime Support
|
|
111
|
+
|
|
112
|
+
| Runtime | Version | Crypto Backend | Status |
|
|
113
|
+
| ----------- | ------- | -------------------- | ---------------------------------------------------- |
|
|
114
|
+
| **Node.js** | 22+ | `node:crypto` | Primary — full streaming support |
|
|
115
|
+
| **Bun** | Latest | `node:crypto` compat | Tested via Docker |
|
|
116
|
+
| **Deno** | Latest | Web Crypto API | Tested via Docker; `whole` decrypt is bounded-buffer |
|
|
117
|
+
|
|
118
|
+
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.
|
|
348
119
|
|
|
349
120
|
## Documentation
|
|
350
121
|
|
|
351
|
-
- [Guide](./GUIDE.md)
|
|
352
|
-
- [
|
|
353
|
-
- [Architecture](./ARCHITECTURE.md) —
|
|
354
|
-
- [
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
|
390
|
-
|
|
391
|
-
Apache-2.0
|
|
392
|
-
Copyright © 2026 [James Ross](https://github.com/flyingrobots)
|
|
122
|
+
- **[Guide](./GUIDE.md)**: Productive path, library/CLI usage, vault workflows, and the feature coverage map.
|
|
123
|
+
- **[Advanced Guide](./ADVANCED_GUIDE.md)**: CDC internals, direct service contracts, security limits, operational tooling, and performance baselines.
|
|
124
|
+
- **[Architecture](./ARCHITECTURE.md)**: The authoritative system map — Facade, Domain, Ports, and Adapters.
|
|
125
|
+
- **[Extending](./docs/EXTENDING.md)**: Custom adapter contracts and extension-point checklist.
|
|
126
|
+
- **[Store/Restore Pipeline](./docs/STORE_RESTORE_PIPELINE.md)**: Maintainer state machines for byte storage, restore, tree publication, and vault boundaries.
|
|
127
|
+
- **[Vault Internals](./docs/VAULT_INTERNALS.md)**: Maintainer map for vault persistence, caching, codecs, privacy indexing, key verification, and retry policy.
|
|
128
|
+
- **[Security](./SECURITY.md)**: Threat models, trust boundaries, and encryption internals.
|
|
129
|
+
- **[Agent API](./docs/API.md)**: JSONL agent protocol for CI/CD automation.
|
|
130
|
+
- **[Workflow](https://github.com/git-stunts/git-cas/blob/main/WORKFLOW.md)**: Repo work doctrine, cycles, and invariants.
|
|
131
|
+
- **[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.
|
|
132
|
+
- **[v6.0.0 Release Notes](./docs/releases/v6.0.0.md)**: Major-release summary, upgrade call-to-action, and publication notes.
|
|
133
|
+
- **[Upgrading](./UPGRADING.md)**: Migration guide for v5 → v6.
|
|
134
|
+
- **[Changelog](./CHANGELOG.md)**: Version history and migration notes.
|
|
393
135
|
|
|
394
136
|
---
|
|
395
137
|
|
|
396
|
-
|
|
397
|
-
<sub>Built by <a href="https://github.com/flyingrobots">FLYING ROBOTS</a></sub>
|
|
398
|
-
</p>
|
|
138
|
+
Built with terminal ambition by [FLYING ROBOTS](https://github.com/flyingrobots)
|