@calltelemetry/fmix 2.4.2 → 2.4.4

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 +254 -49
  2. package/package.json +3 -3
package/bin/fmix CHANGED
@@ -11,6 +11,7 @@
11
11
  # ./fmix cache explain --worktree <path> --cache-base <N.N.N-stable>
12
12
  # ./fmix cache verify [--key <16-hex-template-key>]
13
13
  # # seed publish is explicit clean-stable-only maintenance; cache explain is read-only
14
+ # ./fmix ensure
14
15
  # ./fmix doctor
15
16
  # ./fmix status
16
17
  # ./fmix timing [--limit N] [--worktree <path>]
@@ -23,7 +24,7 @@ set -uo pipefail
23
24
  # ---------------------------------------------------------------------------
24
25
  # Constants & config
25
26
  # ---------------------------------------------------------------------------
26
- FMIX_VERSION="2.4.2"
27
+ FMIX_VERSION="2.4.4"
27
28
  FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
28
29
  FMIX_OS="$(uname -s)"
29
30
  FMIX_ARCH="$(uname -m)"
@@ -34,14 +35,15 @@ FMIX_LOCK_TIMEOUT="${FMIX_LOCK_TIMEOUT:-900}" # 15 min template build wait
34
35
  FMIX_LOCK_INIT_GRACE="${FMIX_LOCK_INIT_GRACE:-5}"
35
36
  FMIX_LOCK_METADATA_TTL_DAYS="${FMIX_LOCK_METADATA_TTL_DAYS:-7}"
36
37
  FMIX_WORKTREE_LOCK_TIMEOUT="${FMIX_WORKTREE_LOCK_TIMEOUT:-360}"
37
- # Session overlays are large (roughly 0.5 GiB each), so one day is the
38
+ # Session overlays are large (roughly 0.5 GiB each), so four hours is the
38
39
  # 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 ...`).
40
+ # the day-based variables as compatibility fallbacks for existing operator
41
+ # config, but leave the modern overrides unset when they were not supplied so
42
+ # command-scoped legacy overrides continue to work.
43
43
  FMIX_SESSION_TTL_DEFAULT="1"
44
44
  FMIX_SESSION_TTL_DAYS="${FMIX_SESSION_TTL_DAYS-}"
45
+ FMIX_SESSION_TTL_HOURS="${FMIX_SESSION_TTL_HOURS-}"
46
+ FMIX_SESSION_TTL_DEFAULT_HOURS="4"
45
47
  FMIX_SESSION_WARN_THRESHOLD="${FMIX_SESSION_WARN_THRESHOLD:-24}"
46
48
  FMIX_COPY_MODE="${FMIX_COPY_MODE:-}" # override: "full" to skip CoW
47
49
  FMIX_HOST_TEST_LOCK="${FMIX_HOST_TEST_LOCK:-1}" # default: serialize only CREATE/DROP DATABASE on this host
@@ -103,6 +105,10 @@ DB_USER="${FMIX_DB_USER:-calltelemetry}"
103
105
  DB_PASSWORD="${FMIX_DB_PASSWORD:-calltelemetry_dev_password}"
104
106
  NATS_HOST="${FMIX_NATS_HOST:-localhost}"
105
107
  NATS_PORT="${FMIX_NATS_PORT:-4222}"
108
+ FMIX_INFRA_PROJECT="${FMIX_INFRA_PROJECT:-ct-infra}"
109
+ FMIX_INFRA_SCHEMA="1"
110
+ FMIX_ENSURE="${FMIX_ENSURE:-1}"
111
+ FMIX_ENSURE_TIMEOUT="${FMIX_ENSURE_TIMEOUT:-90}"
106
112
 
107
113
  # Fixed dev constant SECRET_KEY_BASE (64 hex chars — only used in test env)
108
114
  SECRET_KEY_BASE="${FMIX_SECRET_KEY_BASE:-dev0000000000000000000000000000000000000000000000000000000000000001}"
@@ -787,15 +793,44 @@ fmix_effective_session_ttl_days() {
787
793
  "$FMIX_SESSION_TTL_DEFAULT" FMIX_SESSION_TTL_DAYS
788
794
  }
789
795
 
796
+ fmix_effective_session_ttl_hours() {
797
+ local explicit_hours="${FMIX_SESSION_TTL_HOURS-}"
798
+ local legacy_days="${FMIX_SESSION_TTL_DAYS:-${FMIX_CACHE_TTL_DAYS:-}}"
799
+ local hours
800
+ if [[ -n "$explicit_hours" ]]; then
801
+ fmix_nonnegative_number_or_default \
802
+ "$explicit_hours" "$FMIX_SESSION_TTL_DEFAULT_HOURS" FMIX_SESSION_TTL_HOURS
803
+ return 0
804
+ fi
805
+ if [[ -n "$legacy_days" ]]; then
806
+ hours="$(fmix_nonnegative_number_or_default \
807
+ "$legacy_days" "$FMIX_SESSION_TTL_DEFAULT" FMIX_SESSION_TTL_DAYS)"
808
+ fmix_session_ttl_hours_from_days "$hours"
809
+ return 0
810
+ fi
811
+ printf '%s\n' "$FMIX_SESSION_TTL_DEFAULT_HOURS"
812
+ }
813
+
814
+ fmix_session_ttl_hours_from_days() {
815
+ local days="$1" py_bin
816
+ if [[ "$days" =~ ^[0-9]+$ ]]; then
817
+ printf '%s\n' "$(( days * 24 ))"
818
+ return 0
819
+ fi
820
+ py_bin="$(fmix_python_bin)"
821
+ "$py_bin" -c 'import sys; print(float(sys.argv[1]) * 24)' \
822
+ "$days" 2>/dev/null || printf '4\n'
823
+ }
824
+
790
825
  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 ))"
826
+ local ttl_hours="${1:-$(fmix_effective_session_ttl_hours)}" py_bin
827
+ if [[ "$ttl_hours" =~ ^[0-9]+$ ]]; then
828
+ printf '%s\n' "$(( ttl_hours * 3600 ))"
794
829
  return 0
795
830
  fi
796
831
  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'
832
+ "$py_bin" -c 'import sys; print(int(float(sys.argv[1]) * 3600))' \
833
+ "$ttl_hours" 2>/dev/null || printf '14400\n'
799
834
  }
800
835
 
801
836
  fmix_control_psql() {
@@ -935,10 +970,11 @@ fmix_session_meta_file() {
935
970
  }
936
971
 
937
972
  fmix_create_or_touch_meta_json() {
938
- local worktree="$1" meta created lockfile_hash app_name ttl_days tmp
973
+ local worktree="$1" meta created lockfile_hash app_name ttl_days ttl_hours tmp
939
974
  meta="$(fmix_session_meta_file)" || return 1
940
975
 
941
976
  ttl_days="$(fmix_effective_session_ttl_days)"
977
+ ttl_hours="$(fmix_effective_session_ttl_hours)"
942
978
 
943
979
  created=""
944
980
  if [[ -f "$meta" ]]; then
@@ -984,6 +1020,7 @@ fmix_create_or_touch_meta_json() {
984
1020
  "last_accessed": "$(fmix_now)",
985
1021
  "last_used": "$(fmix_now)",
986
1022
  "ttl_days": $ttl_days,
1023
+ "ttl_hours": $ttl_hours,
987
1024
  "lockfile_hash": $(fmix_json_escape "$lockfile_hash"),
988
1025
  "status": "active"
989
1026
  }
@@ -1206,9 +1243,9 @@ fmix_drop_orphan_session_db() {
1206
1243
 
1207
1244
  fmix_purge_expired_sessions() {
1208
1245
  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")"
1246
+ local ttl_hours ttl_seconds
1247
+ ttl_hours="$(fmix_effective_session_ttl_hours)"
1248
+ ttl_seconds="$(fmix_session_ttl_seconds "$ttl_hours")"
1212
1249
  local now session_meta session_root session_hash session_last session_epoch session_age session_lock session_db
1213
1250
  local dir_mtime dir_age session_meta_paths empty_dir_paths
1214
1251
  now="$(fmix_epoch)"
@@ -1310,7 +1347,7 @@ fmix_purge_expired_sessions() {
1310
1347
  fi
1311
1348
 
1312
1349
  if (( quiet == 0 && purged_count > 0 )); then
1313
- fmix_info "Purged $purged_count expired session build artifact(s) (TTL: ${ttl_days}d)."
1350
+ fmix_info "Purged $purged_count expired session build artifact(s) (TTL: ${ttl_hours}h)."
1314
1351
  fi
1315
1352
  return 0
1316
1353
  }
@@ -4053,22 +4090,7 @@ fmix_preflight() {
4053
4090
  esac
4054
4091
  done
4055
4092
 
4056
- # postgres TCP check
4057
- if ! nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null; then
4058
- fmix_error "Postgres not reachable at $DB_HOST:$DB_PORT."
4059
- fmix_error "Run: ./infra.sh up (from the monorepo root)"
4060
- fail=1
4061
- fi
4062
-
4063
- # NATS TCP check (warn only — tests stub NATS)
4064
- if ! nc -z "$NATS_HOST" "$NATS_PORT" 2>/dev/null; then
4065
- fmix_warn "NATS not reachable at $NATS_HOST:$NATS_PORT."
4066
- fmix_warn "Run: ./infra.sh up — some tests may fail without NATS."
4067
- fi
4068
-
4069
- # psql availability check
4070
- if ! fmix_control_psql 5 -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "SELECT 1" >/dev/null 2>&1; then
4071
- fmix_error "Cannot connect to postgres as user '$DB_USER'. Check DB credentials or run './infra.sh up'."
4093
+ if ! fmix_ensure_infra; then
4072
4094
  fail=1
4073
4095
  fi
4074
4096
 
@@ -9056,6 +9078,176 @@ cmd_task() {
9056
9078
  return "$task_rc"
9057
9079
  }
9058
9080
 
9081
+ # ---------------------------------------------------------------------------
9082
+ # Shared postgres + NATS (one host-wide ct-infra plane)
9083
+ # ---------------------------------------------------------------------------
9084
+
9085
+ fmix_infra_postgres_ready() {
9086
+ nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null \
9087
+ && fmix_control_psql 5 -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "SELECT 1" >/dev/null 2>&1
9088
+ }
9089
+
9090
+ fmix_infra_nats_ready() {
9091
+ nc -z "$NATS_HOST" "$NATS_PORT" 2>/dev/null
9092
+ }
9093
+
9094
+ fmix_infra_ready() {
9095
+ fmix_infra_postgres_ready && fmix_infra_nats_ready
9096
+ }
9097
+
9098
+ fmix_docker_usable() {
9099
+ command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1
9100
+ }
9101
+
9102
+ fmix_infra_host_is_local() {
9103
+ case "$DB_HOST" in
9104
+ localhost|127.0.0.1|::1) return 0 ;;
9105
+ *) return 1 ;;
9106
+ esac
9107
+ }
9108
+
9109
+ fmix_write_ensure_compose() {
9110
+ local dir="$FMIX_HOME/infra"
9111
+ mkdir -p "$dir" || return 1
9112
+ cat >"$dir/nats.conf" <<'NATS'
9113
+ max_payload: 5242880
9114
+ jetstream {
9115
+ store_dir: "/data/jetstream"
9116
+ max_memory_store: 1G
9117
+ max_file_store: 10G
9118
+ }
9119
+ http_port: 8222
9120
+ debug: false
9121
+ trace: false
9122
+ max_connections: 500
9123
+ NATS
9124
+ cat >"$dir/compose-ensure.yml" <<YAML
9125
+ # Written by fmix ensure (schema ${FMIX_INFRA_SCHEMA}). Postgres + NATS only.
9126
+ # Project name ${FMIX_INFRA_PROJECT} matches ai-workspace ./infra.sh so one stack is reused.
9127
+ services:
9128
+ postgres:
9129
+ hostname: postgres
9130
+ image: calltelemetry/postgres:14
9131
+ restart: unless-stopped
9132
+ command:
9133
+ - postgres
9134
+ - -c
9135
+ - max_connections=600
9136
+ - -c
9137
+ - shared_buffers=512MB
9138
+ - -c
9139
+ - work_mem=16MB
9140
+ environment:
9141
+ POSTGRES_USER: ${DB_USER}
9142
+ POSTGRES_PASSWORD: ${DB_PASSWORD}
9143
+ POSTGRES_DB: calltelemetry_dev
9144
+ ports:
9145
+ - "${DB_PORT}:5432"
9146
+ volumes:
9147
+ - ct-pgdata:/var/lib/postgresql/data
9148
+ healthcheck:
9149
+ test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d calltelemetry_dev"]
9150
+ interval: 5s
9151
+ timeout: 5s
9152
+ retries: 12
9153
+ start_period: 20s
9154
+ nats:
9155
+ hostname: nats
9156
+ image: nats:2.11
9157
+ restart: unless-stopped
9158
+ command: ["-c", "/etc/nats/nats.conf"]
9159
+ ports:
9160
+ - "${NATS_PORT}:4222"
9161
+ - "8222:8222"
9162
+ volumes:
9163
+ - ${dir}/nats.conf:/etc/nats/nats.conf:ro
9164
+ - ct-natsdata:/data
9165
+ volumes:
9166
+ ct-pgdata:
9167
+ ct-natsdata:
9168
+ YAML
9169
+ }
9170
+
9171
+ fmix_start_existing_ct_infra() {
9172
+ local name started=0
9173
+ for name in "${FMIX_INFRA_PROJECT}-postgres-1" "${FMIX_INFRA_PROJECT}-nats-1"; do
9174
+ if docker inspect "$name" >/dev/null 2>&1; then
9175
+ docker start "$name" >/dev/null 2>&1 || true
9176
+ started=1
9177
+ fi
9178
+ done
9179
+ [[ "$started" == "1" ]]
9180
+ }
9181
+
9182
+ fmix_compose_up_ensure() {
9183
+ fmix_write_ensure_compose || return 1
9184
+ docker compose -p "$FMIX_INFRA_PROJECT" -f "$FMIX_HOME/infra/compose-ensure.yml" up -d postgres nats
9185
+ }
9186
+
9187
+ fmix_wait_infra() {
9188
+ local now deadline
9189
+ now="$(fmix_epoch)"
9190
+ deadline=$(( now + FMIX_ENSURE_TIMEOUT ))
9191
+ while (( $(fmix_epoch) < deadline )); do
9192
+ if fmix_infra_ready; then
9193
+ return 0
9194
+ fi
9195
+ sleep 1
9196
+ done
9197
+ return 1
9198
+ }
9199
+
9200
+ fmix_ensure_infra() {
9201
+ if fmix_infra_ready; then
9202
+ echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
9203
+ return 0
9204
+ fi
9205
+
9206
+ if [[ "$FMIX_ENSURE" != "1" ]]; then
9207
+ fmix_error "Postgres/NATS not ready at $DB_HOST:$DB_PORT / $NATS_HOST:$NATS_PORT (FMIX_ENSURE=0)."
9208
+ return 1
9209
+ fi
9210
+
9211
+ if ! fmix_infra_host_is_local; then
9212
+ fmix_error "Postgres $DB_HOST:$DB_PORT is not reachable. Remote FMIX_DB_HOST is operator-owned; fmix will not start Docker."
9213
+ return 1
9214
+ fi
9215
+
9216
+ if nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null && ! fmix_infra_postgres_ready; then
9217
+ fmix_error "Port $DB_PORT is occupied but not postgres user '$DB_USER'. Refusing to start a second database."
9218
+ return 1
9219
+ fi
9220
+
9221
+ if ! fmix_docker_usable; then
9222
+ fmix_error "Shared postgres/NATS is down and Docker is not usable. Start OrbStack/Docker, then retry: fmix ensure"
9223
+ return 1
9224
+ fi
9225
+
9226
+ echo " starting shared $FMIX_INFRA_PROJECT (postgres + nats)..."
9227
+ fmix_start_existing_ct_infra || true
9228
+ if fmix_wait_infra; then
9229
+ echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
9230
+ return 0
9231
+ fi
9232
+ if ! fmix_compose_up_ensure; then
9233
+ fmix_error "docker compose could not start $FMIX_INFRA_PROJECT postgres/nats"
9234
+ return 1
9235
+ fi
9236
+ if ! fmix_wait_infra; then
9237
+ fmix_error "Shared infra did not become ready within ${FMIX_ENSURE_TIMEOUT}s at $DB_HOST:$DB_PORT / $NATS_HOST:$NATS_PORT"
9238
+ return 1
9239
+ fi
9240
+ echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
9241
+ return 0
9242
+ }
9243
+
9244
+ cmd_ensure() {
9245
+ echo "=== fmix ensure ==="
9246
+ echo " target: postgres $DB_HOST:$DB_PORT user=$DB_USER ; nats $NATS_HOST:$NATS_PORT"
9247
+ echo " project: $FMIX_INFRA_PROJECT (one host-wide plane; not a per-branch stack)"
9248
+ fmix_ensure_infra
9249
+ }
9250
+
9059
9251
  # ---------------------------------------------------------------------------
9060
9252
  # cmd: fmix doctor
9061
9253
  # ---------------------------------------------------------------------------
@@ -9154,7 +9346,7 @@ cmd_doctor() {
9154
9346
  if nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null; then
9155
9347
  echo " [OK] postgres TCP $DB_HOST:$DB_PORT"
9156
9348
  else
9157
- echo " [FAIL] postgres not reachable at $DB_HOST:$DB_PORT — run: ./infra.sh up"
9349
+ echo " [FAIL] postgres not reachable at $DB_HOST:$DB_PORT — run: fmix ensure"
9158
9350
  fail=1
9159
9351
  fi
9160
9352
 
@@ -9185,7 +9377,7 @@ cmd_doctor() {
9185
9377
  if nc -z "$NATS_HOST" "$NATS_PORT" 2>/dev/null; then
9186
9378
  echo " [OK] NATS TCP $NATS_HOST:$NATS_PORT"
9187
9379
  else
9188
- echo " [WARN] NATS not reachable at $NATS_HOST:$NATS_PORT — run: ./infra.sh up (some tests may fail)"
9380
+ echo " [WARN] NATS not reachable at $NATS_HOST:$NATS_PORT — run: fmix ensure (some tests may fail)"
9189
9381
  fi
9190
9382
 
9191
9383
  # Headless Chromium for ChromicPDF-backed reporting suites (API-1184).
@@ -9288,8 +9480,8 @@ cmd_doctor() {
9288
9480
 
9289
9481
  # Session metadata & TTL cache lifecycle inspection & purging
9290
9482
  local ttl_val
9291
- ttl_val="$(fmix_effective_session_ttl_days)"
9292
- echo " Session metadata & TTL cache inspection (FMIX_SESSION_TTL_DAYS=${ttl_val}):"
9483
+ ttl_val="$(fmix_effective_session_ttl_hours)"
9484
+ echo " Session metadata & TTL cache inspection (FMIX_SESSION_TTL_HOURS=${ttl_val}h):"
9293
9485
  local session_meta_paths="" session_scan_ok=1
9294
9486
  if ! fmix_purge_expired_sessions 0; then
9295
9487
  echo " [FAIL] session discovery failed; skipped orphan scratch DB cleanup"
@@ -10186,11 +10378,11 @@ cmd_gc() {
10186
10378
 
10187
10379
  # 6. Expired session overlays. Reaping is lease-aware: the exact session
10188
10380
  # 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")"
10381
+ local session_ttl_hours session_ttl_seconds
10382
+ session_ttl_hours="$(fmix_effective_session_ttl_hours)"
10383
+ session_ttl_seconds="$(fmix_session_ttl_seconds "$session_ttl_hours")"
10192
10384
  echo ""
10193
- echo "--- Sessions unused > ${session_ttl_days} days ---"
10385
+ echo "--- Sessions unused > ${session_ttl_hours} hours ---"
10194
10386
  local session_meta session_root session_hash session_last session_epoch
10195
10387
  local session_age session_lock session_db session_reap_ok
10196
10388
  while IFS= read -r session_meta; do
@@ -10230,7 +10422,7 @@ cmd_gc() {
10230
10422
  continue
10231
10423
  fi
10232
10424
  fi
10233
- echo " STALE: $session_hash (last_used=$session_last, age=$(( session_age / 86400 ))d)"
10425
+ echo " STALE: $session_hash (last_used=$session_last, age=$(( session_age / 3600 ))h)"
10234
10426
  actions=$(( actions + 1 ))
10235
10427
  if (( do_reap == 1 )); then
10236
10428
  local confirm_session="y"
@@ -10331,7 +10523,7 @@ cmd_self_test() {
10331
10523
  echo ""
10332
10524
 
10333
10525
  echo "--- Session retention configuration ---"
10334
- local self_script ttl_default ttl_legacy ttl_explicit ttl_fractional_seconds
10526
+ local self_script ttl_default ttl_legacy ttl_explicit ttl_hours_default ttl_hours_explicit ttl_fractional_seconds
10335
10527
  self_script="$(fmix_realpath "${BASH_SOURCE[0]}")"
10336
10528
  ttl_default="$(env -u FMIX_SESSION_TTL_DAYS -u FMIX_CACHE_TTL_DAYS \
10337
10529
  /bin/bash -c 'source "$1"; fmix_effective_session_ttl_days' \
@@ -10342,12 +10534,19 @@ cmd_self_test() {
10342
10534
  ttl_explicit="$(env FMIX_SESSION_TTL_DAYS=2 FMIX_CACHE_TTL_DAYS=3 \
10343
10535
  /bin/bash -c 'source "$1"; fmix_effective_session_ttl_days' \
10344
10536
  _ "$self_script")"
10537
+ ttl_hours_default="$(env -u FMIX_SESSION_TTL_HOURS -u FMIX_SESSION_TTL_DAYS -u FMIX_CACHE_TTL_DAYS \
10538
+ /bin/bash -c 'source "$1"; fmix_effective_session_ttl_hours' \
10539
+ _ "$self_script")"
10540
+ ttl_hours_explicit="$(env FMIX_SESSION_TTL_HOURS=2 FMIX_SESSION_TTL_DAYS=3 \
10541
+ /bin/bash -c 'source "$1"; fmix_effective_session_ttl_hours' \
10542
+ _ "$self_script")"
10345
10543
  ttl_fractional_seconds="$(FMIX_SESSION_TTL_DAYS=0.5 fmix_session_ttl_seconds)"
10346
10544
  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"
10545
+ && "$ttl_explicit" == "2" && "$ttl_hours_default" == "4" \
10546
+ && "$ttl_hours_explicit" == "2" && "$ttl_fractional_seconds" == "43200" ]]; then
10547
+ st_pass "session retention shares legacy compatibility, four-hour default, override precedence, and fractional conversion"
10349
10548
  else
10350
- st_fail "session retention config default=$ttl_default legacy=$ttl_legacy explicit=$ttl_explicit fractional_seconds=$ttl_fractional_seconds"
10549
+ 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
10550
  fi
10352
10551
  echo ""
10353
10552
 
@@ -14195,7 +14394,7 @@ PY
14195
14394
  st_fail "postgres reachable but auth failed for user=$DB_USER — check FMIX_DB_PASSWORD"
14196
14395
  fi
14197
14396
  else
14198
- st_skip "postgres $DB_HOST:$DB_PORT not reachable — OK in bare container or without infra.sh up"
14397
+ st_skip "postgres $DB_HOST:$DB_PORT not reachable — OK in bare container or without fmix ensure"
14199
14398
  fi
14200
14399
 
14201
14400
  # 8. asdf toolchain (skip in bare container)
@@ -14470,6 +14669,7 @@ Usage:
14470
14669
  ./fmix seed publish --worktree <path> [--session <id>] --cache-base <N.N.N-stable>
14471
14670
  ./fmix cache explain --worktree <path> --cache-base <N.N.N-stable>
14472
14671
  ./fmix cache verify [--key <16-hex-template-key>]
14672
+ ./fmix ensure # start or reuse shared postgres + NATS (ct-infra)
14473
14673
  ./fmix doctor
14474
14674
  ./fmix status
14475
14675
  ./fmix timing [--limit N] [--worktree <path>] # phase timings + session fragmentation
@@ -14525,14 +14725,18 @@ Environment overrides:
14525
14725
  FMIX_HOT_PATH_BUDGET_S hot_path overhead budget seconds excl mix_test (default: 25)
14526
14726
  FMIX_SCHEMA_READY_TTL_S Schema-ready stamp TTL; auto-expire ledger skip (default: 300)
14527
14727
  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
14728
+ FMIX_SESSION_TTL_HOURS Inactive-session auto-purge and GC threshold (default: 4)
14729
+ FMIX_SESSION_TTL_DAYS Legacy compatibility override, converted to hours when FMIX_SESSION_TTL_HOURS is unset
14730
+ FMIX_CACHE_TTL_DAYS Legacy compatibility fallback used when the hour/day overrides are unset
14530
14731
  FMIX_CONFIG_HOME Private configuration directory (default: ~/.config/calltelemetry)
14531
14732
  FMIX_ENV_FILE Explicit credential file (default: <config-home>/fmix.env)
14532
14733
  FMIX_DOPPLER_PROJECT Doppler project for credential fallback (default: ai-workspace)
14533
14734
  FMIX_DOPPLER_CONFIG Doppler config for credential fallback (default: dev_personal)
14534
14735
  FMIX_SESSION_WARN_THRESHOLD Per-host session count that triggers a gc warning (default: 24)
14535
14736
  FMIX_STABLE_BASE Opt-in stable dependency base for fmix test (default: unset)
14737
+ FMIX_ENSURE Set to 0 to skip auto-starting shared postgres/NATS (default: 1)
14738
+ FMIX_ENSURE_TIMEOUT Seconds to wait after starting ct-infra (default: 90)
14739
+ FMIX_INFRA_PROJECT Docker Compose project for shared infra (default: ct-infra)
14536
14740
  FMIX_DB_HOST Postgres host (default: localhost)
14537
14741
  FMIX_DB_PORT Postgres port (default: 5432)
14538
14742
  FMIX_DB_USER Postgres user (default: calltelemetry)
@@ -14603,6 +14807,7 @@ main() {
14603
14807
  setup) cmd_setup "$@" ;;
14604
14808
  seed) cmd_seed "$@" ;;
14605
14809
  cache) cmd_cache "$@" ;;
14810
+ ensure) cmd_ensure "$@" ;;
14606
14811
  doctor) cmd_doctor "$@" ;;
14607
14812
  status) cmd_status "$@" ;;
14608
14813
  timing) cmd_timing "$@" ;;
@@ -14611,7 +14816,7 @@ main() {
14611
14816
  self-test) cmd_self_test "$@" ;;
14612
14817
  *)
14613
14818
  fmix_error "Unknown command: $cmd"
14614
- fmix_error "Valid commands: test, coverage, task, setup, seed publish, cache explain, cache verify, doctor, status, timing, gc, install, self-test, version, help"
14819
+ fmix_error "Valid commands: test, coverage, task, setup, seed publish, cache explain, cache verify, ensure, doctor, status, timing, gc, install, self-test, version, help"
14615
14820
  return 1
14616
14821
  ;;
14617
14822
  esac
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calltelemetry/fmix",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
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": "e2cbf06d87961a954b87a746e56bcf6bd9400fc299f127b50daac7505696e482",
28
+ "sourceTag": "fmix-v2.4.4"
29
29
  }
30
30
  }