@calltelemetry/fmix 2.7.8 → 2.7.9

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 +464 -30
  2. package/package.json +3 -3
package/bin/fmix CHANGED
@@ -24,7 +24,7 @@ set -uo pipefail
24
24
  # ---------------------------------------------------------------------------
25
25
  # Constants & config
26
26
  # ---------------------------------------------------------------------------
27
- FMIX_VERSION="2.7.8"
27
+ FMIX_VERSION="2.7.9"
28
28
  FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
29
29
  FMIX_OS="$(uname -s)"
30
30
  FMIX_ARCH="$(uname -m)"
@@ -175,6 +175,14 @@ fmix_prepare_home() {
175
175
  export FMIX_HOME
176
176
  }
177
177
 
178
+ fmix_prepare_command_home() {
179
+ fmix_prepare_home || return 1
180
+ mkdir -p "$FMIX_HOME"/{templates,template-access,dependency-artifacts,dependency-artifact-access,sessions,worktrees,db-index,compile-stamps,dependency-stamps,locks,lock-kernel,lock-metadata,logs,quarantine} \
181
+ || return 1
182
+ fmix_prepare_session_state_root || return 1
183
+ chmod 0700 "$FMIX_HOME" 2>/dev/null || true
184
+ }
185
+
178
186
  fmix_prepare_home_readonly() {
179
187
  # Cache explain/verify are read-only. Canonicalize an existing home so the
180
188
  # same path-safety comparisons apply through aliases, but never create a
@@ -2663,7 +2671,7 @@ fmix_guard_stale_build() {
2663
2671
  fmix_error "SAFETY: refusing to delete '$path' — expected _build.fmix-stale.* pattern."
2664
2672
  return 1
2665
2673
  fi
2666
- if [[ ! -f "$parent/mix.exs" ]] || ! grep -q 'app: :cdrcisco' "$parent/mix.exs" 2>/dev/null; then
2674
+ if ! fmix_worktree_has_cisco_cdr_app "$parent"; then
2667
2675
  fmix_error "SAFETY: refusing to delete '$path' — parent is not a cisco-cdr checkout."
2668
2676
  return 1
2669
2677
  fi
@@ -2680,7 +2688,7 @@ fmix_guard_worktree_subdir() {
2680
2688
  fmix_error "SAFETY: refusing to rm '$path' — expected path ending in /deps or /_build."
2681
2689
  return 1
2682
2690
  fi
2683
- if [[ ! -f "$parent/mix.exs" ]] || ! grep -q 'app: :cdrcisco' "$parent/mix.exs" 2>/dev/null; then
2691
+ if ! fmix_worktree_has_cisco_cdr_app "$parent"; then
2684
2692
  fmix_error "SAFETY: refusing to rm '$path' — parent '$parent' is not a cisco-cdr checkout."
2685
2693
  return 1
2686
2694
  fi
@@ -5151,6 +5159,7 @@ fmix_host_test_lock_enabled() {
5151
5159
 
5152
5160
  fmix_ensure_worktree_submodules() {
5153
5161
  local target_dir="$1"
5162
+ local selected_gitlink="${2:-}"
5154
5163
 
5155
5164
  # Find top-level repo if inside a Git tree
5156
5165
  local top_repo
@@ -5160,7 +5169,11 @@ fmix_ensure_worktree_submodules() {
5160
5169
  if [[ ! -f "$target_dir/mix.exs" ]]; then
5161
5170
  if [[ -f "$top_repo/.gitmodules" ]]; then
5162
5171
  fmix_info "Detected uninitialized submodules in $top_repo. Initializing..." >&2
5163
- git -C "$top_repo" submodule update --init --recursive >&2 || true
5172
+ if [[ -n "$selected_gitlink" ]]; then
5173
+ git -C "$top_repo" submodule update --init --recursive -- ":(top,literal)$selected_gitlink" >&2 || true
5174
+ else
5175
+ git -C "$top_repo" submodule update --init --recursive >&2 || true
5176
+ fi
5164
5177
  fi
5165
5178
  fi
5166
5179
 
@@ -5178,17 +5191,290 @@ fmix_ensure_worktree_submodules() {
5178
5191
  fi
5179
5192
  }
5180
5193
 
5194
+ fmix_worktree_has_cisco_cdr_app() {
5195
+ [[ -f "$1/mix.exs" ]] || return 1
5196
+
5197
+ # A bounded static recognizer, not an Elixir interpreter. Require one
5198
+ # literal module, a direct use Mix.Project and its literal project list.
5199
+ # Python is isolated from site/PYTHONPATH and cannot create bytecode; no
5200
+ # project code, helper, toolchain, home or session preparation runs here.
5201
+ python3 -I -S -B - "$1/mix.exs" <<'PY' 2>/dev/null
5202
+ import re
5203
+ import sys
5204
+
5205
+
5206
+ class Refuse(Exception):
5207
+ pass
5208
+
5209
+
5210
+ def require(condition):
5211
+ if not condition:
5212
+ raise Refuse()
5213
+
5214
+
5215
+ def literal_end(source, start):
5216
+ quote = source[start]
5217
+ delimiter = quote * (3 if source.startswith(quote * 3, start) else 1)
5218
+ i = start + len(delimiter)
5219
+ while i < len(source):
5220
+ if source[i] == "\\":
5221
+ i += 2
5222
+ elif source.startswith("#{", i):
5223
+ # Canonical project strings interpolate simple names/calls.
5224
+ # Nested/quoted interpolation is outside this static subset.
5225
+ end = source.find("}", i + 2)
5226
+ require(end != -1 and re.fullmatch(r"[A-Za-z0-9_.&!?()\[\] +*/=-]+", source[i + 2:end]))
5227
+ i = end + 1
5228
+ elif source.startswith(delimiter, i):
5229
+ return i + len(delimiter)
5230
+ else:
5231
+ i += 1
5232
+ raise Refuse()
5233
+
5234
+
5235
+ def tokenize(source):
5236
+ tokens = []
5237
+ identifier = re.compile(r"[A-Za-z_][A-Za-z0-9_]*[!?]?")
5238
+ i = 0
5239
+ while i < len(source):
5240
+ start = i
5241
+ c = source[i]
5242
+ if c.isspace():
5243
+ i += 1
5244
+ continue
5245
+ if c == "#":
5246
+ end = source.find("\n", i)
5247
+ i = len(source) if end == -1 else end
5248
+ continue
5249
+ if c in "\"'":
5250
+ i = literal_end(source, i)
5251
+ value = "<literal>"
5252
+ elif c == "~":
5253
+ # Only canonical plain ASCII wordlists are supported. All other
5254
+ # sigils (including unused ~S decoys) refuse the whole candidate.
5255
+ require(source[i + 1:i + 2] in ("w", "W"))
5256
+ opener = source[i + 2:i + 3]
5257
+ closer = {"(": ")", "[": "]", "{": "}", "<": ">", "/": "/", "|": "|",
5258
+ "\"": "\"", "'": "'"}.get(opener)
5259
+ require(closer is not None)
5260
+ end = source.find(closer, i + 3)
5261
+ require(end != -1 and re.fullmatch(r"[A-Za-z0-9_\s]*", source[i + 3:end]))
5262
+ i = end + 1
5263
+ modifier_start = i
5264
+ while i < len(source) and source[i] in "acs":
5265
+ i += 1
5266
+ require(source[modifier_start:i] in ("", "a", "c", "s"))
5267
+ require(i == len(source) or not (source[i].isalnum() or source[i] == "_"))
5268
+ value = "<literal>"
5269
+ else:
5270
+ word = identifier.match(source, i)
5271
+ require(c != "?") # Character literals are outside this subset.
5272
+ value = word.group() if word else c
5273
+ i += len(value)
5274
+ tokens.append((value, start, i))
5275
+ require(len(tokens) <= 65_536)
5276
+ return tokens
5277
+
5278
+
5279
+ def recognizes(source):
5280
+ tokens = tokenize(source)
5281
+ words = [token[0] for token in tokens]
5282
+ require(len(words) >= 7 and words[0] == "defmodule")
5283
+
5284
+ def codeword(i, word):
5285
+ return (words[i] == word and (i == 0 or words[i - 1] not in (":", "."))
5286
+ and (i + 1 == len(words) or words[i + 1] != ":"))
5287
+
5288
+ # Never let a helper module or quoted/metaprogrammed definition become
5289
+ # authority. Even otherwise-valid multi-module mix.exs files fail closed.
5290
+ require(sum(codeword(i, "defmodule") for i in range(len(words))) == 1)
5291
+ require(not any(codeword(i, word) for i in range(len(words))
5292
+ for word in ("quote", "unquote", "unquote_splicing")))
5293
+ # Do not infer ownership through aliases or imported macros. This also
5294
+ # excludes qualified Kernel.alias/import; literal atoms/keyword keys do
5295
+ # not change lexical resolution and remain opaque field values.
5296
+ require(not any(word in ("alias", "import")
5297
+ and (i == 0 or words[i - 1] != ":")
5298
+ and (i + 1 == len(words) or words[i + 1] != ":")
5299
+ for i, word in enumerate(words)))
5300
+ projects = [i for i, word in enumerate(words[:-1])
5301
+ if word in ("def", "defp") and codeword(i, word) and words[i + 1] == "project"]
5302
+ require(len(projects) == 1)
5303
+
5304
+ i = 1
5305
+ module = []
5306
+ while i < len(words) and words[i] != "do":
5307
+ module.append(words[i])
5308
+ i += 1
5309
+ require(module and len(module) % 2 == 1
5310
+ and all(value == "." if index % 2 else re.fullmatch(r"[A-Z][A-Za-z0-9_]*", value)
5311
+ for index, value in enumerate(module)))
5312
+ require(i < len(words) and codeword(i, "do"))
5313
+ module_do = i
5314
+ i += 1
5315
+ blocks = ["module"]
5316
+ delimiters = []
5317
+ closing = {"]": "[", ")": "(", "}": "{"}
5318
+ uses = 0
5319
+ project_ok = False
5320
+ functions_seen = False
5321
+
5322
+ def statement_start(index):
5323
+ return (index - 1 == module_do or words[index - 1] == ";"
5324
+ or "\n" in source[tokens[index - 1][2]:tokens[index][1]])
5325
+
5326
+ def project_list(index):
5327
+ if words[index:index + 2] == ["(", ")"]:
5328
+ index += 2
5329
+ inline = words[index:index + 3] == [",", "do", ":"]
5330
+ require(inline or words[index:index + 1] == ["do"])
5331
+ index += 3 if inline else 1
5332
+ require(words[index:index + 1] == ["["])
5333
+ depth = ["["]
5334
+ entries = []
5335
+ entry = []
5336
+ index += 1
5337
+ while index < len(words) and depth:
5338
+ word = words[index]
5339
+ if word in ("[", "(", "{"):
5340
+ depth.append(word)
5341
+ elif word in closing:
5342
+ require(depth[-1] == closing[word])
5343
+ depth.pop()
5344
+ if not depth:
5345
+ break
5346
+ # Control blocks or spliced lists are not literal keyword fields.
5347
+ require(not any(codeword(index, key) for key in ("do", "fn", "end")))
5348
+ if word == "," and len(depth) == 1:
5349
+ entries.append(entry)
5350
+ entry = []
5351
+ else:
5352
+ entry.append(word)
5353
+ index += 1
5354
+ require(not depth)
5355
+ if entry:
5356
+ entries.append(entry)
5357
+ require(entries and all(len(field) >= 3 and field[1] == ":"
5358
+ and re.fullmatch(r"[a-z_][A-Za-z0-9_]*[!?]?", field[0])
5359
+ for field in entries))
5360
+ require([field[2:] for field in entries if field[0] == "app"] == [[":", "cdrcisco"]])
5361
+ index += 1
5362
+ require(index < len(words))
5363
+ if inline:
5364
+ require(words[index] in (";", "end")
5365
+ or (statement_start(index) and words[index] in ("def", "defp", "@")))
5366
+ else:
5367
+ require(codeword(index, "end"))
5368
+ index += 1
5369
+ return index
5370
+
5371
+ while i < len(words):
5372
+ word = words[i]
5373
+ if codeword(i, "use"):
5374
+ require(blocks == ["module"] and not delimiters and not functions_seen
5375
+ and statement_start(i) and words[i + 1:i + 4] == ["Mix", ".", "Project"])
5376
+ uses += 1
5377
+ require(uses == 1)
5378
+ i += 4
5379
+ require(i < len(words) and (words[i] in (";", "end") or statement_start(i))
5380
+ and words[i] not in (",", "."))
5381
+ continue
5382
+ if word in ("def", "defp") and codeword(i, word):
5383
+ functions_seen = True
5384
+ if i == projects[0]:
5385
+ require(word == "def" and blocks == ["module"] and not delimiters
5386
+ and uses == 1 and statement_start(i))
5387
+ i = project_list(i + 2)
5388
+ project_ok = True
5389
+ continue
5390
+ if word in ("[", "(", "{"):
5391
+ delimiters.append(word)
5392
+ elif word in closing:
5393
+ require(delimiters and delimiters.pop() == closing[word])
5394
+ elif codeword(i, "do") or codeword(i, "fn"):
5395
+ blocks.append("block")
5396
+ elif codeword(i, "end"):
5397
+ require(blocks)
5398
+ blocks.pop()
5399
+ if not blocks:
5400
+ require(not delimiters and all(value == ";" for value in words[i + 1:]))
5401
+ return uses == 1 and project_ok
5402
+ i += 1
5403
+ return False
5404
+
5405
+
5406
+ try:
5407
+ with open(sys.argv[1], "rb") as handle:
5408
+ raw = handle.read(1_048_577)
5409
+ require(len(raw) <= 1_048_576)
5410
+ source = raw.decode("utf-8")
5411
+ sys.exit(0 if recognizes(source) else 1)
5412
+ except (OSError, UnicodeError, Refuse, IndexError):
5413
+ sys.exit(1)
5414
+ PY
5415
+ }
5416
+
5417
+ fmix_worktree_is_cold_submodule() {
5418
+ # A missing mix.exs is not a checkout identity. Admit the one cold
5419
+ # exception only when Git registers this exact directory as an
5420
+ # uninitialized Gitlink and .gitmodules names the cisco-cdr source.
5421
+ [[ -d "$1" && ! -e "$1/mix.exs" ]] || return 1
5422
+ local target top relative entry key registered_path url status
5423
+ target="$(fmix_realpath "$1")" || return 1
5424
+ top="$(git -C "$target" rev-parse --show-toplevel 2>/dev/null)" || return 1
5425
+ top="$(fmix_realpath "$top")" || return 1
5426
+ [[ "$target" == "$top/"* && -f "$top/.gitmodules" ]] || return 1
5427
+ relative="${target#"$top/"}"
5428
+ entry="$(git -C "$top" ls-files --stage -- "$relative" 2>/dev/null)" || return 1
5429
+ [[ "$entry" != *$'\n'* && "$entry" =~ ^160000\ [0-9a-f]{40}\ 0$'\t' ]] || return 1
5430
+ [[ "${entry#*$'\t'}" == "$relative" ]] || return 1
5431
+
5432
+ while IFS= read -r key; do
5433
+ registered_path="$(git -C "$top" config --file .gitmodules --get "$key" 2>/dev/null)" || continue
5434
+ [[ "$registered_path" == "$relative" ]] || continue
5435
+ url="$(git -C "$top" config --file .gitmodules --get "${key%.path}.url" 2>/dev/null)" || return 1
5436
+ case "$url" in
5437
+ https://github.com/calltelemetry/cisco-cdr|https://github.com/calltelemetry/cisco-cdr.git|git@github.com:calltelemetry/cisco-cdr|git@github.com:calltelemetry/cisco-cdr.git|ssh://git@github.com/calltelemetry/cisco-cdr|ssh://git@github.com/calltelemetry/cisco-cdr.git) ;;
5438
+ *) return 1 ;;
5439
+ esac
5440
+ status="$(git -C "$top" submodule status -- "$relative" 2>/dev/null)" || return 1
5441
+ [[ "$status" == -[0-9a-f]* ]] || return 1
5442
+ printf '%s\n' "$relative"
5443
+ return 0
5444
+ done < <(git -C "$top" config --file .gitmodules --name-only --get-regexp '^submodule\..*\.path$' 2>/dev/null)
5445
+ return 1
5446
+ }
5447
+
5181
5448
  fmix_find_worktree() {
5182
5449
  local path="$1"
5450
+ # Admission needs a verified candidate without initializing submodules.
5451
+ # The default resolution still initializes and verifies the checkout.
5452
+ local resolution_mode="${2:-initialize}"
5183
5453
  local search_from
5454
+ local cold_relative
5184
5455
 
5185
5456
  if [[ "$path" == "auto" ]]; then
5186
5457
  search_from="$(pwd)"
5187
5458
  # Walk up looking for mix.exs with app: :cdrcisco
5188
5459
  local dir="$search_from"
5189
5460
  while true; do
5190
- if [[ -f "$dir/mix.exs" ]] && grep -q 'app: :cdrcisco' "$dir/mix.exs" 2>/dev/null; then
5191
- fmix_ensure_worktree_submodules "$dir"
5461
+ cold_relative=""
5462
+ if fmix_worktree_has_cisco_cdr_app "$dir"; then
5463
+ :
5464
+ elif cold_relative="$(fmix_worktree_is_cold_submodule "$dir")"; then
5465
+ :
5466
+ else
5467
+ cold_relative=""
5468
+ fi
5469
+ if fmix_worktree_has_cisco_cdr_app "$dir" || [[ -n "$cold_relative" ]]; then
5470
+ if [[ "$resolution_mode" != "readonly" ]]; then
5471
+ if [[ -n "$cold_relative" ]]; then
5472
+ fmix_ensure_worktree_submodules "$dir" "$cold_relative"
5473
+ else
5474
+ fmix_ensure_worktree_submodules "$dir"
5475
+ fi
5476
+ fmix_worktree_has_cisco_cdr_app "$dir" || return 1
5477
+ fi
5192
5478
  printf '%s\n' "$dir"
5193
5479
  return 0
5194
5480
  fi
@@ -5202,10 +5488,29 @@ fmix_find_worktree() {
5202
5488
 
5203
5489
  # If not found walking up, check if CWD has a cisco-cdr subdirectory
5204
5490
  if [[ -d "$search_from/cisco-cdr" ]]; then
5205
- fmix_ensure_worktree_submodules "$search_from/cisco-cdr"
5206
- if [[ -f "$search_from/cisco-cdr/mix.exs" ]] && grep -q 'app: :cdrcisco' "$search_from/cisco-cdr/mix.exs" 2>/dev/null; then
5207
- printf '%s\n' "$search_from/cisco-cdr"
5208
- return 0
5491
+ if [[ "$resolution_mode" == "readonly" ]]; then
5492
+ cold_relative=""
5493
+ if ! fmix_worktree_has_cisco_cdr_app "$search_from/cisco-cdr"; then
5494
+ cold_relative="$(fmix_worktree_is_cold_submodule "$search_from/cisco-cdr")" || cold_relative=""
5495
+ fi
5496
+ if fmix_worktree_has_cisco_cdr_app "$search_from/cisco-cdr" || [[ -n "$cold_relative" ]]; then
5497
+ printf '%s\n' "$search_from/cisco-cdr"
5498
+ return 0
5499
+ fi
5500
+ else
5501
+ cold_relative=""
5502
+ if ! fmix_worktree_has_cisco_cdr_app "$search_from/cisco-cdr"; then
5503
+ cold_relative="$(fmix_worktree_is_cold_submodule "$search_from/cisco-cdr")" || cold_relative=""
5504
+ fi
5505
+ if [[ -n "$cold_relative" ]]; then
5506
+ fmix_ensure_worktree_submodules "$search_from/cisco-cdr" "$cold_relative"
5507
+ elif fmix_worktree_has_cisco_cdr_app "$search_from/cisco-cdr"; then
5508
+ fmix_ensure_worktree_submodules "$search_from/cisco-cdr"
5509
+ fi
5510
+ if fmix_worktree_has_cisco_cdr_app "$search_from/cisco-cdr"; then
5511
+ printf '%s\n' "$search_from/cisco-cdr"
5512
+ return 0
5513
+ fi
5209
5514
  fi
5210
5515
  fi
5211
5516
 
@@ -5223,9 +5528,30 @@ fmix_find_worktree() {
5223
5528
  resolved_dir="$resolved_dir/cisco-cdr"
5224
5529
  fi
5225
5530
 
5226
- fmix_ensure_worktree_submodules "$resolved_dir"
5531
+ cold_relative=""
5532
+ if ! fmix_worktree_has_cisco_cdr_app "$resolved_dir"; then
5533
+ cold_relative="$(fmix_worktree_is_cold_submodule "$resolved_dir")" || cold_relative=""
5534
+ fi
5227
5535
 
5228
- if [[ ! -f "$resolved_dir/mix.exs" ]] || ! grep -q 'app: :cdrcisco' "$resolved_dir/mix.exs" 2>/dev/null; then
5536
+ if [[ "$resolution_mode" == "readonly" ]]; then
5537
+ if ! fmix_worktree_has_cisco_cdr_app "$resolved_dir" && [[ -z "$cold_relative" ]]; then
5538
+ fmix_error "'$path' is not a cisco-cdr checkout (mix.exs missing or app: :cdrcisco not found; no recognized uninitialized cisco-cdr Gitlink)."
5539
+ return 1
5540
+ fi
5541
+ printf '%s\n' "$resolved_dir"
5542
+ return 0
5543
+ fi
5544
+ if [[ -n "$cold_relative" ]]; then
5545
+ fmix_ensure_worktree_submodules "$resolved_dir" "$cold_relative"
5546
+ elif fmix_worktree_has_cisco_cdr_app "$resolved_dir"; then
5547
+ fmix_ensure_worktree_submodules "$resolved_dir"
5548
+ else
5549
+ fmix_error "'$path' is not a cisco-cdr checkout (not inside a cisco-cdr checkout, mix.exs missing or app: :cdrcisco not found)."
5550
+ fmix_error "fmix v1 only supports cisco-cdr worktrees."
5551
+ return 1
5552
+ fi
5553
+
5554
+ if ! fmix_worktree_has_cisco_cdr_app "$resolved_dir"; then
5229
5555
  fmix_error "'$path' is not a cisco-cdr checkout (not inside a cisco-cdr checkout, mix.exs missing or app: :cdrcisco not found)."
5230
5556
  fmix_error "fmix v1 only supports cisco-cdr worktrees."
5231
5557
  return 1
@@ -6143,7 +6469,7 @@ fmix_clone_donor_to_session() {
6143
6469
  local donor_keeper_pid
6144
6470
  [[ -f "$donor/meta.json" ]] || return 1
6145
6471
  if ! fmix_lock_keeper_start "$donor/meta.json" shared 0 \
6146
- "donor session clone" "donor-$(fmix_hash_text "$donor" | cut -c1-16)"; then
6472
+ "donor session clone" "donor-$(fmix_hash_string "$donor" | cut -c1-16)"; then
6147
6473
  fmix_warn "Could not acquire shared lock on donor session $donor."
6148
6474
  return 1
6149
6475
  fi
@@ -10744,6 +11070,107 @@ fmix_ensure_chromium() {
10744
11070
  # cmd: fmix test
10745
11071
  # ---------------------------------------------------------------------------
10746
11072
 
11073
+ fmix_validate_test_targets() {
11074
+ # Mix silently drops nonexistent selections when another file runs. Admit
11075
+ # every positional path before home/session/setup effects, without treating
11076
+ # Mix option values (tags, regexes, formatters, numbers) as file selections.
11077
+ local worktree="$1"
11078
+ shift
11079
+ local selection option boolean_name target prefix remaining part resolved
11080
+ local positional_only=0 takes_value=0
11081
+ while (( $# > 0 )); do
11082
+ selection="$1"
11083
+ shift
11084
+ if (( positional_only == 0 )); then
11085
+ takes_value=0
11086
+ option="${selection%%=*}"
11087
+ case "$option" in
11088
+ --)
11089
+ if [[ "$selection" == "--" ]]; then
11090
+ positional_only=1
11091
+ continue
11092
+ fi
11093
+ fmix_error "Unsupported or ambiguous Mix test option: $option. Target admission supports documented mix test options only; use -- before a literal positional selection."
11094
+ return 2
11095
+ ;;
11096
+ --include|--exclude|--only|--formatter|--name-pattern|--export-coverage|--profile-require|--max-cases|--max-failures|--max-requires|--seed|--timeout|--slowest|--slowest-modules|--partitions|--exit-status|--repeat-until-failure)
11097
+ takes_value=1
11098
+ ;;
11099
+ --*)
11100
+ boolean_name="${option#--}"
11101
+ boolean_name="${boolean_name#no-}"
11102
+ case "$boolean_name" in
11103
+ all-warnings|breakpoints|force|color|cover|trace|compile|start|raise|deps-check|archives-check|elixir-version-check|failed|stale|listen-on-stdin|preload-modules|warnings-as-errors|dry-run)
11104
+ continue
11105
+ ;;
11106
+ *)
11107
+ fmix_error "Unsupported or ambiguous Mix test option: $option. Target admission supports documented mix test options only; use -- before a literal positional selection."
11108
+ return 2
11109
+ ;;
11110
+ esac
11111
+ ;;
11112
+ -*)
11113
+ # Mix's only short aliases are -b (boolean) and -n
11114
+ # (regex). A cluster ending in -n also consumes a value;
11115
+ # a numeric suffix is an attached value, as in -n2pattern.
11116
+ if [[ "$option" =~ ^-b*n$ ]]; then
11117
+ takes_value=1
11118
+ elif [[ "$option" =~ ^-b+$ || "$option" =~ ^-b*n[0-9][^-_]*$ ]]; then
11119
+ continue
11120
+ elif [[ "$selection" != "-" && "$selection" != "- "* \
11121
+ && ! ( "$selection" =~ ^-[0-9] && "$selection" != *=* ) ]]; then
11122
+ fmix_error "Unsupported or ambiguous Mix test option: $option. Target admission supports documented mix test options only; use -- before a literal positional selection."
11123
+ return 2
11124
+ fi
11125
+ ;;
11126
+ esac
11127
+ if (( takes_value == 1 )); then
11128
+ [[ "$selection" == "$option" ]] || continue
11129
+ # Match OptionParser: another switch is not a value, but a
11130
+ # negative number, lone '-' or '- ' prefix can be one. Refuse
11131
+ # unknown arity before effects; leave value/type validation to
11132
+ # Mix rather than implementing another full option parser.
11133
+ if (( $# > 0 )) && { [[ "$1" != -* || "$1" == "-" || "$1" == "- "* ]] \
11134
+ || [[ "$1" =~ ^-[0-9] ]]; }; then
11135
+ shift
11136
+ else
11137
+ fmix_error "Mix test option requires a value: $option."
11138
+ return 2
11139
+ fi
11140
+ continue
11141
+ fi
11142
+ fi
11143
+ if [[ -z "$selection" ]]; then
11144
+ fmix_error "Invalid test target: empty positional selection."
11145
+ return 2
11146
+ fi
11147
+ # ExUnit treats the first positive numeric colon component as the
11148
+ # location boundary (including multiple lines and +/leading-zero forms).
11149
+ # Colons before that boundary remain part of the filename.
11150
+ target="$selection"
11151
+ prefix="${selection%%:*}"
11152
+ remaining="$selection"
11153
+ while [[ "$remaining" == *:* ]]; do
11154
+ remaining="${remaining#*:}"
11155
+ part="${remaining%%:*}"
11156
+ if [[ "$part" =~ ^[+]?0*[1-9][0-9]*$ ]]; then
11157
+ target="$prefix"
11158
+ break
11159
+ fi
11160
+ prefix="$prefix:$part"
11161
+ done
11162
+ case "$target" in
11163
+ /*) resolved="$target" ;;
11164
+ *) resolved="$worktree/$target" ;;
11165
+ esac
11166
+ if [[ -z "$target" || ! -f "$resolved" && ! -d "$resolved" ]]; then
11167
+ fmix_error "Missing or non-regular test target: $selection (resolved path: $resolved)."
11168
+ return 2
11169
+ fi
11170
+ done
11171
+ return 0
11172
+ }
11173
+
10747
11174
  cmd_test() {
10748
11175
  local run_mode="${FMIX_INTERNAL_RUN_MODE:-test}"
10749
11176
  local worktree_arg="auto"
@@ -10914,6 +11341,15 @@ cmd_test() {
10914
11341
  fi
10915
11342
  fi
10916
11343
 
11344
+ local worktree real_worktree
11345
+ worktree="$(fmix_find_worktree "$worktree_arg" readonly)" || return 1
11346
+ real_worktree="$(fmix_realpath "$worktree")" || return 1
11347
+ if (( mix_args_present == 1 )); then
11348
+ fmix_validate_test_targets "$real_worktree" "${mix_args[@]}" || return $?
11349
+ fi
11350
+
11351
+ # main defers all mutable test/coverage preparation until admission passes.
11352
+ fmix_prepare_command_home || return 1
10917
11353
  fmix_run_telemetry_begin "$run_mode"
10918
11354
 
10919
11355
  if (( isolate_mode == 1 )); then
@@ -10926,13 +11362,12 @@ cmd_test() {
10926
11362
  fi
10927
11363
  fi
10928
11364
 
10929
- local worktree
10930
- worktree="$(fmix_find_worktree "$worktree_arg")" || {
11365
+ # Initialize/verify this same candidate only after target admission. This
11366
+ # retains cold submodule bootstrap and the normal no-target default.
11367
+ worktree="$(fmix_find_worktree "$real_worktree")" || {
10931
11368
  fmix_run_telemetry_finish 1
10932
11369
  return 1
10933
11370
  }
10934
- local real_worktree
10935
- real_worktree="$(fmix_realpath "$worktree")"
10936
11371
  fmix_activate_toolchain "$real_worktree" || {
10937
11372
  fmix_run_telemetry_finish 1
10938
11373
  return 1
@@ -13259,15 +13694,22 @@ cmd_self_test() {
13259
13694
  # Also cover a top-level cisco-cdr submodule that has not materialized its
13260
13695
  # mix.exs yet. The mocked update creates the checkout while keeping every
13261
13696
  # initialization diagnostic off command-substitution stdout.
13262
- local submodule_parent top_level_wt top_level_stderr top_level_stdout
13697
+ local submodule_parent top_level_wt top_level_stderr top_level_stdout top_level_fixture_sha
13263
13698
  submodule_parent="$(mktemp -d)"
13264
13699
  submodule_parent="$(fmix_realpath "$submodule_parent")"
13265
13700
  top_level_wt="$submodule_parent/cisco-cdr"
13266
13701
  top_level_stderr="$(mktemp)"
13267
13702
  git init -q "$submodule_parent"
13268
13703
  mkdir -p "$top_level_wt"
13269
- printf '[submodule "cisco-cdr"]\n\tpath = cisco-cdr\n\turl = https://example.invalid/cisco-cdr.git\n' \
13704
+ printf '[submodule "cisco-cdr"]\n\tpath = cisco-cdr\n\turl = https://github.com/calltelemetry/cisco-cdr.git\n' \
13270
13705
  >"$submodule_parent/.gitmodules"
13706
+ git -C "$submodule_parent" -c user.name=fmix-self-test \
13707
+ -c user.email=fmix-self-test@example.invalid -c commit.gpgsign=false \
13708
+ commit --allow-empty -qm 'owned cold Gitlink fixture'
13709
+ top_level_fixture_sha="$(git -C "$submodule_parent" rev-parse HEAD)"
13710
+ git -C "$submodule_parent" add .gitmodules
13711
+ git -C "$submodule_parent" update-index --add --cacheinfo \
13712
+ "160000,$top_level_fixture_sha,cisco-cdr"
13271
13713
  if top_level_stdout="$({
13272
13714
  git() {
13273
13715
  if [[ " $* " == *" submodule update --init --recursive "* ]]; then
@@ -19978,11 +20420,7 @@ fmix_observability_validate_worker_capability() {
19978
20420
 
19979
20421
  main() {
19980
20422
  if (( $# == 0 )); then
19981
- fmix_prepare_home || return 1
19982
- mkdir -p "$FMIX_HOME"/{templates,template-access,dependency-artifacts,dependency-artifact-access,sessions,worktrees,db-index,compile-stamps,dependency-stamps,locks,lock-kernel,lock-metadata,logs,quarantine} \
19983
- || return 1
19984
- fmix_prepare_session_state_root || return 1
19985
- chmod 0700 "$FMIX_HOME" 2>/dev/null || true
20423
+ fmix_prepare_command_home || return 1
19986
20424
  fmix_usage
19987
20425
  return 0
19988
20426
  fi
@@ -20021,12 +20459,8 @@ main() {
20021
20459
 
20022
20460
  if [[ "$cmd" == "cache" ]]; then
20023
20461
  fmix_prepare_home_readonly || return 1
20024
- else
20025
- fmix_prepare_home || return 1
20026
- mkdir -p "$FMIX_HOME"/{templates,template-access,dependency-artifacts,dependency-artifact-access,sessions,worktrees,db-index,compile-stamps,dependency-stamps,locks,lock-kernel,lock-metadata,logs,quarantine} \
20027
- || return 1
20028
- fmix_prepare_session_state_root || return 1
20029
- chmod 0700 "$FMIX_HOME" 2>/dev/null || true
20462
+ elif [[ "$cmd" != "test" && "$cmd" != "coverage" ]]; then
20463
+ fmix_prepare_command_home || return 1
20030
20464
  fi
20031
20465
 
20032
20466
  case "$cmd" in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calltelemetry/fmix",
3
- "version": "2.7.8",
3
+ "version": "2.7.9",
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": "adc849bdca6acd7aa90bb51d115a6852f051f7de5567cef8d5f90bc0d9ecaee5",
30
- "sourceTag": "fmix-v2.7.8"
29
+ "runnerSha256": "67794255e5093d508bc36af1c8d3ad932d7f392624f44e96660d62379edfe9f5",
30
+ "sourceTag": "fmix-v2.7.9"
31
31
  }
32
32
  }