@git-stunts/git-cas 6.0.0 → 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.
@@ -1,14 +1,19 @@
1
1
  /**
2
2
  * Interactive store wizard — guided flow for storing a file into git-cas.
3
3
  *
4
- * State machine with steps: filePath → slug → encryption → compression → chunking → confirm.
4
+ * State machine with steps: filePath → slug → encryption → passphrase → compression → chunking → confirm.
5
5
  * Renders within the TUI overlay system using the TEA architecture.
6
6
  * Delegates generic step handling and rendering to WizardBlock.
7
7
  */
8
8
 
9
9
  import {
10
- handleSelectKey, handleTextKey, handleToggleKey,
11
- renderFieldLine, renderSelectList, renderTextInput, renderToggle,
10
+ handleSelectKey,
11
+ handleTextKey,
12
+ handleToggleKey,
13
+ renderFieldLine,
14
+ renderSelectList,
15
+ renderTextInput,
16
+ renderToggle,
12
17
  renderWizardPanel,
13
18
  } from './blocks/wizard-block.js';
14
19
  import { themeText } from './theme.js';
@@ -19,7 +24,7 @@ import { themeText } from './theme.js';
19
24
  */
20
25
 
21
26
  /**
22
- * @typedef {'filePath' | 'slug' | 'encryption' | 'compression' | 'chunking' | 'confirm' | 'storing' | 'done' | 'error'} WizardStep
27
+ * @typedef {'filePath' | 'slug' | 'encryption' | 'passphrase' | 'compression' | 'chunking' | 'confirm' | 'storing' | 'done' | 'error'} WizardStep
23
28
  */
24
29
 
25
30
  /**
@@ -31,14 +36,14 @@ import { themeText } from './theme.js';
31
36
  * @property {string} passphrase
32
37
  * @property {boolean} passphraseVisible
33
38
  * @property {boolean} compression
34
- * @property {'whole' | 'fixed' | 'cdc'} chunking
39
+ * @property {'fixed' | 'cdc'} chunking
35
40
  * @property {number} selectIndex
36
41
  * @property {string | null} error
37
42
  * @property {string | null} resultSlug
38
43
  */
39
44
 
40
45
  const ENCRYPTION_OPTIONS = ['none', 'passphrase', 'convergent'];
41
- const CHUNKING_OPTIONS = ['whole', 'fixed', 'cdc'];
46
+ const CHUNKING_OPTIONS = ['fixed', 'cdc'];
42
47
 
43
48
  /**
44
49
  * Create a fresh wizard state.
@@ -82,7 +87,12 @@ function handleFilePathKey(state, key) {
82
87
  function handleSlugKey(state, key) {
83
88
  const result = handleTextKey(state.slug, key);
84
89
  if (result.confirmed) {
85
- return { ...state, slug: result.value, step: 'encryption', selectIndex: ENCRYPTION_OPTIONS.indexOf(state.encryption) };
90
+ return {
91
+ ...state,
92
+ slug: result.value,
93
+ step: 'encryption',
94
+ selectIndex: ENCRYPTION_OPTIONS.indexOf(state.encryption),
95
+ };
86
96
  }
87
97
  return { ...state, slug: result.value };
88
98
  }
@@ -95,12 +105,28 @@ function handleSlugKey(state, key) {
95
105
  function handleEncryptionKey(state, key) {
96
106
  const result = handleSelectKey(state.selectIndex, ENCRYPTION_OPTIONS.length, key);
97
107
  if (result.confirmed) {
98
- const encryption = /** @type {'none' | 'passphrase' | 'convergent'} */ (ENCRYPTION_OPTIONS[result.selectIndex]);
99
- return { ...state, encryption, selectIndex: 0, step: 'compression' };
108
+ const encryption = /** @type {'none' | 'passphrase' | 'convergent'} */ (
109
+ ENCRYPTION_OPTIONS[result.selectIndex]
110
+ );
111
+ const step = encryption === 'none' ? 'compression' : 'passphrase';
112
+ return { ...state, encryption, passphrase: '', selectIndex: 0, step };
100
113
  }
101
114
  return { ...state, selectIndex: result.selectIndex };
102
115
  }
103
116
 
117
+ /**
118
+ * @param {StoreWizardState} state
119
+ * @param {string} key
120
+ * @returns {StoreWizardState}
121
+ */
122
+ function handlePassphraseKey(state, key) {
123
+ const result = handleTextKey(state.passphrase, key);
124
+ if (result.confirmed) {
125
+ return { ...state, passphrase: result.value, step: 'compression' };
126
+ }
127
+ return { ...state, passphrase: result.value };
128
+ }
129
+
104
130
  /**
105
131
  * @param {StoreWizardState} state
106
132
  * @param {string} key
@@ -109,7 +135,12 @@ function handleEncryptionKey(state, key) {
109
135
  function handleCompressionKey(state, key) {
110
136
  const result = handleToggleKey(state.compression, key);
111
137
  if (result.confirmed) {
112
- return { ...state, compression: result.value, step: 'chunking', selectIndex: CHUNKING_OPTIONS.indexOf(state.chunking) };
138
+ return {
139
+ ...state,
140
+ compression: result.value,
141
+ step: 'chunking',
142
+ selectIndex: CHUNKING_OPTIONS.indexOf(state.chunking),
143
+ };
113
144
  }
114
145
  return { ...state, compression: result.value };
115
146
  }
@@ -122,7 +153,7 @@ function handleCompressionKey(state, key) {
122
153
  function handleChunkingKey(state, key) {
123
154
  const result = handleSelectKey(state.selectIndex, CHUNKING_OPTIONS.length, key);
124
155
  if (result.confirmed) {
125
- const chunking = /** @type {'whole' | 'fixed' | 'cdc'} */ (CHUNKING_OPTIONS[result.selectIndex]);
156
+ const chunking = /** @type {'fixed' | 'cdc'} */ (CHUNKING_OPTIONS[result.selectIndex]);
126
157
  return { ...state, chunking, step: 'confirm' };
127
158
  }
128
159
  return { ...state, selectIndex: result.selectIndex };
@@ -148,6 +179,7 @@ const stepHandlers = {
148
179
  filePath: handleFilePathKey,
149
180
  slug: handleSlugKey,
150
181
  encryption: handleEncryptionKey,
182
+ passphrase: handlePassphraseKey,
151
183
  compression: handleCompressionKey,
152
184
  chunking: handleChunkingKey,
153
185
  confirm: handleConfirmKey,
@@ -182,19 +214,49 @@ function deriveSlug(filePath) {
182
214
  return dotIndex > 0 ? name.slice(0, dotIndex) : name;
183
215
  }
184
216
 
217
+ const ENCRYPTED_STEP_ORDER = Object.freeze([
218
+ 'filePath',
219
+ 'slug',
220
+ 'encryption',
221
+ 'passphrase',
222
+ 'compression',
223
+ 'chunking',
224
+ 'confirm',
225
+ ]);
226
+ const PLAIN_STEP_ORDER = Object.freeze([
227
+ 'filePath',
228
+ 'slug',
229
+ 'encryption',
230
+ 'compression',
231
+ 'chunking',
232
+ 'confirm',
233
+ ]);
234
+
185
235
  /** @type {Record<string, string>} */
186
- const STEP_LABELS = {
187
- filePath: '1/6 File',
188
- slug: '2/6 Slug',
189
- encryption: '3/6 Encryption',
190
- compression: '4/6 Compression',
191
- chunking: '5/6 Chunking',
192
- confirm: '6/6 Confirm',
236
+ const STEP_NAMES = {
237
+ filePath: 'File',
238
+ slug: 'Slug',
239
+ encryption: 'Encryption',
240
+ passphrase: 'Passphrase',
241
+ compression: 'Compression',
242
+ chunking: 'Chunking',
243
+ confirm: 'Confirm',
193
244
  storing: 'Storing...',
194
245
  done: 'Done',
195
246
  error: 'Error',
196
247
  };
197
248
 
249
+ /**
250
+ * @param {StoreWizardState} state
251
+ * @returns {string}
252
+ */
253
+ function stepLabel(state) {
254
+ const name = STEP_NAMES[state.step] ?? state.step;
255
+ const order = state.encryption === 'none' ? PLAIN_STEP_ORDER : ENCRYPTED_STEP_ORDER;
256
+ const index = order.indexOf(state.step);
257
+ return index === -1 ? name : `${index + 1}/${order.length} ${name}`;
258
+ }
259
+
198
260
  /**
199
261
  * Render the wizard overlay surface.
200
262
  *
@@ -204,7 +266,7 @@ const STEP_LABELS = {
204
266
  */
205
267
  export function renderWizardSurface(state, opts) {
206
268
  return renderWizardPanel({
207
- title: `Store [${STEP_LABELS[state.step] ?? state.step}]`,
269
+ title: `Store [${stepLabel(state)}]`,
208
270
  body: renderWizardBody(state, opts.ctx),
209
271
  screenWidth: opts.width,
210
272
  screenHeight: opts.height,
@@ -259,6 +321,14 @@ function renderStepBody(state, ctx) {
259
321
  '',
260
322
  themeText(ctx, 'j/k to move, enter to select.', { tone: 'subdued' }),
261
323
  ],
324
+ passphrase: () => [
325
+ themeText(ctx, 'Encryption passphrase:', { tone: 'accent' }),
326
+ renderTextInput(
327
+ state.passphraseVisible ? state.passphrase : '*'.repeat(state.passphrase.length)
328
+ ),
329
+ '',
330
+ themeText(ctx, 'Type the passphrase, then press enter.', { tone: 'subdued' }),
331
+ ],
262
332
  compression: () => [
263
333
  themeText(ctx, 'Compression (gzip):', { tone: 'accent' }),
264
334
  renderToggle(state.compression, ctx),
@@ -288,6 +358,7 @@ function renderConfirmBody(state, ctx) {
288
358
  renderFieldLine(ctx, 'File:', state.filePath),
289
359
  renderFieldLine(ctx, 'Slug:', state.slug),
290
360
  renderFieldLine(ctx, 'Encryption:', state.encryption),
361
+ renderFieldLine(ctx, 'Passphrase:', state.encryption === 'none' ? 'none' : 'set'),
291
362
  renderFieldLine(ctx, 'Compression:', state.compression ? 'gzip' : 'none'),
292
363
  renderFieldLine(ctx, 'Chunking:', state.chunking),
293
364
  '',
package/build-info.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "3a3cd3e",
3
- "timestamp": "2026-05-09T06:59:46.782Z"
2
+ "sha": "b3aaedc",
3
+ "timestamp": "2026-06-29T19:41:41.301Z"
4
4
  }
package/docs/API.md CHANGED
@@ -172,7 +172,19 @@ const vaultService = await cas.getVaultService();
172
172
  #### store
173
173
 
174
174
  ```javascript
175
- await cas.store({ source, slug, filename, encryptionKey, passphrase, encryption, kdfOptions, compression, recipients, merkleThreshold });
175
+ await cas.store({
176
+ source,
177
+ slug,
178
+ filename,
179
+ encryptionKey,
180
+ passphrase,
181
+ encryption,
182
+ kdfOptions,
183
+ compression,
184
+ chunking,
185
+ recipients,
186
+ merkleThreshold,
187
+ });
176
188
  ```
177
189
 
178
190
  Stores content from an async iterable source.
@@ -190,6 +202,7 @@ Stores content from an async iterable source.
190
202
  - `encryption.convergent` (optional): `boolean` - Explicit convergent opt-in/opt-out when `encryption.scheme` is omitted
191
203
  - `kdfOptions` (optional): `Object` - KDF options when using `passphrase` (`{ algorithm, iterations, cost, ... }`). New passphrase stores default to PBKDF2 `600000` iterations or scrypt `N=131072`, and out-of-policy values fail with `KDF_POLICY_VIOLATION`
192
204
  - `compression` (optional): `{ algorithm: 'gzip' }` - Enable compression before encryption/chunking
205
+ - `chunking` (optional): `{ strategy: 'fixed' | 'cdc', chunkSize?, targetChunkSize?, minChunkSize?, maxChunkSize?, normalized? }` - Per-operation chunking override. It affects only this store call; the facade's default chunker is unchanged
193
206
  - `recipients` (optional): `Array<{ label: string, key: Uint8Array }>` - Envelope recipients for multi-recipient encryption (mutually exclusive with `encryptionKey`/`passphrase`)
194
207
  - `merkleThreshold` (optional): `number` - Per-operation chunk count threshold used when this manifest is later published with `createTree()`
195
208
 
@@ -232,6 +245,7 @@ await cas.storeFile({
232
245
  encryption,
233
246
  kdfOptions,
234
247
  compression,
248
+ chunking,
235
249
  recipients,
236
250
  merkleThreshold,
237
251
  });
@@ -252,6 +266,7 @@ Convenience method that opens a file and stores it.
252
266
  - `encryption.convergent` (optional): `boolean` - Explicit convergent opt-in/opt-out when `encryption.scheme` is omitted
253
267
  - `kdfOptions` (optional): `Object` - KDF options when using `passphrase`. New passphrase stores default to PBKDF2 `600000` iterations or scrypt `N=131072`, and out-of-policy values fail with `KDF_POLICY_VIOLATION`
254
268
  - `compression` (optional): `{ algorithm: 'gzip' }` - Enable compression
269
+ - `chunking` (optional): `{ strategy: 'fixed' | 'cdc', chunkSize?, targetChunkSize?, minChunkSize?, maxChunkSize?, normalized? }` - Per-operation chunking override. It affects only this file store; the facade's default chunker is unchanged
255
270
  - `recipients` (optional): `Array<{ label: string, key: Uint8Array }>` - Envelope recipients for multi-recipient encryption (mutually exclusive with `encryptionKey`/`passphrase`)
256
271
  - `merkleThreshold` (optional): `number` - Per-operation chunk count threshold used when this manifest is later published with `createTree()`
257
272
 
@@ -266,6 +281,7 @@ const manifest = await cas.storeFile({
266
281
  filePath: '/path/to/file.txt',
267
282
  slug: 'my-asset',
268
283
  encryptionKey: key,
284
+ chunking: { strategy: 'cdc' },
269
285
  });
270
286
  ```
271
287
 
@@ -1231,14 +1247,14 @@ git cas rotate --slug demo/hello \
1231
1247
 
1232
1248
  #### `git cas vault rotate` flags
1233
1249
 
1234
- | Flag | Description |
1235
- | ----------------------------- | ------------------------------------------------------- |
1236
- | `--old-passphrase <pass>` | Current inline passphrase (warns; prefer file) |
1237
- | `--new-passphrase <pass>` | New inline passphrase (warns; prefer file) |
1238
- | `--old-passphrase-file <path>` | Read current passphrase from file (`-` for stdin) |
1239
- | `--new-passphrase-file <path>` | Read new passphrase from file (`-` for stdin) |
1240
- | `--algorithm <alg>` | KDF algorithm for new passphrase (`pbkdf2` or `scrypt`) |
1241
- | `--cwd <dir>` | Git working directory (default: `.`) |
1250
+ | Flag | Description |
1251
+ | ------------------------------ | ------------------------------------------------------- |
1252
+ | `--old-passphrase <pass>` | Current inline passphrase (warns; prefer file) |
1253
+ | `--new-passphrase <pass>` | New inline passphrase (warns; prefer file) |
1254
+ | `--old-passphrase-file <path>` | Read current passphrase from file (`-` for stdin) |
1255
+ | `--new-passphrase-file <path>` | Read new passphrase from file (`-` for stdin) |
1256
+ | `--algorithm <alg>` | KDF algorithm for new passphrase (`pbkdf2` or `scrypt`) |
1257
+ | `--cwd <dir>` | Git working directory (default: `.`) |
1242
1258
 
1243
1259
  ### Vault History
1244
1260
 
@@ -1264,7 +1280,21 @@ Core domain service implementing CAS operations. Usually accessed via ContentAdd
1264
1280
  ### Constructor
1265
1281
 
1266
1282
  ```javascript
1267
- new CasService({ persistence, codec, crypto, observability, chunkSize, merkleThreshold, concurrency, chunker, compressionAdapter, maxRestoreBufferSize, maxBlobSize, formatVersion, legacyMode });
1283
+ new CasService({
1284
+ persistence,
1285
+ codec,
1286
+ crypto,
1287
+ observability,
1288
+ chunkSize,
1289
+ merkleThreshold,
1290
+ concurrency,
1291
+ chunker,
1292
+ compressionAdapter,
1293
+ maxRestoreBufferSize,
1294
+ maxBlobSize,
1295
+ formatVersion,
1296
+ legacyMode,
1297
+ });
1268
1298
  ```
1269
1299
 
1270
1300
  **Parameters:**
@@ -1319,7 +1349,7 @@ const service = new CasService({
1319
1349
 
1320
1350
  All methods from ContentAddressableStore delegate to CasService. See ContentAddressableStore documentation above for:
1321
1351
 
1322
- - `store({ source, slug, filename, encryptionKey, passphrase, encryption, kdfOptions, compression, recipients })`
1352
+ - `store({ source, slug, filename, encryptionKey, passphrase, encryption, kdfOptions, compression, chunker, recipients })`
1323
1353
  - `restore({ manifest, encryptionKey, passphrase })`
1324
1354
  - `restoreStream({ manifest, encryptionKey, passphrase })`
1325
1355
  - `createTree({ manifest })`
@@ -2107,39 +2137,39 @@ new CasError({ message, code, meta, documentationUrl });
2107
2137
 
2108
2138
  ### Error Codes
2109
2139
 
2110
- | Code | Description | Thrown By |
2111
- | ------------------------------------- | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
2112
- | `INVALID_KEY_TYPE` | Encryption key must be a Uint8Array | `encrypt()`, `decrypt()`, `store()`, `restore()` |
2113
- | `INVALID_KEY_LENGTH` | Encryption key must be exactly 32 bytes | `encrypt()`, `decrypt()`, `store()`, `restore()` |
2114
- | `MISSING_KEY` | Encryption key required to restore encrypted content but none was provided | `restore()` |
2115
- | `INTEGRITY_ERROR` | Chunk digest verification failed or decryption authentication failed | `restore()`, `verifyIntegrity()`, `decrypt()` |
2116
- | `PERSISTENCE_CAPABILITY_REQUIRED` | Buffered restore mode requires `readBlobStream()` so `maxRestoreBufferSize` can be enforced with memory-safe reads | `restore()`, `restoreStream()` |
2117
- | `DECRYPTION_BUFFER_EXCEEDED` | Web Crypto whole-object decrypt exceeded the configured buffer limit | `createDecryptionStream()` via Web Crypto restore paths |
2118
- | `KDF_POLICY_VIOLATION` | KDF parameters fell outside the accepted policy window | `store()`, `restore()`, `initVault()`, `rotateVaultPassphrase()`, `readState()` |
2119
- | `STREAM_ERROR` | Stream error occurred during store operation | `store()` |
2120
- | `STORE_ERROR` | Chunk write failed during store after dispatch | `store()` |
2121
- | `MANIFEST_NOT_FOUND` | No manifest entry found in the Git tree | `readManifest()`, `inspectAsset()`, `collectReferencedChunks()` |
2122
- | `GIT_ERROR` | Underlying Git plumbing command failed | `readManifest()`, `inspectAsset()`, `collectReferencedChunks()` |
2123
- | `GIT_REF_NOT_FOUND` | Git ref lookup found no ref; vault reads normalize this to empty state | `GitRefAdapter`, `VaultPersistence` |
2124
- | `INVALID_OPTIONS` | Mutually exclusive options provided or unsupported option value | `store()`, `restore()` |
2125
- | `INVALID_SLUG` | Slug fails validation (empty, control chars, `..` segments, etc.) | `addToVault()` |
2126
- | `VAULT_ENTRY_NOT_FOUND` | Slug does not exist in vault | `removeFromVault()`, `resolveVaultEntry()` |
2127
- | `VAULT_ENTRY_EXISTS` | Slug already exists (use `force` to overwrite) | `addToVault()` |
2128
- | `VAULT_CONFLICT` | Concurrent vault update detected (CAS failure after retries) | `addToVault()`, `removeFromVault()`, `initVault()`, `rotateVaultPassphrase()` |
2129
- | `VAULT_REF_MISSING` | Vault ref is absent during diagnostics | `git cas doctor` |
2130
- | `VAULT_REF_UPDATE_FAILED` | Vault ref update failed for a non-CAS reason | `addToVault()`, `removeFromVault()`, `initVault()`, `rotateVaultPassphrase()` |
2131
- | `VAULT_HEAD_INVALID` | Vault ref exists but cannot be resolved to a readable commit tree | `readState()`, `getVaultMetadata()`, `git cas doctor` |
2132
- | `VAULT_METADATA_INVALID` | `.vault.json` malformed, unknown version, unsupported cipher, or missing required fields | `readState()`, `rotateVaultPassphrase()`, `git cas doctor` |
2133
- | `VAULT_PRIVACY_INDEX_INVALID` | Privacy index metadata, payload, or raw HMAC tree coverage is invalid | `readState()`, `listVault()`, `resolveVaultEntry()`, `git cas doctor` |
2134
- | `VAULT_PRIVACY_INDEX_MISSING` | Privacy mode is enabled but `.privacy-index` is missing | `readState()`, `listVault()`, `git cas doctor` |
2135
- | `VAULT_PRIVACY_KEY_REQUIRED` | Privacy mode requires a vault encryption key for state reads | `readState()`, `listVault()`, `resolveVaultEntry()` |
2136
- | `VAULT_ENCRYPTION_ALREADY_CONFIGURED` | Cannot reconfigure encryption without key rotation | `initVault()` |
2137
- | `NO_MATCHING_RECIPIENT` | No recipient entry matches the provided KEK | `restore()`, `rotateKey()` |
2138
- | `DEK_UNWRAP_FAILED` | Failed to unwrap DEK with the provided KEK | `addRecipient()`, `rotateKey()` |
2139
- | `RECIPIENT_NOT_FOUND` | Recipient label not found in manifest | `removeRecipient()`, `rotateKey()` |
2140
- | `RECIPIENT_ALREADY_EXISTS` | Recipient label already exists | `addRecipient()` |
2141
- | `CANNOT_REMOVE_LAST_RECIPIENT` | Cannot remove the last recipient | `removeRecipient()` |
2142
- | `ROTATION_NOT_SUPPORTED` | Key rotation requires envelope encryption (recipients) | `rotateKey()` |
2140
+ | Code | Description | Thrown By |
2141
+ | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
2142
+ | `INVALID_KEY_TYPE` | Encryption key must be a Uint8Array | `encrypt()`, `decrypt()`, `store()`, `restore()` |
2143
+ | `INVALID_KEY_LENGTH` | Encryption key must be exactly 32 bytes | `encrypt()`, `decrypt()`, `store()`, `restore()` |
2144
+ | `MISSING_KEY` | Encryption key required to restore encrypted content but none was provided | `restore()` |
2145
+ | `INTEGRITY_ERROR` | Chunk digest verification failed or decryption authentication failed | `restore()`, `verifyIntegrity()`, `decrypt()` |
2146
+ | `PERSISTENCE_CAPABILITY_REQUIRED` | Buffered restore mode requires `readBlobStream()` so `maxRestoreBufferSize` can be enforced with memory-safe reads | `restore()`, `restoreStream()` |
2147
+ | `DECRYPTION_BUFFER_EXCEEDED` | Web Crypto whole-object decrypt exceeded the configured buffer limit | `createDecryptionStream()` via Web Crypto restore paths |
2148
+ | `KDF_POLICY_VIOLATION` | KDF parameters fell outside the accepted policy window | `store()`, `restore()`, `initVault()`, `rotateVaultPassphrase()`, `readState()` |
2149
+ | `STREAM_ERROR` | Stream error occurred during store operation | `store()` |
2150
+ | `STORE_ERROR` | Chunk write failed during store after dispatch | `store()` |
2151
+ | `MANIFEST_NOT_FOUND` | No manifest entry found in the Git tree | `readManifest()`, `inspectAsset()`, `collectReferencedChunks()` |
2152
+ | `GIT_ERROR` | Underlying Git plumbing command failed | `readManifest()`, `inspectAsset()`, `collectReferencedChunks()` |
2153
+ | `GIT_REF_NOT_FOUND` | Git ref lookup found no ref; vault reads normalize this to empty state | `GitRefAdapter`, `VaultPersistence` |
2154
+ | `INVALID_OPTIONS` | Mutually exclusive options provided or unsupported option value | `store()`, `restore()` |
2155
+ | `INVALID_SLUG` | Slug fails validation (empty, control chars, `..` segments, etc.) | `addToVault()` |
2156
+ | `VAULT_ENTRY_NOT_FOUND` | Slug does not exist in vault | `removeFromVault()`, `resolveVaultEntry()` |
2157
+ | `VAULT_ENTRY_EXISTS` | Slug already exists (use `force` to overwrite) | `addToVault()` |
2158
+ | `VAULT_CONFLICT` | Concurrent vault update detected (CAS failure after retries) | `addToVault()`, `removeFromVault()`, `initVault()`, `rotateVaultPassphrase()` |
2159
+ | `VAULT_REF_MISSING` | Vault ref is absent during diagnostics | `git cas doctor` |
2160
+ | `VAULT_REF_UPDATE_FAILED` | Vault ref update failed for a non-CAS reason | `addToVault()`, `removeFromVault()`, `initVault()`, `rotateVaultPassphrase()` |
2161
+ | `VAULT_HEAD_INVALID` | Vault ref exists but cannot be resolved to a readable commit tree | `readState()`, `getVaultMetadata()`, `git cas doctor` |
2162
+ | `VAULT_METADATA_INVALID` | `.vault.json` malformed, unknown version, unsupported cipher, or missing required fields | `readState()`, `rotateVaultPassphrase()`, `git cas doctor` |
2163
+ | `VAULT_PRIVACY_INDEX_INVALID` | Privacy index metadata, payload, or raw HMAC tree coverage is invalid | `readState()`, `listVault()`, `resolveVaultEntry()`, `git cas doctor` |
2164
+ | `VAULT_PRIVACY_INDEX_MISSING` | Privacy mode is enabled but `.privacy-index` is missing | `readState()`, `listVault()`, `git cas doctor` |
2165
+ | `VAULT_PRIVACY_KEY_REQUIRED` | Privacy mode requires a vault encryption key for state reads | `readState()`, `listVault()`, `resolveVaultEntry()` |
2166
+ | `VAULT_ENCRYPTION_ALREADY_CONFIGURED` | Cannot reconfigure encryption without key rotation | `initVault()` |
2167
+ | `NO_MATCHING_RECIPIENT` | No recipient entry matches the provided KEK | `restore()`, `rotateKey()` |
2168
+ | `DEK_UNWRAP_FAILED` | Failed to unwrap DEK with the provided KEK | `addRecipient()`, `rotateKey()` |
2169
+ | `RECIPIENT_NOT_FOUND` | Recipient label not found in manifest | `removeRecipient()`, `rotateKey()` |
2170
+ | `RECIPIENT_ALREADY_EXISTS` | Recipient label already exists | `addRecipient()` |
2171
+ | `CANNOT_REMOVE_LAST_RECIPIENT` | Cannot remove the last recipient | `removeRecipient()` |
2172
+ | `ROTATION_NOT_SUPPORTED` | Key rotation requires envelope encryption (recipients) | `rotateKey()` |
2143
2173
 
2144
2174
  ### Error Handling
2145
2175