@calltelemetry/fmix 2.7.23 → 2.7.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/fmix +224 -1
  2. package/package.json +3 -3
package/bin/fmix CHANGED
@@ -28,7 +28,7 @@ set -uo pipefail
28
28
  # ---------------------------------------------------------------------------
29
29
  # Constants & config
30
30
  # ---------------------------------------------------------------------------
31
- FMIX_VERSION="2.7.23"
31
+ FMIX_VERSION="2.7.24"
32
32
  FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
33
33
  FMIX_OS="$(uname -s)"
34
34
  FMIX_ARCH="$(uname -m)"
@@ -8061,10 +8061,195 @@ fmix_host_test_lock_enabled() {
8061
8061
  # Worktree resolution: find nearest cisco-cdr checkout from CWD
8062
8062
  # ---------------------------------------------------------------------------
8063
8063
 
8064
+ # REL-3297: fmix probes git as `git -C <worktree> ... 2>/dev/null` in well over
8065
+ # a hundred places. A checkout whose git metadata does not resolve back to the
8066
+ # checkout itself therefore failed far from its cause, most visibly as "Could
8067
+ # not capture a source-stability identity after acquiring the worktree lock".
8068
+ # The usual cause is a linked worktree of a submodule: once
8069
+ # extensions.worktreeConfig is true it inherits the submodule's shared,
8070
+ # relative core.worktree and resolves it against its own per-worktree gitdir.
8071
+ # That names a missing directory, or the module gitdir itself, where a
8072
+ # submodule bootstrap or checkout would write the tree into the git directory.
8073
+ #
8074
+ # Diagnose before any lock, session or submodule work and name the exact config
8075
+ # file and a one-line repair. Values are read with `git config --file` from `/`
8076
+ # because every repository-scoped git command run inside the broken checkout
8077
+ # dies during setup. fmix never rewrites git config itself.
8078
+
8079
+ # Collapse `.`, `..` and repeated slashes in an absolute path without touching
8080
+ # the filesystem, so a core.worktree that names a missing directory can still
8081
+ # be shown where it lands.
8082
+ fmix_lexical_abs_path() {
8083
+ local path="${1:-}" part out=""
8084
+ local -a parts=() kept=()
8085
+ [[ "$path" == /* ]] || return 1
8086
+ IFS='/' read -r -a parts <<<"$path"
8087
+ for part in "${parts[@]+"${parts[@]}"}"; do
8088
+ case "$part" in
8089
+ ''|.) ;;
8090
+ ..)
8091
+ if (( ${#kept[@]} > 0 )); then
8092
+ unset "kept[$(( ${#kept[@]} - 1 ))]"
8093
+ kept=("${kept[@]+"${kept[@]}"}")
8094
+ fi
8095
+ ;;
8096
+ *) kept+=("$part") ;;
8097
+ esac
8098
+ done
8099
+ for part in "${kept[@]+"${kept[@]}"}"; do
8100
+ out="$out/$part"
8101
+ done
8102
+ printf '%s\n' "${out:-/}"
8103
+ }
8104
+
8105
+ # Read one key from one config file, outside any repository and ignoring any
8106
+ # GIT_* environment that would redirect git's own setup.
8107
+ fmix_git_config_file_get() {
8108
+ local file="${1:-}" key="${2:-}"
8109
+ shift 2 || return 1
8110
+ [[ -f "$file" ]] || return 1
8111
+ env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_CONFIG \
8112
+ git -C / config --file "$file" "$@" --get "$key" 2>/dev/null
8113
+ }
8114
+
8115
+ # Print a diagnosis and return 1 when `dir` is a git checkout whose metadata
8116
+ # does not resolve back to `dir`. Silent and 0 for a sound checkout and for a
8117
+ # directory without a `.git` entry (the non-git contract is unchanged).
8118
+ fmix_git_worktree_metadata_report() {
8119
+ local dir="${1:-}" real err_file toplevel="" real_toplevel="" git_err=""
8120
+ local gitfile_line="" gitdir="" commondir="" ext="" bare="" value="" origin=""
8121
+ local resolved="" real_resolved="" where="" fix_file=""
8122
+ [[ -n "$dir" ]] || return 0
8123
+ real="$(fmix_realpath "$dir" 2>/dev/null)" || return 0
8124
+ [[ -n "$real" ]] || return 0
8125
+ [[ -e "$real/.git" || -L "$real/.git" ]] || return 0
8126
+
8127
+ err_file="$(mktemp)" || return 1
8128
+ if toplevel="$(git -C "$real" rev-parse --show-toplevel 2>"$err_file")" && [[ -n "$toplevel" ]]; then
8129
+ real_toplevel="$(fmix_realpath "$toplevel" 2>/dev/null)" || real_toplevel="$toplevel"
8130
+ if [[ "$real_toplevel" == "$real" ]]; then
8131
+ rm -f "$err_file"
8132
+ return 0
8133
+ fi
8134
+ else
8135
+ toplevel=""
8136
+ fi
8137
+ git_err="$(head -n 1 "$err_file" 2>/dev/null)"
8138
+ rm -f "$err_file"
8139
+
8140
+ if [[ -f "$real/.git" ]]; then
8141
+ gitfile_line="$(head -n 1 "$real/.git" 2>/dev/null)"
8142
+ gitdir="${gitfile_line#gitdir: }"
8143
+ [[ "$gitdir" == /* ]] || gitdir="$real/$gitdir"
8144
+ else
8145
+ gitdir="$real/.git"
8146
+ fi
8147
+ if [[ -d "$gitdir" ]]; then
8148
+ gitdir="$(fmix_realpath "$gitdir" 2>/dev/null)" || gitdir="$(fmix_lexical_abs_path "$gitdir")"
8149
+ else
8150
+ gitdir="$(fmix_lexical_abs_path "$gitdir")"
8151
+ printf 'git_worktree_metadata_broken: %s/.git names gitdir %s, which does not exist.\n' "$real" "$gitdir"
8152
+ [[ -z "$git_err" ]] || printf 'git said: %s\n' "$git_err"
8153
+ printf 'fix: run `git worktree repair %s` from the main checkout of this repository, or recreate the worktree.\n' "$real"
8154
+ return 1
8155
+ fi
8156
+ commondir="$gitdir"
8157
+ if [[ -f "$gitdir/commondir" ]]; then
8158
+ commondir="$(head -n 1 "$gitdir/commondir" 2>/dev/null)"
8159
+ [[ "$commondir" == /* ]] || commondir="$gitdir/$commondir"
8160
+ commondir="$(fmix_realpath "$commondir" 2>/dev/null)" || commondir="$(fmix_lexical_abs_path "$commondir")"
8161
+ fi
8162
+
8163
+ ext="$(fmix_git_config_file_get "$commondir/config" extensions.worktreeConfig --bool)" || ext=""
8164
+ if [[ "$ext" == "true" ]] \
8165
+ && value="$(fmix_git_config_file_get "$gitdir/config.worktree" core.worktree)"; then
8166
+ origin="$gitdir/config.worktree"
8167
+ elif value="$(fmix_git_config_file_get "$commondir/config" core.worktree)"; then
8168
+ origin="$commondir/config"
8169
+ # Without extensions.worktreeConfig git ignores the shared value in a
8170
+ # linked worktree, so it cannot be this worktree's cause.
8171
+ if [[ "$gitdir" != "$commondir" && "$ext" != "true" ]]; then
8172
+ value=""
8173
+ origin=""
8174
+ fi
8175
+ else
8176
+ value=""
8177
+ fi
8178
+
8179
+ if [[ -n "$value" ]]; then
8180
+ printf 'git_core_worktree_broken: git cannot resolve %s to itself, so no source identity, receipt or dirty-tree check can run there.\n' "$real"
8181
+ else
8182
+ printf 'git_worktree_metadata_broken: git cannot resolve %s to itself, so no source identity, receipt or dirty-tree check can run there.\n' "$real"
8183
+ fi
8184
+ if [[ -n "$toplevel" ]]; then
8185
+ printf 'git resolves it to %s\n' "${real_toplevel:-$toplevel}"
8186
+ elif [[ -n "$git_err" ]]; then
8187
+ printf 'git said: %s\n' "$git_err"
8188
+ fi
8189
+ printf 'gitdir: %s\n' "$gitdir"
8190
+ if [[ -n "${GIT_DIR:-}" || -n "${GIT_WORK_TREE:-}" ]]; then
8191
+ printf 'environment overrides discovery: GIT_DIR=%s GIT_WORK_TREE=%s\n' "${GIT_DIR:-}" "${GIT_WORK_TREE:-}"
8192
+ fi
8193
+ bare="$(fmix_git_config_file_get "$commondir/config" core.bare --bool)" || bare=""
8194
+ if [[ "$bare" == "true" ]]; then
8195
+ printf 'core.bare = true (set in %s): git treats this repository as having no work tree.\n' "$commondir/config"
8196
+ fi
8197
+
8198
+ if [[ -z "$value" ]]; then
8199
+ printf 'no core.worktree applies to this checkout; check `git -C %s rev-parse --show-toplevel` and the GIT_* environment.\n' "$real"
8200
+ return 1
8201
+ fi
8202
+
8203
+ case "$value" in
8204
+ /*) resolved="$(fmix_lexical_abs_path "$value")" ;;
8205
+ *) resolved="$(fmix_lexical_abs_path "$gitdir/$value")" ;;
8206
+ esac
8207
+ if [[ ! -d "$resolved" ]]; then
8208
+ where="a directory that does not exist"
8209
+ else
8210
+ real_resolved="$(fmix_realpath "$resolved" 2>/dev/null)" || real_resolved="$resolved"
8211
+ case "$real_resolved/" in
8212
+ "$gitdir"/*|"$commondir"/*)
8213
+ where="the git directory itself; a status, checkout or submodule update there acts on the gitdir"
8214
+ ;;
8215
+ *) where="another directory, not this checkout" ;;
8216
+ esac
8217
+ fi
8218
+ printf 'core.worktree = %s (set in %s)\n' "$value" "$origin"
8219
+ printf 'it resolves against %s to %s: %s.\n' "$gitdir" "$resolved" "$where"
8220
+ if [[ "$origin" == "$commondir/config" && "$gitdir" != "$commondir" ]]; then
8221
+ printf 'cause: with extensions.worktreeConfig=true a linked worktree reads the shared core.worktree of %s unless its own config.worktree overrides it, and a relative value resolves against the linked gitdir.\n' "$commondir/config"
8222
+ fi
8223
+ fix_file="$gitdir/config.worktree"
8224
+ [[ "$ext" == "true" ]] || fix_file="$commondir/config"
8225
+ printf "fix (this worktree only): git config --file '%s' core.worktree '%s'\n" "$fix_file" "$real"
8226
+ printf "verify: git -C '%s' rev-parse --show-toplevel must print %s\n" "$real" "$real"
8227
+ return 1
8228
+ }
8229
+
8230
+ # Refuse a checkout whose git metadata is broken, naming the cause on stderr.
8231
+ fmix_require_git_worktree_metadata() {
8232
+ local report line
8233
+ report="$(fmix_git_worktree_metadata_report "${1:-}")" && return 0
8234
+ if [[ -z "$report" ]]; then
8235
+ fmix_error "git_worktree_metadata_broken: could not inspect the git metadata of ${1:-}."
8236
+ return 1
8237
+ fi
8238
+ while IFS= read -r line; do
8239
+ [[ -n "$line" ]] && fmix_error "$line"
8240
+ done <<<"$report"
8241
+ return 1
8242
+ }
8243
+
8064
8244
  fmix_ensure_worktree_submodules() {
8065
8245
  local target_dir="$1"
8066
8246
  local selected_gitlink="${2:-}"
8067
8247
 
8248
+ # REL-3297: never run a submodule bootstrap through git metadata that
8249
+ # resolves to another tree (it could land in the module gitdir). The
8250
+ # caller's fmix_require_git_worktree_metadata names the cause.
8251
+ fmix_git_worktree_metadata_report "$target_dir" >/dev/null || return 0
8252
+
8068
8253
  # Find top-level repo if inside a Git tree
8069
8254
  local top_repo
8070
8255
  top_repo="$(git -C "$target_dir" rev-parse --show-toplevel 2>/dev/null)" || return 0
@@ -8361,7 +8546,17 @@ fmix_worktree_is_cold_submodule() {
8361
8546
  return 1
8362
8547
  }
8363
8548
 
8549
+ # Resolve the cisco-cdr checkout, then refuse it when its git metadata does not
8550
+ # resolve back to it (REL-3297). Every verb that resolves a worktree goes through
8551
+ # here, so the named error replaces the unrelated failures further down.
8364
8552
  fmix_find_worktree() {
8553
+ local found
8554
+ found="$(fmix_find_worktree_resolve "$@")" || return 1
8555
+ fmix_require_git_worktree_metadata "$found" || return 1
8556
+ printf '%s\n' "$found"
8557
+ }
8558
+
8559
+ fmix_find_worktree_resolve() {
8365
8560
  local path="$1"
8366
8561
  # Admission needs a verified candidate without initializing submodules.
8367
8562
  # The default resolution still initializes and verifies the checkout.
@@ -17055,6 +17250,8 @@ cmd_verify_push() {
17055
17250
  local real_worktree
17056
17251
  real_worktree="$(fmix_realpath "$worktree")"
17057
17252
 
17253
+ # REL-3297: name a broken core.worktree instead of "not a git worktree".
17254
+ fmix_require_git_worktree_metadata "$real_worktree" || return 1
17058
17255
  if ! git -C "$real_worktree" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
17059
17256
  fmix_error "Path is not inside a git worktree: $real_worktree"
17060
17257
  return 1
@@ -17248,6 +17445,8 @@ cmd_hook_install() {
17248
17445
  fi
17249
17446
  local real_worktree
17250
17447
  real_worktree="$(fmix_realpath "$worktree")"
17448
+ # REL-3297: name a broken core.worktree instead of "not a git worktree".
17449
+ fmix_require_git_worktree_metadata "$real_worktree" || return 1
17251
17450
  if ! git -C "$real_worktree" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
17252
17451
  fmix_error "Path is not inside a git worktree: $real_worktree"
17253
17452
  return 1
@@ -18918,6 +19117,23 @@ cmd_doctor() {
18918
19117
  worktree="$(fmix_find_worktree "$PWD/cisco-cdr" 2>/dev/null)" || true
18919
19118
  [[ -n "$worktree" ]] && echo " (auto-resolved worktree: $worktree — pass --worktree to be explicit)"
18920
19119
  fi
19120
+ # REL-3297: the lookups above refuse a checkout with broken git metadata and
19121
+ # their stderr is discarded, which used to end in "all checks passed".
19122
+ # Re-resolve without the metadata check (readonly: no submodule bootstrap)
19123
+ # and report it as a failure.
19124
+ local git_metadata_candidate="" git_metadata_report=""
19125
+ if [[ -z "$worktree" ]]; then
19126
+ git_metadata_candidate="$(fmix_find_worktree_resolve "$worktree_arg" readonly 2>/dev/null)" \
19127
+ || git_metadata_candidate=""
19128
+ if [[ -z "$git_metadata_candidate" && "$worktree_arg" == "auto" && -f "$PWD/cisco-cdr/mix.exs" ]]; then
19129
+ git_metadata_candidate="$(fmix_find_worktree_resolve "$PWD/cisco-cdr" readonly 2>/dev/null)" \
19130
+ || git_metadata_candidate=""
19131
+ fi
19132
+ if [[ -n "$git_metadata_candidate" ]]; then
19133
+ git_metadata_report="$(fmix_git_worktree_metadata_report "$git_metadata_candidate")" \
19134
+ && git_metadata_report=""
19135
+ fi
19136
+ fi
18921
19137
 
18922
19138
  # OS detection
18923
19139
  echo " OS: $FMIX_OS $FMIX_ARCH"
@@ -19139,6 +19355,13 @@ cmd_doctor() {
19139
19355
  else
19140
19356
  echo " [INFO] no state file yet — will be created on first run"
19141
19357
  fi
19358
+ elif [[ -n "$git_metadata_report" ]]; then
19359
+ echo " [FAIL] git worktree metadata: $git_metadata_candidate"
19360
+ local git_metadata_line
19361
+ while IFS= read -r git_metadata_line; do
19362
+ [[ -n "$git_metadata_line" ]] && echo " $git_metadata_line"
19363
+ done <<<"$git_metadata_report"
19364
+ fail=$(( fail + 1 ))
19142
19365
  fi
19143
19366
 
19144
19367
  # fmix state dir
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calltelemetry/fmix",
3
- "version": "2.7.23",
3
+ "version": "2.7.24",
4
4
  "description": "Verified native FMix runner for CallTelemetry workspaces",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -26,7 +26,7 @@
26
26
  "directory": "packages/npm"
27
27
  },
28
28
  "fmix": {
29
- "runnerSha256": "8c529727c309584bc2684550f05dd64680ec5e2b87f715af219cc5703a7eb0d4",
30
- "sourceTag": "fmix-v2.7.23"
29
+ "runnerSha256": "0fbb2d612397cc1bbe434d7a6373b8c39fd309c20ce2ad0aebd91c7273d61702",
30
+ "sourceTag": "fmix-v2.7.24"
31
31
  }
32
32
  }