@calltelemetry/fmix 2.7.24 → 2.7.26

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 +115 -21
  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.24"
31
+ FMIX_VERSION="2.7.26"
32
32
  FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
33
33
  FMIX_OS="$(uname -s)"
34
34
  FMIX_ARCH="$(uname -m)"
@@ -145,6 +145,10 @@ FMIX_LAST_LOCK_KEEPER_PID=""
145
145
  FMIX_LOCK_STOP_PROBE_PIDS=()
146
146
  FMIX_PENDING_LOCK_KEEPER_PID=""
147
147
  FMIX_PENDING_LOCK_KEEPER_STATE=""
148
+ # Typed kind of the last keeper bootstrap failure, set only after its keeper
149
+ # was retired: "bootstrap_deadline" (host load; retryable) or "bootstrap_failed"
150
+ # (genuine; fail fast). Callers branch on this, never on the message text.
151
+ FMIX_LAST_LOCK_KEEPER_FAILURE=""
148
152
 
149
153
  # Set by fmix_activate_session before any mutable artifact, stamp, or scratch
150
154
  # database path is resolved.
@@ -7142,9 +7146,11 @@ fmix_lock_keeper_start() {
7142
7146
  local path="$1" mode="$2" timeout="$3"
7143
7147
  local diagnostic_name="${4:-lock}"
7144
7148
  local lock_name="${5:-${diagnostic_name:-lock}}"
7145
- local py_bin owner_pid owner_file state keeper_pid status keeper_source
7149
+ local py_bin owner_pid owner_file state keeper_pid status keeper_source keeper_alive keeper_rc
7146
7150
  local bootstrap_deadline acquire_deadline="" failure="keeper exited before readiness"
7151
+ local bootstrap_secs failure_kind="bootstrap_failed" retryable=false
7147
7152
  local probe_pid
7153
+ FMIX_LAST_LOCK_KEEPER_FAILURE=""
7148
7154
  # Failed retirement is not contention. Preserve its exact recovery handle
7149
7155
  # rather than overwriting it with a second keeper, even for a different lock.
7150
7156
  if [[ -n "$FMIX_PENDING_LOCK_KEEPER_PID" ]]; then
@@ -7329,8 +7335,19 @@ finally:
7329
7335
  # try-locks still need a finite startup allowance, but a started keeper may
7330
7336
  # wait for the original contention timeout. SECONDS is shell-local and
7331
7337
  # avoids launching a clock subprocess for every poll.
7332
- bootstrap_deadline=$(( SECONDS + 5 ))
7338
+ # Interpreter start-up alone can exceed five seconds on a host under heavy
7339
+ # load (ADR 0478 agents share one machine). The default is deliberately
7340
+ # generous; FMIX_LOCK_KEEPER_BOOTSTRAP_SECS overrides it for tests and ops.
7341
+ bootstrap_secs="$(fmix_positive_uint_or_default "${FMIX_LOCK_KEEPER_BOOTSTRAP_SECS:-30}" 30 FMIX_LOCK_KEEPER_BOOTSTRAP_SECS)"
7342
+ bootstrap_deadline=$(( SECONDS + bootstrap_secs ))
7333
7343
  while true; do
7344
+ # Probe liveness BEFORE reading the handshake. A keeper publishes its
7345
+ # terminal state and then exits, so a keeper that finishes between a
7346
+ # state read and a liveness probe must be classified from its final
7347
+ # state. Probing afterwards mistook ordinary flock contention ("timeout")
7348
+ # for a dead bootstrap under load.
7349
+ keeper_alive=1
7350
+ kill -0 "$keeper_pid" 2>/dev/null || keeper_alive=0
7334
7351
  if [[ -s "$state" ]]; then
7335
7352
  IFS= read -r status <"$state"
7336
7353
  case "$status" in
@@ -7359,12 +7376,18 @@ finally:
7359
7376
  ;;
7360
7377
  esac
7361
7378
  fi
7362
- if ! kill -0 "$keeper_pid" 2>/dev/null; then
7379
+ if (( keeper_alive == 0 )); then
7380
+ # Nothing terminal was published: the keeper died during bootstrap.
7381
+ # Its exit status names the real cause (crash, signal, or io failure).
7382
+ keeper_rc=0
7383
+ wait "$keeper_pid" 2>/dev/null || keeper_rc=$?
7384
+ failure="keeper exited before readiness (status $keeper_rc)"
7363
7385
  break
7364
7386
  fi
7365
7387
  if [[ -z "$acquire_deadline" ]]; then
7366
7388
  if (( SECONDS >= bootstrap_deadline )); then
7367
7389
  failure="keeper bootstrap deadline exceeded"
7390
+ failure_kind="bootstrap_deadline"
7368
7391
  break
7369
7392
  fi
7370
7393
  elif (( SECONDS >= acquire_deadline )); then
@@ -7373,9 +7396,14 @@ finally:
7373
7396
  fi
7374
7397
  sleep 0.05
7375
7398
  done
7399
+ [[ "$failure_kind" != bootstrap_deadline ]] || retryable=true
7376
7400
  # This is exactly the child launched above, never an inferred lock holder.
7377
- printf '{"error":"lock_keeper_bootstrap_failed","reason":"%s"}\n' "$failure" >&2
7401
+ printf '{"error":"lock_keeper_bootstrap_failed","reason":"%s","retryable":%s}\n' \
7402
+ "$failure" "$retryable" >&2
7378
7403
  fmix_lock_keeper_retire "$keeper_pid" "$state" || return 70
7404
+ # Publish the typed kind only after the abandoned keeper is confirmed gone:
7405
+ # a retry must never run beside a keeper this attempt failed to retire.
7406
+ FMIX_LAST_LOCK_KEEPER_FAILURE="$failure_kind"
7379
7407
  return 70
7380
7408
  }
7381
7409
 
@@ -12830,6 +12858,21 @@ fmix_ensure_partitions() {
12830
12858
  # compile step: ensure app beams are up to date in the worktree
12831
12859
  # ---------------------------------------------------------------------------
12832
12860
 
12861
+ fmix_git_in() {
12862
+ # Run git in <dir>. A linked worktree of a bare hub (core.bare=true, with
12863
+ # extensions.worktreeConfig) reports "false" for is-inside-work-tree and
12864
+ # rejects every work-tree command. Only in that case pass the work tree
12865
+ # explicitly; other failures keep git's native resolution so the existing
12866
+ # dead-core.worktree diagnostics still apply.
12867
+ local dir="$1"
12868
+ shift
12869
+ if [[ "$(git -C "$dir" rev-parse --is-inside-work-tree 2>/dev/null)" == "false" ]]; then
12870
+ git -C "$dir" --work-tree="$dir" "$@"
12871
+ else
12872
+ git -C "$dir" "$@"
12873
+ fi
12874
+ }
12875
+
12833
12876
  fmix_compile_build_root() {
12834
12877
  local worktree="$1" configured="${MIX_BUILD_PATH:-_build}"
12835
12878
  if [[ -n "$FMIX_ACTIVE_SESSION_ROOT" \
@@ -12919,10 +12962,10 @@ fmix_hash_compile_paths() {
12919
12962
  fmix_reject_compile_input_symlink_components "$root" "$path" || return 1
12920
12963
  done
12921
12964
  if [[ -d "$root/.git" || -f "$root/.git" ]]; then
12922
- git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1 \
12965
+ fmix_git_in "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1 \
12923
12966
  || return 1
12924
12967
  tracked_file="$(mktemp)" || return 1
12925
- if ! git -C "$root" ls-files -s -z -- "$@" \
12968
+ if ! fmix_git_in "$root" ls-files -s -z -- "$@" \
12926
12969
  >"$tracked_file" 2>/dev/null; then
12927
12970
  rm -f "$tracked_file"
12928
12971
  return 1
@@ -12934,14 +12977,14 @@ fmix_hash_compile_paths() {
12934
12977
  rm -f "$tracked_file"
12935
12978
  untracked_file="$(mktemp)" || return 1
12936
12979
  if ! (
12937
- git -C "$root" ls-files --others --exclude-standard -z -- "$@" \
12980
+ fmix_git_in "$root" ls-files --others --exclude-standard -z -- "$@" \
12938
12981
  || exit 1
12939
12982
  # Git ignores do not change what Mix can compile or execute. Keep
12940
12983
  # ignored source files in the exact run identity, but only beneath
12941
12984
  # the caller's bounded source/test pathspecs. Never widen an empty
12942
12985
  # pathspec into a scan of ignored cache artifacts.
12943
12986
  if (( $# > 0 )); then
12944
- git -C "$root" ls-files --others --ignored \
12987
+ fmix_git_in "$root" ls-files --others --ignored \
12945
12988
  --exclude-standard -z -- "$@" || exit 1
12946
12989
  fi
12947
12990
  ) >"$untracked_file" 2>/dev/null; then
@@ -13005,11 +13048,11 @@ fmix_ignored_compile_inputs_hash() {
13005
13048
  return 0
13006
13049
  fi
13007
13050
  command -v git >/dev/null 2>&1 || return 1
13008
- git -C "$real" rev-parse --is-inside-work-tree >/dev/null 2>&1 \
13051
+ fmix_git_in "$real" rev-parse --is-inside-work-tree >/dev/null 2>&1 \
13009
13052
  || return 1
13010
13053
  ignored_file="$(mktemp)" || return 1
13011
13054
  manifest="$(mktemp)" || { rm -f "$ignored_file"; return 1; }
13012
- if ! git -C "$real" ls-files --others --ignored --exclude-standard -z \
13055
+ if ! fmix_git_in "$real" ls-files --others --ignored --exclude-standard -z \
13013
13056
  -- "${compile_paths[@]}" >"$ignored_file" 2>/dev/null; then
13014
13057
  rm -f "$ignored_file" "$manifest"
13015
13058
  return 1
@@ -13101,9 +13144,9 @@ fmix_source_stability_compile_identity() {
13101
13144
  (( $# >= 1 )) || return 1
13102
13145
  real="$(fmix_realpath "$worktree")" || return 1
13103
13146
  if [[ -d "$real/.git" || -f "$real/.git" ]]; then
13104
- git -C "$real" rev-parse --is-inside-work-tree >/dev/null 2>&1 \
13147
+ fmix_git_in "$real" rev-parse --is-inside-work-tree >/dev/null 2>&1 \
13105
13148
  || return 1
13106
- head="$(git -C "$real" rev-parse HEAD 2>/dev/null)" || return 1
13149
+ head="$(fmix_git_in "$real" rev-parse HEAD 2>/dev/null)" || return 1
13107
13150
  [[ "$head" =~ ^[0-9a-f]{40}$ ]] || return 1
13108
13151
  else
13109
13152
  head="non-git"
@@ -13325,6 +13368,22 @@ fmix_compute_dependency_fingerprint() {
13325
13368
  printf '%s\n' "$fingerprint"
13326
13369
  }
13327
13370
 
13371
+ fmix_dependency_provenance_failure_cause() {
13372
+ # Name why the dependency fingerprint could not be computed. The probes
13373
+ # themselves swallow git stderr, so ask git directly. A linked worktree of
13374
+ # a bare hub (core.bare=true) answers "false" to plain rev-parse and must
13375
+ # be reported as such, not as a generic provenance failure.
13376
+ local worktree="$1" probe
13377
+ probe="$(git -C "$worktree" rev-parse --is-inside-work-tree 2>&1)" || probe="error: ${probe}"
13378
+ if [[ "$probe" == "false" ]]; then
13379
+ printf '%s\n' "git reports $worktree is not a work tree (core.bare=true in the shared repo config); fmix now passes --work-tree explicitly, so this checkout is not a supported git layout"
13380
+ elif [[ "$probe" == "true" ]]; then
13381
+ printf '%s\n' "git resolves a work tree for $worktree, so a dependency input could not be hashed (see the fmix error above and 'fmix doctor')"
13382
+ else
13383
+ printf '%s\n' "git could not inspect $worktree: $probe"
13384
+ fi
13385
+ }
13386
+
13328
13387
  fmix_compute_mix_project_reconciliation_guard() {
13329
13388
  # Normalize mix.exs while replacing exactly one ordinary deps/0 body. This
13330
13389
  # permits dependency declaration/constraint edits but keeps application,
@@ -13822,16 +13881,16 @@ fmix_hash_git_dependency() {
13822
13881
  local dependency="$1" commit diff_hash file untracked_file
13823
13882
  local -a untracked=()
13824
13883
  fmix_reject_nested_source_symlinks "$dependency" || return 1
13825
- commit="$(git -C "$dependency" rev-parse HEAD 2>/dev/null)" || return 1
13884
+ commit="$(fmix_git_in "$dependency" rev-parse HEAD 2>/dev/null)" || return 1
13826
13885
  [[ -n "$commit" ]] || return 1
13827
13886
  printf '.git-commit:%s\n' "$commit"
13828
13887
 
13829
- diff_hash="$(git -C "$dependency" diff --no-ext-diff --binary HEAD 2>/dev/null \
13888
+ diff_hash="$(fmix_git_in "$dependency" diff --no-ext-diff --binary HEAD 2>/dev/null \
13830
13889
  | fmix_hash_stdin)" || return 1
13831
13890
  printf '.git-worktree-diff:%s\n' "$diff_hash"
13832
13891
 
13833
13892
  untracked_file="$(mktemp)" || return 1
13834
- if ! git -C "$dependency" ls-files --others --exclude-standard -z \
13893
+ if ! fmix_git_in "$dependency" ls-files --others --exclude-standard -z \
13835
13894
  >"$untracked_file" 2>/dev/null; then
13836
13895
  rm -f "$untracked_file"
13837
13896
  return 1
@@ -14722,8 +14781,14 @@ fmix_compile_semaphore_acquire() {
14722
14781
  local permits deadline_secs
14723
14782
  permits="$(fmix_compile_semaphore_permits)"
14724
14783
  deadline_secs="${FMIX_CALLER_DEADLINE_SECS:-}"
14725
-
14726
- local slot acquired_slot=-1 acquired_keeper_pid=""
14784
+ # A keeper bootstrap that misses its deadline under host load is transient:
14785
+ # retry it on a bounded backoff. The budget keeps a truly hung interpreter
14786
+ # from blocking forever when no caller deadline is set.
14787
+ local bootstrap_retries bootstrap_retries_left bootstrap_backoff=1
14788
+ bootstrap_retries="$(fmix_uint_or_default "${FMIX_LOCK_KEEPER_BOOTSTRAP_RETRIES:-3}" 3 FMIX_LOCK_KEEPER_BOOTSTRAP_RETRIES)"
14789
+ bootstrap_retries_left="$bootstrap_retries"
14790
+
14791
+ local slot acquired_slot=-1 acquired_keeper_pid="" bootstrap_transient=0
14727
14792
  mkdir -p "$FMIX_HOME/lock-kernel" "$FMIX_HOME/lock-metadata" || return 1
14728
14793
 
14729
14794
  local t0=$(fmix_epoch)
@@ -14731,6 +14796,7 @@ fmix_compile_semaphore_acquire() {
14731
14796
  local estimated_compile_s=60
14732
14797
 
14733
14798
  while true; do
14799
+ bootstrap_transient=0
14734
14800
  for (( slot = 0; slot < permits; slot++ )); do
14735
14801
  local kfile="$FMIX_HOME/lock-kernel/compile-permit-${slot}"
14736
14802
  local keeper_rc=0
@@ -14741,9 +14807,16 @@ fmix_compile_semaphore_acquire() {
14741
14807
  break
14742
14808
  else
14743
14809
  keeper_rc=$?
14744
- # A broken bootstrap is not permit contention. Surface its
14745
- # typed failure immediately instead of retrying indefinitely.
14746
- (( keeper_rc == 1 )) || return "$keeper_rc"
14810
+ # Real contention is rc 1 and is handled below.
14811
+ (( keeper_rc == 1 )) && continue
14812
+ # The abandoned keeper was retired; retry the whole pass.
14813
+ if [[ "$FMIX_LAST_LOCK_KEEPER_FAILURE" == bootstrap_deadline ]]; then
14814
+ bootstrap_transient=1
14815
+ break
14816
+ fi
14817
+ # A genuine bootstrap error is not permit contention. Surface
14818
+ # its typed failure immediately instead of retrying it.
14819
+ return "$keeper_rc"
14747
14820
  fi
14748
14821
  done
14749
14822
 
@@ -14766,6 +14839,25 @@ EOF
14766
14839
  local elapsed=$(( now - t0 ))
14767
14840
  local queue_depth=$permits
14768
14841
 
14842
+ if (( bootstrap_transient )); then
14843
+ if (( bootstrap_retries_left == 0 )); then
14844
+ printf '{"error":"lock_keeper_bootstrap_deadline_exhausted","retries":%d}\n' \
14845
+ "$bootstrap_retries" >&2
14846
+ return 70
14847
+ fi
14848
+ if [[ -n "$deadline_secs" && "$deadline_secs" =~ ^[0-9]+$ ]] \
14849
+ && (( elapsed + bootstrap_backoff >= deadline_secs )); then
14850
+ printf '{"error": "host_compile_deadline_exceeded", "queue_depth": %d, "estimated_wait_s": 0, "permit_limit": %d}\n' \
14851
+ "$queue_depth" "$permits" >&2
14852
+ return 75
14853
+ fi
14854
+ fmix_info "Compile keeper bootstrap exceeded its deadline under host load; retrying in ${bootstrap_backoff}s."
14855
+ bootstrap_retries_left=$(( bootstrap_retries_left - 1 ))
14856
+ sleep "$bootstrap_backoff"
14857
+ (( bootstrap_backoff >= 8 )) || bootstrap_backoff=$(( bootstrap_backoff * 2 ))
14858
+ continue
14859
+ fi
14860
+
14769
14861
  if [[ -n "$deadline_secs" && "$deadline_secs" =~ ^[0-9]+$ ]]; then
14770
14862
  local estimated_wait=$(( (queue_depth / permits) * estimated_compile_s ))
14771
14863
  if (( elapsed + estimated_wait + estimated_compile_s > deadline_secs )); then
@@ -15314,6 +15406,7 @@ _fmix_ensure_compile_impl() {
15314
15406
  return 0
15315
15407
  fi
15316
15408
  fmix_error "Compile artifacts are valid, but final dependency provenance could not be recorded."
15409
+ fmix_error "$(fmix_dependency_provenance_failure_cause "$worktree")"
15317
15410
  FMIX_LAST_COMPILE_OUTCOME="error"
15318
15411
  return 1
15319
15412
  fi
@@ -15449,6 +15542,7 @@ _fmix_ensure_compile_impl() {
15449
15542
  || ! fmix_write_dependency_stamp "$worktree" "$dependency_fingerprint"; then
15450
15543
  fmix_invalidate_rejected_stamps "$worktree"
15451
15544
  fmix_error "Compile succeeded, but final dependency provenance could not be recorded."
15545
+ fmix_error "$(fmix_dependency_provenance_failure_cause "$worktree")"
15452
15546
  FMIX_LAST_COMPILE_OUTCOME="error"
15453
15547
  return 1
15454
15548
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calltelemetry/fmix",
3
- "version": "2.7.24",
3
+ "version": "2.7.26",
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": "0fbb2d612397cc1bbe434d7a6373b8c39fd309c20ce2ad0aebd91c7273d61702",
30
- "sourceTag": "fmix-v2.7.24"
29
+ "runnerSha256": "a91b91b08d2bac8ac16a47d5b9c30039f02f3943509d0d5194eb4874b1cf4ee2",
30
+ "sourceTag": "fmix-v2.7.26"
31
31
  }
32
32
  }