@git-stunts/git-cas 6.5.4 → 6.5.6

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.
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { statSync } from 'node:fs';
7
- import { CLEAR_LINE_RETURN, progressBar } from '@flyingrobots/bijou';
7
+ import { CLEAR_LINE_RETURN, cursorGuard, progressBar } from '@flyingrobots/bijou';
8
8
  import { getCliContext } from './context.js';
9
9
 
10
10
  /**
@@ -43,7 +43,13 @@ function formatBytes(bytes) {
43
43
  * @param {import('@flyingrobots/bijou').BijouContext} [options.ctx] - Context override.
44
44
  * @returns {ProgressTracker}
45
45
  */
46
- export function createStoreProgress({ filePath, chunkSize, quiet, fileSize: providedSize, ctx: providedCtx }) {
46
+ export function createStoreProgress({
47
+ filePath,
48
+ chunkSize,
49
+ quiet,
50
+ fileSize: providedSize,
51
+ ctx: providedCtx,
52
+ }) {
47
53
  if (quiet) {
48
54
  return { attach() {}, detach() {} };
49
55
  }
@@ -92,6 +98,7 @@ export function createRestoreProgress({ totalChunks, quiet, ctx: providedCtx })
92
98
  * @property {number | null} startTime
93
99
  * @property {Observer | null} service
94
100
  * @property {((evt: { size: number }) => void) | null} handler
101
+ * @property {import('@flyingrobots/bijou').CursorHideHandle | null} cursorHandle
95
102
  */
96
103
 
97
104
  /**
@@ -102,18 +109,77 @@ export function createRestoreProgress({ totalChunks, quiet, ctx: providedCtx })
102
109
  * @param {{ ctx: import('@flyingrobots/bijou').BijouContext, totalChunks: number, label: string, width: number }} deps
103
110
  */
104
111
  function handleChunkEvent({ size }, state, deps) {
105
- if (!state.startTime) { state.startTime = Date.now(); }
112
+ if (!state.startTime) {
113
+ state.startTime = Date.now();
114
+ }
106
115
  state.chunksProcessed++;
107
116
  state.bytesProcessed += size;
117
+ renderProgress(state, deps);
118
+ }
119
+
120
+ /**
121
+ * Render the current tracker state without mutating its counters.
122
+ *
123
+ * @param {TrackerState} state
124
+ * @param {{ ctx: import('@flyingrobots/bijou').BijouContext, totalChunks: number, label: string, width: number }} deps
125
+ */
126
+ function renderProgress(state, deps) {
108
127
  const pct = (state.chunksProcessed / deps.totalChunks) * 100;
109
- const elapsed = (Date.now() - state.startTime) / 1000;
128
+ const elapsed = state.startTime ? (Date.now() - state.startTime) / 1000 : 0;
110
129
  const throughput = elapsed > 0 ? state.bytesProcessed / elapsed : 0;
111
130
  if (deps.ctx.mode === 'interactive') {
112
131
  const status = ` ${deps.label} ${state.chunksProcessed}/${deps.totalChunks} ${formatBytes(throughput)}/s `;
113
132
  const barStr = progressBar(pct, { width: deps.width, showPercent: false, ctx: deps.ctx });
114
133
  deps.ctx.io.writeError(`${CLEAR_LINE_RETURN}${status}${barStr}`);
115
- } else if (state.chunksProcessed === 1 || state.chunksProcessed === deps.totalChunks || state.chunksProcessed % 10 === 0) {
116
- deps.ctx.io.writeError(`${deps.label} ${state.chunksProcessed}/${deps.totalChunks} ${Math.round(pct)}%\n`);
134
+ } else if (
135
+ state.chunksProcessed === 1 ||
136
+ state.chunksProcessed === deps.totalChunks ||
137
+ state.chunksProcessed % 10 === 0
138
+ ) {
139
+ deps.ctx.io.writeError(
140
+ `${deps.label} ${state.chunksProcessed}/${deps.totalChunks} ${Math.round(pct)}%\n`
141
+ );
142
+ }
143
+ }
144
+
145
+ function releaseTracker(state) {
146
+ state.cursorHandle?.dispose();
147
+ state.cursorHandle = null;
148
+ state.service = null;
149
+ state.handler = null;
150
+ }
151
+
152
+ function attachProgress(svc, state, deps) {
153
+ state.service = svc;
154
+ state.handler = (/** @type {{ size: number }} */ evt) => handleChunkEvent(evt, state, deps);
155
+ try {
156
+ if (deps.ctx.mode === 'interactive') {
157
+ state.cursorHandle = cursorGuard(deps.ctx.io).hide();
158
+ renderProgress(state, deps);
159
+ }
160
+ state.service.on(deps.event, state.handler);
161
+ } catch (error) {
162
+ releaseTracker(state);
163
+ throw error;
164
+ }
165
+ }
166
+
167
+ function detachProgress(state, deps) {
168
+ try {
169
+ if (state.service && state.handler) {
170
+ state.service.removeListener(deps.event, state.handler);
171
+ }
172
+ const elapsed = state.startTime ? (Date.now() - state.startTime) / 1000 : 0;
173
+ const throughput = elapsed > 0 ? state.bytesProcessed / elapsed : 0;
174
+ if (deps.ctx.mode === 'interactive') {
175
+ deps.ctx.io.writeError(
176
+ `${CLEAR_LINE_RETURN} ${deps.label} ${state.chunksProcessed}/${deps.totalChunks} done ${formatBytes(throughput)}/s\n`
177
+ );
178
+ } else {
179
+ deps.ctx.io.writeError(`${deps.label} ${state.chunksProcessed}/${deps.totalChunks} done\n`);
180
+ }
181
+ } finally {
182
+ releaseTracker(state);
117
183
  }
118
184
  }
119
185
 
@@ -126,29 +192,23 @@ function handleChunkEvent({ size }, state, deps) {
126
192
  function createProgressTracker({ ctx, totalChunks, event, label }) {
127
193
  const width = Math.min(40, (ctx.runtime.columns || 80) - 30);
128
194
  /** @type {TrackerState} */
129
- const state = { chunksProcessed: 0, bytesProcessed: 0, startTime: null, service: null, handler: null };
130
- const deps = { ctx, totalChunks, label, width };
195
+ const state = {
196
+ chunksProcessed: 0,
197
+ bytesProcessed: 0,
198
+ startTime: null,
199
+ service: null,
200
+ handler: null,
201
+ cursorHandle: null,
202
+ };
203
+ const deps = { ctx, totalChunks, event, label, width };
131
204
 
132
205
  return {
133
206
  /** @param {Observer} svc */
134
207
  attach(svc) {
135
- state.service = svc;
136
- state.handler = (/** @type {{ size: number }} */ evt) => handleChunkEvent(evt, state, deps);
137
- if (ctx.mode === 'interactive') {
138
- ctx.io.writeError('\x1b[?25l'); // hide cursor
139
- handleChunkEvent({ size: 0 }, state, deps);
140
- }
141
- state.service.on(event, state.handler);
208
+ attachProgress(svc, state, deps);
142
209
  },
143
210
  detach() {
144
- if (state.service && state.handler) { state.service.removeListener(event, state.handler); }
145
- const elapsed = state.startTime ? (Date.now() - state.startTime) / 1000 : 0;
146
- const throughput = elapsed > 0 ? state.bytesProcessed / elapsed : 0;
147
- if (ctx.mode === 'interactive') {
148
- ctx.io.writeError(`${CLEAR_LINE_RETURN} ${label} ${state.chunksProcessed}/${totalChunks} done ${formatBytes(throughput)}/s\n\x1b[?25h`); // show cursor
149
- } else {
150
- ctx.io.writeError(`${label} ${state.chunksProcessed}/${totalChunks} done\n`);
151
- }
211
+ detachProgress(state, deps);
152
212
  },
153
213
  };
154
214
  }
package/bin/ui/theme.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Shared visual language for git-cas terminal surfaces.
3
3
  */
4
4
 
5
- import { parseAnsiToSurface } from '@flyingrobots/bijou';
5
+ import { defineThemeSafePairs, parseAnsiToSurface } from '@flyingrobots/bijou';
6
6
 
7
7
  export const GIT_CAS_PALETTE = {
8
8
  ghost: [251, 252, 252],
@@ -31,16 +31,18 @@ function token(rgb, modifiers = [], bg) {
31
31
  };
32
32
  }
33
33
 
34
- const {
35
- ghost, pearl, slate, cyan, orange, midnight, ink, ruby, sky, violet, deepSlate,
36
- } = GIT_CAS_PALETTE;
34
+ const { ghost, slate, cyan, orange, midnight, ink, ruby, sky, violet, deepSlate } = GIT_CAS_PALETTE;
35
+
36
+ const secondaryBackground = [43, 58, 68];
37
+ const elevatedBackground = [51, 68, 78];
38
+ const mutedBackground = [31, 41, 49];
37
39
 
38
40
  /**
39
- * Bijou v5 theme for the git-cas cockpit.
41
+ * Bijou v7 theme for the git-cas cockpit.
40
42
  *
41
43
  * Keep this object aligned with Bijou's public Theme shape. App-specific
42
- * colors belong in local helpers, not in stray token groups that components
43
- * will never read.
44
+ * surface tokens are registered under `ui` so Bijou's theme doctor can verify
45
+ * every foreground/background relationship used by the cockpit.
44
46
  */
45
47
  export const GIT_CAS_THEME = {
46
48
  name: 'git-cas-cockpit',
@@ -51,7 +53,7 @@ export const GIT_CAS_THEME = {
51
53
  info: token(sky),
52
54
  pending: token(slate),
53
55
  active: token(cyan, ['bold']),
54
- muted: token(deepSlate),
56
+ muted: token(slate),
55
57
  },
56
58
  semantic: {
57
59
  success: token(cyan, ['bold']),
@@ -91,22 +93,47 @@ export const GIT_CAS_THEME = {
91
93
  logo: token(cyan, ['bold']),
92
94
  tableHeader: token(ghost, ['bold']),
93
95
  trackEmpty: token(deepSlate),
96
+ canvas: token(midnight),
97
+ secondaryCanvas: token(secondaryBackground),
98
+ elevatedCanvas: token(elevatedBackground),
99
+ overlayCanvas: token(ink),
100
+ mutedCanvas: token(mutedBackground),
94
101
  },
95
102
  surface: {
96
103
  primary: token(ghost, [], midnight),
97
- secondary: token(pearl, [], [43, 58, 68]),
98
- elevated: token(ghost, [], [51, 68, 78]),
104
+ secondary: token(ghost, [], secondaryBackground),
105
+ elevated: token(ghost, [], elevatedBackground),
99
106
  overlay: token(ghost, [], ink),
100
- muted: token(slate, [], [31, 41, 49]),
107
+ muted: token(ghost, [], mutedBackground),
101
108
  },
102
109
  };
103
110
 
111
+ /**
112
+ * High-contrast foreground/background contracts selected with Design Book and
113
+ * enforced by Bijou's theme doctor. Decorative track and border colors are not
114
+ * text pairs and are intentionally excluded.
115
+ */
116
+ export const GIT_CAS_THEME_SAFE_PAIRS = defineThemeSafePairs()
117
+ .readable('surface.primary', 'ui.canvas', { label: 'primary surface text' })
118
+ .readable('surface.secondary', 'ui.secondaryCanvas', { label: 'secondary surface text' })
119
+ .readable('surface.elevated', 'ui.elevatedCanvas', { label: 'elevated surface text' })
120
+ .readable('surface.overlay', 'ui.overlayCanvas', { label: 'overlay surface text' })
121
+ .readable('surface.muted', 'ui.mutedCanvas', { label: 'muted surface text' })
122
+ .readable('semantic.primary', 'ui.canvas', { label: 'primary cockpit text' })
123
+ .readable('semantic.muted', 'ui.canvas', { label: 'muted cockpit text' })
124
+ .status('semantic.success', 'ui.canvas', { label: 'success cockpit text' })
125
+ .status('semantic.error', 'ui.canvas', { label: 'error cockpit text' })
126
+ .status('semantic.warning', 'ui.canvas', { label: 'warning cockpit text' })
127
+ .status('semantic.info', 'ui.canvas', { label: 'informational cockpit text' })
128
+ .status('semantic.accent', 'ui.canvas', { label: 'accent cockpit text' })
129
+ .build();
130
+
104
131
  const TEXT_TONES = {
105
132
  brand: { fg: cyan, bold: true },
106
133
  accent: { fg: orange, bold: true },
107
134
  primary: { fg: ghost },
108
135
  secondary: { fg: slate },
109
- subdued: { fg: deepSlate },
136
+ subdued: { fg: slate },
110
137
  info: { fg: sky, bold: true },
111
138
  violet: { fg: violet, bold: true },
112
139
  success: { fg: cyan, bold: true },
package/build-info.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "a2d23f5",
3
- "timestamp": "2026-07-26T13:59:44.601Z"
2
+ "sha": "257e882",
3
+ "timestamp": "2026-07-30T08:25:55.465Z"
4
4
  }
@@ -0,0 +1,43 @@
1
+ # git-cas v6.5.5 Release Notes
2
+
3
+ v6.5.5 makes every git-cas-owned Git commit independent of ambient user
4
+ configuration. Root-set, publication, and vault writes now work in a clean bare
5
+ repository without configuring a personal author or committer.
6
+
7
+ ## Self-Contained Commit Identity
8
+
9
+ `GitRefAdapter.createCommit()` supplies this stable identity to each internal
10
+ `git commit-tree` operation:
11
+
12
+ ```text
13
+ git-cas <git-cas@example.invalid>
14
+ ```
15
+
16
+ The identity is scoped to the individual Git command. git-cas does not invoke
17
+ `git config`, mutate repository or global settings, or require applications to
18
+ provide personal identity.
19
+
20
+ This fixes storage writes performed against bare or automation-owned
21
+ repositories where `user.name` and `user.email` are deliberately absent. The
22
+ failure was exposed by a clean-Linux retained-substrate migration rehearsal:
23
+ post-promotion root-set retention reached `git commit-tree`, which otherwise
24
+ stopped with `Author identity unknown`.
25
+
26
+ ## Verification
27
+
28
+ Unit coverage observes all four author and committer environment variables.
29
+ Real-Git integration reads a root-set commit through native Git and verifies
30
+ both headers exactly. The versioned release candidate passed the complete
31
+ Node, Bun, and Deno unit and integration matrix, public type compatibility,
32
+ examples, lint, build stamping, and package dry-runs.
33
+
34
+ ## Compatibility
35
+
36
+ This release changes no public API or stored-data schema and requires no
37
+ migration. Existing refs, objects, handles, and retained generations remain
38
+ valid.
39
+
40
+ Git identity is part of commit bytes, so newly created internal commit OIDs may
41
+ differ from commits that previously inherited an operator identity. Internal
42
+ commit OIDs remain opaque generations; callers must not derive them in advance
43
+ or interpret personal attribution from them.
@@ -0,0 +1,55 @@
1
+ # git-cas v6.5.6 Release Notes
2
+
3
+ v6.5.6 moves the interactive cockpit onto Bijou 7.2's hosted application
4
+ boundary and makes checked Git ref conflicts independent of diagnostic prose.
5
+ It changes no public package API or stored-data schema.
6
+
7
+ ## Bijou 7 Hosted Cockpit
8
+
9
+ The interactive launcher now runs a `FramedApp`. Bijou owns terminal lifecycle,
10
+ outer chrome, help, command and asset-search palettes, settings, notifications,
11
+ performance telemetry, quit confirmation, and reference-counted cursor state.
12
+ The git-cas page continues to own vault authentication, storage state,
13
+ Explorer/Atlas/Operations navigation, filtering, and the Store Wizard.
14
+
15
+ Store and restore progress use Bijou's shared cursor guard and render the
16
+ initial `0/N` state without incrementing the processed count. Frame and page
17
+ tests preserve ordinary modal input, page-first key ownership, structured
18
+ stdout, and the static noninteractive fallback.
19
+
20
+ Design Book selected the high-contrast foregrounds for the dark cockpit
21
+ surfaces. Bijou's theme doctor and explicit text-tone tests enforce a minimum
22
+ 4.5:1 contrast ratio.
23
+
24
+ ## Deterministic Checked-Ref Conflicts
25
+
26
+ Failed checked updates, atomic anchors, and checked deletes no longer inspect
27
+ Git's human-readable diagnostics. The Git adapter reads structured post-failure
28
+ posture—direct OID, symbolic target, or absence—and normalizes only when that
29
+ posture disproves the attempted compare-and-swap precondition.
30
+
31
+ The existing contracts remain:
32
+
33
+ - checked updates and deletes reject with `GIT_REF_CONFLICT` plus structured
34
+ expected and observed posture;
35
+ - atomic anchors return `false` when their source changed or target appeared;
36
+ - operational failures remain the original error when the attempted ref
37
+ precondition still holds.
38
+
39
+ Diagnostic-free unit and real-Git tests cover changed, absent, and symbolic
40
+ posture across all three mutation paths.
41
+
42
+ ## Verification
43
+
44
+ The release candidate passed the repository's complete 14-step verifier with
45
+ 6,898 observed tests across Node, Bun, and Deno. The matrix includes public
46
+ type compatibility, executable examples, 199 real-Git integration tests on
47
+ each runtime, build stamping, and npm and JSR dry-runs.
48
+
49
+ ## Compatibility
50
+
51
+ This release requires no application or stored-data migration. Existing refs,
52
+ objects, handles, cockpit lower modes, machine-readable output, and package
53
+ exports remain valid. Interactive operators receive the hosted Bijou shell
54
+ automatically; callers receive more reliable existing conflict semantics
55
+ without changing method signatures.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git-stunts/git-cas",
3
- "version": "6.5.4",
3
+ "version": "6.5.6",
4
4
  "description": "Content-addressed storage backed by Git's object database, with optional encryption and pluggable codecs",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -41,6 +41,8 @@
41
41
  "docs/releases/v6.5.2.md",
42
42
  "docs/releases/v6.5.3.md",
43
43
  "docs/releases/v6.5.4.md",
44
+ "docs/releases/v6.5.5.md",
45
+ "docs/releases/v6.5.6.md",
44
46
  "docs/THREAT_MODEL.md",
45
47
  "docs/VAULT_INTERNALS.md",
46
48
  "docs/WALKTHROUGH.md",
@@ -101,10 +103,10 @@
101
103
  "format": "prettier --write ."
102
104
  },
103
105
  "dependencies": {
104
- "@flyingrobots/bijou": "^5.0.0",
105
- "@flyingrobots/bijou-node": "^5.0.0",
106
- "@flyingrobots/bijou-tui": "^5.0.0",
107
- "@flyingrobots/bijou-tui-app": "^5.0.0",
106
+ "@flyingrobots/bijou": "^7.2.0",
107
+ "@flyingrobots/bijou-node": "^7.2.0",
108
+ "@flyingrobots/bijou-tui": "^7.2.0",
109
+ "@flyingrobots/bijou-tui-app": "^7.2.0",
108
110
  "@git-stunts/alfred": "^0.10.0",
109
111
  "@git-stunts/plumbing": "^3.2.0",
110
112
  "@git-stunts/vault": "^1.0.1",
@@ -1,7 +1,7 @@
1
1
  import { Policy } from '@git-stunts/alfred';
2
2
  import GitRefPort from '../../ports/GitRefPort.js';
3
3
  import { CasError, ErrorCodes } from '../../domain/errors/index.js';
4
- import { errorDetailsText, isGitMissingRefError } from '../../domain/helpers/gitRefErrors.js';
4
+ import { isGitMissingRefError } from '../../domain/helpers/gitRefErrors.js';
5
5
  import Oid from '../../domain/value-objects/Oid.js';
6
6
 
7
7
  /**
@@ -14,6 +14,12 @@ import Oid from '../../domain/value-objects/Oid.js';
14
14
  */
15
15
  const DEFAULT_POLICY = Policy.timeout(30_000);
16
16
  const FORBIDDEN_REF_CHARACTERS = new Set(['~', '^', ':', '?', '*', '[', '\\']);
17
+ const INTERNAL_COMMIT_IDENTITY = Object.freeze({
18
+ GIT_AUTHOR_EMAIL: 'git-cas@example.invalid',
19
+ GIT_AUTHOR_NAME: 'git-cas',
20
+ GIT_COMMITTER_EMAIL: 'git-cas@example.invalid',
21
+ GIT_COMMITTER_NAME: 'git-cas',
22
+ });
17
23
  const MAX_REF_ITERATION_LIMIT = 1001;
18
24
  const REF_NAME_ENCODER = new globalThis.TextEncoder();
19
25
 
@@ -103,7 +109,7 @@ export default class GitRefAdapter extends GitRefPort {
103
109
  args.push('-p', parent);
104
110
  }
105
111
  return this.policy.execute(() =>
106
- this.plumbing.execute({ args }),
112
+ this.plumbing.execute({ args, env: INTERNAL_COMMIT_IDENTITY }),
107
113
  );
108
114
  }
109
115
 
@@ -130,9 +136,22 @@ export default class GitRefAdapter extends GitRefPort {
130
136
  if (expectedOldOid !== undefined) {
131
137
  args.push(expectedOldOid ?? '0'.repeat(newOid.length));
132
138
  }
133
- await this.policy.execute(() =>
134
- this.plumbing.execute({ args }),
135
- );
139
+ try {
140
+ await this.policy.execute(() =>
141
+ this.plumbing.execute({ args }),
142
+ );
143
+ } catch (error) {
144
+ const actual = await this.#inspectRefPosture(ref);
145
+ if (postureDisprovesExpectedOid(actual, expectedOldOid)) {
146
+ throw refConflictFromPosture({
147
+ ref,
148
+ expectedOldOid: expectedOldOid ?? null,
149
+ actual,
150
+ originalError: error,
151
+ });
152
+ }
153
+ throw error;
154
+ }
136
155
  }
137
156
 
138
157
  /** @override */
@@ -162,7 +181,12 @@ export default class GitRefAdapter extends GitRefPort {
162
181
  );
163
182
  return true;
164
183
  } catch (error) {
165
- if (isUpdateRefConflict(error, [sourceRef, targetRef])) {
184
+ const sourceActual = await this.#inspectRefPosture(sourceRef);
185
+ if (postureDisprovesExpectedOid(sourceActual, generation)) {
186
+ return false;
187
+ }
188
+ const targetActual = await this.#inspectRefPosture(targetRef);
189
+ if (postureDisprovesExpectedOid(targetActual, null)) {
166
190
  return false;
167
191
  }
168
192
  throw error;
@@ -191,27 +215,16 @@ export default class GitRefAdapter extends GitRefPort {
191
215
  }),
192
216
  );
193
217
  } catch (error) {
194
- if (!isUpdateRefConflict(error, [ref])) {
195
- throw error;
196
- }
197
- const racedSymbolicTarget = await this.#resolveSymbolicRef(ref);
198
- if (racedSymbolicTarget !== null) {
199
- throw refConflict({
218
+ const actual = await this.#inspectRefPosture(ref);
219
+ if (postureDisprovesExpectedOid(actual, expectedGeneration)) {
220
+ throw refConflictFromPosture({
200
221
  ref,
201
222
  expectedOldOid: expectedGeneration,
202
- actualOldOid: null,
203
- actualSymref: racedSymbolicTarget,
223
+ actual,
204
224
  originalError: error,
205
225
  });
206
226
  }
207
- const actual = await this.#inspectDirectRef(ref);
208
- throw refConflict({
209
- ref,
210
- expectedOldOid: expectedGeneration,
211
- actualOldOid: actual?.oid ?? null,
212
- actualSymref: actual?.symref ?? null,
213
- originalError: error,
214
- });
227
+ throw error;
215
228
  }
216
229
  return true;
217
230
  }
@@ -264,6 +277,18 @@ export default class GitRefAdapter extends GitRefPort {
264
277
  });
265
278
  }
266
279
 
280
+ async #inspectRefPosture(ref) {
281
+ const symbolicTarget = await this.#resolveSymbolicRef(ref);
282
+ if (symbolicTarget !== null) {
283
+ return Object.freeze({ oid: null, symref: symbolicTarget });
284
+ }
285
+ const direct = await this.#inspectDirectRef(ref);
286
+ if (direct?.symref) {
287
+ return Object.freeze({ oid: null, symref: direct.symref });
288
+ }
289
+ return Object.freeze({ oid: direct?.oid ?? null, symref: null });
290
+ }
291
+
267
292
  async #resolveSymbolicRef(ref) {
268
293
  try {
269
294
  const output = await this.policy.execute(() =>
@@ -437,17 +462,18 @@ function invalidRefName(ref) {
437
462
  return new CasError('Git ref name or prefix is invalid', ErrorCodes.GIT_ERROR, { ref });
438
463
  }
439
464
 
440
- function isUpdateRefConflict(error, refs) {
441
- const text = errorDetailsText(error).toLowerCase();
442
- return refs.some((ref) => text.includes(ref.toLowerCase()))
443
- && (
444
- text.includes('cannot lock ref') ||
445
- text.includes('but expected') ||
446
- text.includes('reference already exists') ||
447
- text.includes('unable to resolve reference') ||
448
- text.includes('zero <oldvalue>') ||
449
- text.includes('is a symref')
450
- );
465
+ function postureDisprovesExpectedOid(actual, expectedOldOid) {
466
+ if (actual.symref !== null) {
467
+ return true;
468
+ }
469
+ if (expectedOldOid === undefined) {
470
+ return false;
471
+ }
472
+ if (expectedOldOid === null) {
473
+ return actual.oid !== null;
474
+ }
475
+ return actual.oid === null
476
+ || Oid.from(actual.oid).toString() !== Oid.from(expectedOldOid).toString();
451
477
  }
452
478
 
453
479
  function isQuietSymbolicRefMiss(error, ref) {
@@ -473,3 +499,13 @@ function refConflict({
473
499
  { ref, expectedOldOid, actualOldOid, actualSymref, originalError },
474
500
  );
475
501
  }
502
+
503
+ function refConflictFromPosture({ ref, expectedOldOid, actual, originalError }) {
504
+ return refConflict({
505
+ ref,
506
+ expectedOldOid,
507
+ actualOldOid: actual.oid,
508
+ actualSymref: actual.symref,
509
+ originalError,
510
+ });
511
+ }
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '6.5.4';
1
+ export const PACKAGE_VERSION = '6.5.6';
@@ -54,6 +54,8 @@ export default class GitRefPort {
54
54
  * @param {string} _options.newOid - New OID to set.
55
55
  * @param {string|null} [_options.expectedOldOid] - Expected current OID for CAS; `null` means the ref must not exist.
56
56
  * @returns {Promise<void>}
57
+ * @throws A `GIT_REF_CONFLICT` error when observed ref posture disproves the
58
+ * checked mutation precondition.
57
59
  */
58
60
  async updateRef(_options) {
59
61
  throw new Error('Not implemented');
@@ -66,6 +68,8 @@ export default class GitRefPort {
66
68
  * @param {string} _options.expectedSourceOid
67
69
  * @param {string} _options.targetRef
68
70
  * @returns {Promise<boolean>} Whether the source generation was anchored.
71
+ * `false` means observed ref posture disproved the atomic verify/create
72
+ * preconditions.
69
73
  */
70
74
  async anchorRef(_options) {
71
75
  throw unsupportedAcquisitionCapability('anchorRef');
@@ -77,6 +81,8 @@ export default class GitRefPort {
77
81
  * @param {string} _options.ref
78
82
  * @param {string} _options.expectedOldOid
79
83
  * @returns {Promise<boolean>} Whether the ref existed and was deleted.
84
+ * @throws A `GIT_REF_CONFLICT` error when observed ref posture disproves the
85
+ * checked delete precondition.
80
86
  */
81
87
  async deleteRef(_options) {
82
88
  throw unsupportedAcquisitionCapability('deleteRef');