@calltelemetry/fmix 2.4.2 → 2.4.3

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 +69 -29
  2. package/package.json +3 -3
package/bin/fmix CHANGED
@@ -23,7 +23,7 @@ set -uo pipefail
23
23
  # ---------------------------------------------------------------------------
24
24
  # Constants & config
25
25
  # ---------------------------------------------------------------------------
26
- FMIX_VERSION="2.4.2"
26
+ FMIX_VERSION="2.4.3"
27
27
  FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
28
28
  FMIX_OS="$(uname -s)"
29
29
  FMIX_ARCH="$(uname -m)"
@@ -34,14 +34,15 @@ FMIX_LOCK_TIMEOUT="${FMIX_LOCK_TIMEOUT:-900}" # 15 min template build wait
34
34
  FMIX_LOCK_INIT_GRACE="${FMIX_LOCK_INIT_GRACE:-5}"
35
35
  FMIX_LOCK_METADATA_TTL_DAYS="${FMIX_LOCK_METADATA_TTL_DAYS:-7}"
36
36
  FMIX_WORKTREE_LOCK_TIMEOUT="${FMIX_WORKTREE_LOCK_TIMEOUT:-360}"
37
- # Session overlays are large (roughly 0.5 GiB each), so one day is the
37
+ # Session overlays are large (roughly 0.5 GiB each), so four hours is the
38
38
  # retention default for both automatic housekeeping and explicit GC. Preserve
39
- # FMIX_CACHE_TTL_DAYS as a legacy fallback for existing operator config, but
40
- # leave the modern override unset when it was not supplied so command-scoped
41
- # legacy overrides continue to work (for example, `FMIX_CACHE_TTL_DAYS=3
42
- # fmix_activate_session ...`).
39
+ # the day-based variables as compatibility fallbacks for existing operator
40
+ # config, but leave the modern overrides unset when they were not supplied so
41
+ # command-scoped legacy overrides continue to work.
43
42
  FMIX_SESSION_TTL_DEFAULT="1"
44
43
  FMIX_SESSION_TTL_DAYS="${FMIX_SESSION_TTL_DAYS-}"
44
+ FMIX_SESSION_TTL_HOURS="${FMIX_SESSION_TTL_HOURS-}"
45
+ FMIX_SESSION_TTL_DEFAULT_HOURS="4"
45
46
  FMIX_SESSION_WARN_THRESHOLD="${FMIX_SESSION_WARN_THRESHOLD:-24}"
46
47
  FMIX_COPY_MODE="${FMIX_COPY_MODE:-}" # override: "full" to skip CoW
47
48
  FMIX_HOST_TEST_LOCK="${FMIX_HOST_TEST_LOCK:-1}" # default: serialize only CREATE/DROP DATABASE on this host
@@ -787,15 +788,44 @@ fmix_effective_session_ttl_days() {
787
788
  "$FMIX_SESSION_TTL_DEFAULT" FMIX_SESSION_TTL_DAYS
788
789
  }
789
790
 
791
+ fmix_effective_session_ttl_hours() {
792
+ local explicit_hours="${FMIX_SESSION_TTL_HOURS-}"
793
+ local legacy_days="${FMIX_SESSION_TTL_DAYS:-${FMIX_CACHE_TTL_DAYS:-}}"
794
+ local hours
795
+ if [[ -n "$explicit_hours" ]]; then
796
+ fmix_nonnegative_number_or_default \
797
+ "$explicit_hours" "$FMIX_SESSION_TTL_DEFAULT_HOURS" FMIX_SESSION_TTL_HOURS
798
+ return 0
799
+ fi
800
+ if [[ -n "$legacy_days" ]]; then
801
+ hours="$(fmix_nonnegative_number_or_default \
802
+ "$legacy_days" "$FMIX_SESSION_TTL_DEFAULT" FMIX_SESSION_TTL_DAYS)"
803
+ fmix_session_ttl_hours_from_days "$hours"
804
+ return 0
805
+ fi
806
+ printf '%s\n' "$FMIX_SESSION_TTL_DEFAULT_HOURS"
807
+ }
808
+
809
+ fmix_session_ttl_hours_from_days() {
810
+ local days="$1" py_bin
811
+ if [[ "$days" =~ ^[0-9]+$ ]]; then
812
+ printf '%s\n' "$(( days * 24 ))"
813
+ return 0
814
+ fi
815
+ py_bin="$(fmix_python_bin)"
816
+ "$py_bin" -c 'import sys; print(float(sys.argv[1]) * 24)' \
817
+ "$days" 2>/dev/null || printf '4\n'
818
+ }
819
+
790
820
  fmix_session_ttl_seconds() {
791
- local ttl_days="${1:-$(fmix_effective_session_ttl_days)}" py_bin
792
- if [[ "$ttl_days" =~ ^[0-9]+$ ]]; then
793
- printf '%s\n' "$(( ttl_days * 86400 ))"
821
+ local ttl_hours="${1:-$(fmix_effective_session_ttl_hours)}" py_bin
822
+ if [[ "$ttl_hours" =~ ^[0-9]+$ ]]; then
823
+ printf '%s\n' "$(( ttl_hours * 3600 ))"
794
824
  return 0
795
825
  fi
796
826
  py_bin="$(fmix_python_bin)"
797
- "$py_bin" -c 'import sys; print(int(float(sys.argv[1]) * 86400))' \
798
- "$ttl_days" 2>/dev/null || printf '86400\n'
827
+ "$py_bin" -c 'import sys; print(int(float(sys.argv[1]) * 3600))' \
828
+ "$ttl_hours" 2>/dev/null || printf '14400\n'
799
829
  }
800
830
 
801
831
  fmix_control_psql() {
@@ -935,10 +965,11 @@ fmix_session_meta_file() {
935
965
  }
936
966
 
937
967
  fmix_create_or_touch_meta_json() {
938
- local worktree="$1" meta created lockfile_hash app_name ttl_days tmp
968
+ local worktree="$1" meta created lockfile_hash app_name ttl_days ttl_hours tmp
939
969
  meta="$(fmix_session_meta_file)" || return 1
940
970
 
941
971
  ttl_days="$(fmix_effective_session_ttl_days)"
972
+ ttl_hours="$(fmix_effective_session_ttl_hours)"
942
973
 
943
974
  created=""
944
975
  if [[ -f "$meta" ]]; then
@@ -984,6 +1015,7 @@ fmix_create_or_touch_meta_json() {
984
1015
  "last_accessed": "$(fmix_now)",
985
1016
  "last_used": "$(fmix_now)",
986
1017
  "ttl_days": $ttl_days,
1018
+ "ttl_hours": $ttl_hours,
987
1019
  "lockfile_hash": $(fmix_json_escape "$lockfile_hash"),
988
1020
  "status": "active"
989
1021
  }
@@ -1206,9 +1238,9 @@ fmix_drop_orphan_session_db() {
1206
1238
 
1207
1239
  fmix_purge_expired_sessions() {
1208
1240
  local quiet="${1:-0}"
1209
- local ttl_days ttl_seconds
1210
- ttl_days="$(fmix_effective_session_ttl_days)"
1211
- ttl_seconds="$(fmix_session_ttl_seconds "$ttl_days")"
1241
+ local ttl_hours ttl_seconds
1242
+ ttl_hours="$(fmix_effective_session_ttl_hours)"
1243
+ ttl_seconds="$(fmix_session_ttl_seconds "$ttl_hours")"
1212
1244
  local now session_meta session_root session_hash session_last session_epoch session_age session_lock session_db
1213
1245
  local dir_mtime dir_age session_meta_paths empty_dir_paths
1214
1246
  now="$(fmix_epoch)"
@@ -1310,7 +1342,7 @@ fmix_purge_expired_sessions() {
1310
1342
  fi
1311
1343
 
1312
1344
  if (( quiet == 0 && purged_count > 0 )); then
1313
- fmix_info "Purged $purged_count expired session build artifact(s) (TTL: ${ttl_days}d)."
1345
+ fmix_info "Purged $purged_count expired session build artifact(s) (TTL: ${ttl_hours}h)."
1314
1346
  fi
1315
1347
  return 0
1316
1348
  }
@@ -9288,8 +9320,8 @@ cmd_doctor() {
9288
9320
 
9289
9321
  # Session metadata & TTL cache lifecycle inspection & purging
9290
9322
  local ttl_val
9291
- ttl_val="$(fmix_effective_session_ttl_days)"
9292
- echo " Session metadata & TTL cache inspection (FMIX_SESSION_TTL_DAYS=${ttl_val}):"
9323
+ ttl_val="$(fmix_effective_session_ttl_hours)"
9324
+ echo " Session metadata & TTL cache inspection (FMIX_SESSION_TTL_HOURS=${ttl_val}h):"
9293
9325
  local session_meta_paths="" session_scan_ok=1
9294
9326
  if ! fmix_purge_expired_sessions 0; then
9295
9327
  echo " [FAIL] session discovery failed; skipped orphan scratch DB cleanup"
@@ -10186,11 +10218,11 @@ cmd_gc() {
10186
10218
 
10187
10219
  # 6. Expired session overlays. Reaping is lease-aware: the exact session
10188
10220
  # lock must be acquired before its artifacts or scratch DB are touched.
10189
- local session_ttl_days session_ttl_seconds
10190
- session_ttl_days="$(fmix_effective_session_ttl_days)"
10191
- session_ttl_seconds="$(fmix_session_ttl_seconds "$session_ttl_days")"
10221
+ local session_ttl_hours session_ttl_seconds
10222
+ session_ttl_hours="$(fmix_effective_session_ttl_hours)"
10223
+ session_ttl_seconds="$(fmix_session_ttl_seconds "$session_ttl_hours")"
10192
10224
  echo ""
10193
- echo "--- Sessions unused > ${session_ttl_days} days ---"
10225
+ echo "--- Sessions unused > ${session_ttl_hours} hours ---"
10194
10226
  local session_meta session_root session_hash session_last session_epoch
10195
10227
  local session_age session_lock session_db session_reap_ok
10196
10228
  while IFS= read -r session_meta; do
@@ -10230,7 +10262,7 @@ cmd_gc() {
10230
10262
  continue
10231
10263
  fi
10232
10264
  fi
10233
- echo " STALE: $session_hash (last_used=$session_last, age=$(( session_age / 86400 ))d)"
10265
+ echo " STALE: $session_hash (last_used=$session_last, age=$(( session_age / 3600 ))h)"
10234
10266
  actions=$(( actions + 1 ))
10235
10267
  if (( do_reap == 1 )); then
10236
10268
  local confirm_session="y"
@@ -10331,7 +10363,7 @@ cmd_self_test() {
10331
10363
  echo ""
10332
10364
 
10333
10365
  echo "--- Session retention configuration ---"
10334
- local self_script ttl_default ttl_legacy ttl_explicit ttl_fractional_seconds
10366
+ local self_script ttl_default ttl_legacy ttl_explicit ttl_hours_default ttl_hours_explicit ttl_fractional_seconds
10335
10367
  self_script="$(fmix_realpath "${BASH_SOURCE[0]}")"
10336
10368
  ttl_default="$(env -u FMIX_SESSION_TTL_DAYS -u FMIX_CACHE_TTL_DAYS \
10337
10369
  /bin/bash -c 'source "$1"; fmix_effective_session_ttl_days' \
@@ -10342,12 +10374,19 @@ cmd_self_test() {
10342
10374
  ttl_explicit="$(env FMIX_SESSION_TTL_DAYS=2 FMIX_CACHE_TTL_DAYS=3 \
10343
10375
  /bin/bash -c 'source "$1"; fmix_effective_session_ttl_days' \
10344
10376
  _ "$self_script")"
10377
+ ttl_hours_default="$(env -u FMIX_SESSION_TTL_HOURS -u FMIX_SESSION_TTL_DAYS -u FMIX_CACHE_TTL_DAYS \
10378
+ /bin/bash -c 'source "$1"; fmix_effective_session_ttl_hours' \
10379
+ _ "$self_script")"
10380
+ ttl_hours_explicit="$(env FMIX_SESSION_TTL_HOURS=2 FMIX_SESSION_TTL_DAYS=3 \
10381
+ /bin/bash -c 'source "$1"; fmix_effective_session_ttl_hours' \
10382
+ _ "$self_script")"
10345
10383
  ttl_fractional_seconds="$(FMIX_SESSION_TTL_DAYS=0.5 fmix_session_ttl_seconds)"
10346
10384
  if [[ "$ttl_default" == "1" && "$ttl_legacy" == "3" \
10347
- && "$ttl_explicit" == "2" && "$ttl_fractional_seconds" == "43200" ]]; then
10348
- st_pass "session retention shares defaults, override precedence, and fractional conversion"
10385
+ && "$ttl_explicit" == "2" && "$ttl_hours_default" == "4" \
10386
+ && "$ttl_hours_explicit" == "2" && "$ttl_fractional_seconds" == "43200" ]]; then
10387
+ st_pass "session retention shares legacy compatibility, four-hour default, override precedence, and fractional conversion"
10349
10388
  else
10350
- st_fail "session retention config default=$ttl_default legacy=$ttl_legacy explicit=$ttl_explicit fractional_seconds=$ttl_fractional_seconds"
10389
+ st_fail "session retention config days_default=$ttl_default days_legacy=$ttl_legacy days_explicit=$ttl_explicit hours_default=$ttl_hours_default hours_explicit=$ttl_hours_explicit fractional_seconds=$ttl_fractional_seconds"
10351
10390
  fi
10352
10391
  echo ""
10353
10392
 
@@ -14525,8 +14564,9 @@ Environment overrides:
14525
14564
  FMIX_HOT_PATH_BUDGET_S hot_path overhead budget seconds excl mix_test (default: 25)
14526
14565
  FMIX_SCHEMA_READY_TTL_S Schema-ready stamp TTL; auto-expire ledger skip (default: 300)
14527
14566
  OBAN_LICENSE_KEY Oban Pro license key override (or from ~/.config/calltelemetry/fmix.env / Doppler)
14528
- FMIX_SESSION_TTL_DAYS Inactive-session auto-purge and GC threshold (default: 1)
14529
- FMIX_CACHE_TTL_DAYS Legacy fallback used only when FMIX_SESSION_TTL_DAYS is unset
14567
+ FMIX_SESSION_TTL_HOURS Inactive-session auto-purge and GC threshold (default: 4)
14568
+ FMIX_SESSION_TTL_DAYS Legacy compatibility override, converted to hours when FMIX_SESSION_TTL_HOURS is unset
14569
+ FMIX_CACHE_TTL_DAYS Legacy compatibility fallback used when the hour/day overrides are unset
14530
14570
  FMIX_CONFIG_HOME Private configuration directory (default: ~/.config/calltelemetry)
14531
14571
  FMIX_ENV_FILE Explicit credential file (default: <config-home>/fmix.env)
14532
14572
  FMIX_DOPPLER_PROJECT Doppler project for credential fallback (default: ai-workspace)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calltelemetry/fmix",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "Verified native FMix runner for CallTelemetry workspaces",
5
5
  "bin": {
6
6
  "fmix": "bin/fmix"
@@ -24,7 +24,7 @@
24
24
  "directory": "packages/npm"
25
25
  },
26
26
  "fmix": {
27
- "runnerSha256": "3781b8be715aafed22bdeb3eb3efe45ad8e92bc091265b02a347819009807b26",
28
- "sourceTag": "fmix-v2.4.2"
27
+ "runnerSha256": "e33e6c5f707742722286eb263d2528213b7686b25affea79171715c25b85e70b",
28
+ "sourceTag": "fmix-v2.4.3"
29
29
  }
30
30
  }