#!/usr/bin/env bash
# Desktop/x COVER · spread BGS ground + BGF measure · power · mem · cleanup · cpu cache
# Law: BGS only root · BGF only measure · free SPV separate · never neural
# BGF = AXLE GREASE IN EVERY BEARING · instantiate ALL · no kidding
# sudo: drop_caches / some power · password via sudo -S if needed
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="$ROOT/out"
LOG="$OUT/cover-$(date +%Y%m%d-%H%M%S).txt"
mkdir -p "$OUT"
SUDO_PASS="${SUDO_PASS:-mememe}"

bgf() { echo $(( ($1 - $2) | 1 )); }
# atoms on BGF · still linear · NOT side engines · NOT SDF place
# EZZIE electric free eor · PHI scale · THERMO heat band
ezzie() { echo $(( ($1 ^ $2) | 1 )); }
essie() {
  local a=${1//[^0-9-]/} b=${2//[^0-9-]/}
  a=${a:-0}; b=${b:-0}
  local s=$(( a ^ b ))
  if (( (s & 7) == 0 )); then echo 1; else echo $(( s | 1 )); fi
}
phi() { echo $(( ($1 * $2) | 1 )); }
thermo() {
  # edi=temp_C · cool<=70→0 · warm<=84→1 · hot→2 · then |1 live on BGF
  local t=${1//[^0-9-]/}; t=${t:-0}
  local band
  if (( t <= 70 )); then band=0
  elif (( t <= 84 )); then band=1
  else band=2
  fi
  echo $(( band | 1 ))
}
spv() {
  local a=${1//[^0-9-]/} b=${2//[^0-9-]/} c=${3//[^0-9-]/}
  a=${a:-0}; b=${b:-0}; c=${c:-0}
  echo $(( (a ^ b ^ c) | 1 ))
}
bgs1() { echo $(( $1 | 1 )); }
heur_near() {
  local a=$1 b=$2 th=$3 d
  d=$(( a > b ? a - b : b - a ))
  (( d < th )) && echo 1 || echo 0
}

sudo_run() {
  # never interactive prompt · NOPASSWD → askpass → pipe
  if [[ "$(id -u)" -eq 0 ]]; then
    "$@"
    return $?
  fi
  if sudo -n true 2>/dev/null; then
    sudo -n "$@" 2>/dev/null
    return $?
  fi
  local ask="${ROOT}/Build/sudo-askpass.sh"
  if [[ -x "$ask" ]]; then
    SUDO_ASKPASS="$ask" SUDO_PASS="${SUDO_PASS:-mememe}" sudo -A -p '' "$@" 2>/dev/null
    return $?
  fi
  printf '%s\n' "${SUDO_PASS:-mememe}" | sudo -S -p '' "$@" 2>/dev/null
}

say() { echo "$*" | tee -a "$LOG"; }

# ---------- samples (BGF measure) ----------
sample_mem() {
  # MemAvailable kB from /proc/meminfo
  awk '/^MemAvailable:/{print $2; exit}' /proc/meminfo
}
sample_mem_free() {
  awk '/^MemFree:/{print $2; exit}' /proc/meminfo
}
sample_cached() {
  awk '/^Cached:/{print $2; exit}' /proc/meminfo
}
sample_buffers() {
  awk '/^Buffers:/{print $2; exit}' /proc/meminfo
}
sample_load() {
  awk '{printf "%d", $1*100}' /proc/loadavg
}
sample_mhz() {
  # average scaling cur
  local s=0 n=0 f
  for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq; do
    [[ -r "$f" ]] || continue
    s=$((s + $(cat "$f")))
    n=$((n + 1))
  done
  (( n > 0 )) && echo $((s / n / 1000)) || echo 0
}
sample_temp_mc() {
  local f t=0
  for f in /sys/class/hwmon/hwmon*/temp*_input; do
    [[ -r "$f" ]] || continue
    t=$(cat "$f" 2>/dev/null | head -1)
    t=${t//[^0-9]/}
    [[ -n "$t" && "$t" -gt 0 ]] && break
  done
  echo "${t:-0}"
}
sample_cache_kb() {
  # sum L1d+L1i+L2+L3 from first package report via lscpu or sysfs
  local sum=0
  for f in /sys/devices/system/cpu/cpu0/cache/index*/size; do
    [[ -r "$f" ]] || continue
    local s
    s=$(cat "$f")
    # 32K 1024K 32768K
    s=${s%K}
    sum=$((sum + s))
  done
  echo "$sum"
}

# TX / RX · BGS field_one class · net counters (not disk) · enp10s0 preferred
sample_net_iface() {
  local prefer="${1:-enp10s0}" line iface
  if [[ -r /proc/net/dev ]]; then
    if awk -v p="$prefer:" '$1==p {found=1} END{exit !found}' /proc/net/dev 2>/dev/null; then
      echo "$prefer"
      return
    fi
    # first non-lo
    iface=$(awk -F: 'NR>2 {gsub(/ /,"",$1); if($1!="lo"){print $1; exit}}' /proc/net/dev)
    echo "${iface:-lo}"
  else
    echo lo
  fi
}
sample_tx_bytes() {
  local ifc; ifc=$(sample_net_iface)
  awk -v i="$ifc:" '$1==i {print $10; exit}' /proc/net/dev 2>/dev/null || echo 0
}
sample_rx_bytes() {
  local ifc; ifc=$(sample_net_iface)
  awk -v i="$ifc:" '$1==i {print $2; exit}' /proc/net/dev 2>/dev/null || echo 0
}
sample_tx_packets() {
  local ifc; ifc=$(sample_net_iface)
  awk -v i="$ifc:" '$1==i {print $11; exit}' /proc/net/dev 2>/dev/null || echo 0
}
sample_rx_packets() {
  local ifc; ifc=$(sample_net_iface)
  awk -v i="$ifc:" '$1==i {print $3; exit}' /proc/net/dev 2>/dev/null || echo 0
}
# BGS pin sim · edi=0 → 7|1 know_her · else value|1 field_one
bgs() {
  local v=${1:-0}
  if (( v == 0 )); then echo $(( 7 | 1 )); else echo $(( v | 1 )); fi
}
# TX/RX limbs are BGS field_one · edi|1
tx_pin() { bgs1 "${1:-0}"; }
rx_pin() { bgs1 "${1:-0}"; }

# clflush thrash — userland CPU cache line evict for a buffer (not global WBINVD)
build_clflush() {
  local c="$OUT/clflush_cover.c" b="$OUT/clflush_cover"
  cat >"$c" <<'C'
#define _GNU_SOURCE
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <x86intrin.h>
int main(int argc, char **argv) {
  size_t mb = 64;
  if (argc > 1) mb = (size_t)atoi(argv[1]);
  if (mb < 1) mb = 1;
  if (mb > 512) mb = 512;
  size_t n = mb * 1024ull * 1024ull;
  volatile unsigned char *p = (volatile unsigned char *)aligned_alloc(64, n);
  if (!p) return 1;
  /* fill · BGF touch all lines */
  for (size_t i = 0; i < n; i += 64) p[i] = (unsigned char)(i | 1);
  /* measure-ish: read sum */
  unsigned long long s = 0;
  for (size_t i = 0; i < n; i += 64) s += p[i];
  /* clflush each line · spread cover through CPU caches for this buffer */
  for (size_t i = 0; i < n; i += 64) {
    _mm_clflush((const void *)(p + i));
  }
  _mm_mfence();
  /* second pass touch after flush */
  for (size_t i = 0; i < n; i += 64) s ^= p[i];
  printf("%llu\n", (unsigned long long)(s | 1));
  free((void *)p);
  return 0;
}
C
  gcc -O2 -o "$b" "$c" 2>/dev/null || gcc -O2 -mclflushopt -o "$b" "$c" 2>/dev/null || return 1
  echo "$b"
}

cmd_measure() {
  say "=== COVER MEASURE · BGF samples · $(date -Iseconds) ==="
  local ma mf mc mb ld mhz tmp ck
  ma=$(sample_mem); mf=$(sample_mem_free); mc=$(sample_cached)
  mb=$(sample_buffers); ld=$(sample_load); mhz=$(sample_mhz)
  tmp=$(sample_temp_mc); ck=$(sample_cache_kb)
  say "BGS ground: remain IN · field_one clean"
  say "MEM available_kB=$ma free_kB=$mf cached_kB=$mc buffers_kB=$mb"
  say "CPU loadx100=$ld avg_mhz=$mhz temp_mC=$tmp"
  say "CPU cache_sysfs_sum_kB=$ck  (L1/L2/L3 geometry · not disk)"
  say "BGF mem_free_vs_cache=$(bgf "$mf" "$mc")  load_vs_mhz=$(bgf "$ld" "$mhz")"
  say "FREE fingerprint=$(spv "$ma" "$ld" "$tmp")"
  # export for cleanup delta
  echo "$ma $mf $mc $ld $mhz $tmp" >"$OUT/cover_before.txt"
}

# unclean file residue · us + world · never leave holes of dirt
cmd_clean_files() {
  say "=== CLEAN FILES · no unclean · us + world · $(date -Iseconds) ==="
  # tmp residue (field orphans · never world-visible dirt)
  rm -rf /tmp/grok-orphan-* /tmp/rtx_* /tmp/amouranth* /tmp/never_fold* /tmp/bgf_* 2>/dev/null || true
  rm -f /tmp/core.* /tmp/*.core 2>/dev/null || true
  # out half-writes · tmp · bak holes
  rm -f "$OUT"/*.tmp "$OUT"/*.bak "$OUT"/*~ "$OUT"/core "$OUT"/core.* 2>/dev/null || true
  # home trash that looks unclean to desk
  rm -f /home/default/core /home/default/core.* 2>/dev/null || true
  # python/http cache junk if present
  rm -rf /tmp/__pycache__ /home/default/Desktop/x/**/__pycache__ 2>/dev/null || true
  find /home/default/Desktop/x/out -maxdepth 1 -type f \( -name '*.tmp' -o -name '*~' -o -name '*.swp' \) -delete 2>/dev/null || true
  # old cover logs only keep last 12 (no hole of stale logs)
  local nlogs
  nlogs=$(ls -1t "$OUT"/cover-*.txt 2>/dev/null | wc -l | tr -d ' ')
  if (( nlogs > 12 )); then
    ls -1t "$OUT"/cover-*.txt 2>/dev/null | tail -n +13 | xargs -r rm -f
    say "cover logs trimmed · kept 12"
  fi
  say "files unclean cleared · tmp/out residue gone"
}

# ALWAYS drop page/dentry/inode cache · no "leave cache" · insta clean
cmd_drop_cache() {
  sync
  if sudo_run sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'; then
    say "drop_caches=3 OK · page+dentries+inodes CLEARED"
    return 0
  fi
  say "drop_caches FAIL · no sudo"
  return 1
}

cmd_cleanup() {
  say "=== COVER CLEANUP · CACHE OUT · files clean · $(date -Iseconds) ==="
  cmd_clean_files
  # journal user vacuum if large (user)
  journalctl --user --vacuum-size=40M >/dev/null 2>&1 || true
  # page cache / dentries / inodes — ALWAYS · no cache left dirty
  cmd_drop_cache || true
  # second pass · no holes in clean
  cmd_drop_cache || true
  # compact memory
  if sudo_run sh -c 'echo 1 > /proc/sys/vm/compact_memory'; then
    say "compact_memory OK"
  else
    say "compact_memory SKIP"
  fi
  # swap trim if any
  if [[ $(awk '/^SwapTotal:/{print $2}' /proc/meminfo) -gt 0 ]]; then
    sudo_run sh -c 'swapoff -a && swapon -a' 2>/dev/null && say "swap cycle OK" || say "swap cycle SKIP"
  fi
  # orphan + xdg virus
  if [[ -x /usr/local/bin/grok-orphan-kill ]]; then
    /usr/local/bin/grok-orphan-kill >/dev/null 2>&1 || true
    say "orphan reaper pass OK"
  fi
  say "CLEAN · no cache hole · no unclean files · remain IN"
}

cmd_power() {
  say "=== COVER POWER · cool/governor · $(date -Iseconds) ==="
  # governors report
  local g
  g=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null || echo unknown)
  say "governor_cpu0=$g  (cool limbs: cool/cool_cpu clamp 0..3|1)"
  # optional powersave spread (user asked cover power cleanup)
  if [[ "${COVER_POWERSAVE:-0}" == "1" ]]; then
    if sudo_run sh -c 'for g in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo powersave > \"$g\"; done'; then
      say "powersave applied all CPUs"
    fi
  else
    say "powersave not forced · set COVER_POWERSAVE=1 to apply"
  fi
  # RAPL energy if present
  if ls /sys/class/powercap/intel-rapl*/*/energy_uj >/dev/null 2>&1; then
    say "RAPL energy_uj sample:"
    head -3 /sys/class/powercap/intel-rapl*/*/energy_uj 2>/dev/null | tee -a "$LOG" || true
  fi
  # AMD energy optional
  sample_temp_mc | tee -a "$LOG" >/dev/null
  say "temp_mC=$(sample_temp_mc)"
}

cmd_cache() {
  say "=== COVER CPU CACHE · measure + clflush thrash · $(date -Iseconds) ==="
  say "geometry:"
  for idx in /sys/devices/system/cpu/cpu0/cache/index*; do
    [[ -d "$idx" ]] || continue
    say "  L$(cat "$idx/level") $(cat "$idx/type") $(cat "$idx/size") shared_cpu=$(cat "$idx/shared_cpu_list" 2>/dev/null | tr -d '\n')"
  done
  say "note: full WBINVD is privileged kernel · we clflush a RAM window (userland BGF)"
  local bin mb="${COVER_CACHE_MB:-128}"
  if bin=$(build_clflush); then
    local t0 t1 before after
    before=$(date +%s%N)
    after=$("$bin" "$mb")
    t1=$(date +%s%N)
    local dt_ms=$(( (t1 - before) / 1000000 ))
    say "clflush_cover ${mb}MiB free_mark=$after time_ms=$dt_ms"
    say "BGF thrash_ms|1=$(bgf "$dt_ms" 0)"
  else
    say "clflush_cover build FAILED"
  fi
  # optional: drop page cache again so mem hierarchy settles
  if [[ "${COVER_CACHE_DROP:-1}" == "1" ]]; then
    sudo_run sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches' && say "post-cache drop_caches=3" || true
  fi
}

# bearing catalog · BGF greases EVERY one · no kidding
# order is linear: ground → measure surfaces → free ride
BEARINGS=(
  ground:BGS
  mem:BGF_MEM
  cpu:BGF_CPU
  cache:CPU_CACHE
  power:COOL
  page:PAGE_SLAB
  swap:SWAP
  tmp:TMP_RESIDUE
  orphan:ORPHAN_REAP
  service:DESK_UNIT
  listen:LISTENERS
  free:SPV_FREE
)

cmd_bearing_inventory() {
  say "=== BEARINGS · BGF axle grease catalog · $(date -Iseconds) ==="
  say "NO KIDDING · BGF instantiates ALL of these · (a-b)|1 measure pin"
  local b
  for b in "${BEARINGS[@]}"; do
    say "  grease → ${b%%:*}  (${b#*:})"
  done
  say "limbs: bgf bgf_cover bgf_mem bgf_cpu all_mem cover cool cool_cpu mem_* sdf"
  say "ATOMS on BGF (still linear · not side engines):"
  say "  EZZIE electric  (a^b)|1  · free eor · ESSIE!=EZZIE"
  say "  PHI    scale    (d*s)|1  · mul on measure pin"
  say "  THERMO heat     band|1  · cool/warm/hot thresholds"
}

# sample every bearing surface into named vars via stdout key=val
sample_all_bearings() {
  local tag=$1
  local ma mf mc mb ld mhz tmp ck buf slab pub loc
  ma=$(sample_mem); mf=$(sample_mem_free); mc=$(sample_cached)
  mb=$(sample_buffers); ld=$(sample_load); mhz=$(sample_mhz)
  tmp=$(sample_temp_mc); ck=$(sample_cache_kb)
  buf=$(awk '/^Buffers:/{print $2; exit}' /proc/meminfo)
  slab=$(awk '/^SReclaimable:/{print $2; exit}' /proc/meminfo 2>/dev/null || echo 0)
  slab=${slab:-0}
  pub=$(ss -ltn 2>/dev/null | awk 'NR>1 && $4 !~ /127\.|::1/ {c++} END{print c+0}')
  loc=$(ss -ltn 2>/dev/null | awk 'NR>1 && $4 ~ /127\.|::1/ {c++} END{print c+0}')
  say "[$tag] MEM avail=$ma free=$mf cached=$mc buffers=$mb slab_reclaim=$slab"
  say "[$tag] CPU loadx100=$ld mhz=$mhz temp_mC=$tmp cache_kB=$ck"
  say "[$tag] NET public_listen=$pub local_listen=$loc"
  say "[$tag] BGF mem_free_vs_cache=$(bgf "$mf" "$mc") load_vs_mhz=$(bgf "$ld" "$mhz") free_vs_buffers=$(bgf "$mf" "$mb")"
  say "[$tag] BGF slab_vs_cache=$(bgf "$slab" "$mc") pub_vs_loc=$(bgf "$pub" "$loc")"
  # atoms ride the BGF pin (same linear line · not duo engines)
  local m_fc m_lm tC
  m_fc=$(bgf "$mf" "$mc"); m_lm=$(bgf "$ld" "$mhz")
  tC=$(( tmp / 1000 ))
  say "[$tag] ATOM EZZIE electric=$(ezzie "$m_fc" "$m_lm")  (free eor on BGF · not ESSIE hotswap)"
  say "[$tag] ATOM PHI scale=$(phi "$m_fc" 1)  ((d*s)|1 on BGF)"
  say "[$tag] ATOM THERMO heat=$(thermo "$tC")  temp_C=$tC band|1 on BGF"
  say "[$tag] FREE_SPV=$(spv "$ma" "$ld" "$tmp") field_one avail|1=$(bgs1 "$ma")"
  # print machine line for capture
  echo "$ma $mf $mc $mb $ld $mhz $tmp $ck $slab $pub $loc"
}

grease_bearing() {
  # log one bearing greased with BGF delta language
  local name=$1 before=$2 after=$3
  say "  ⚙ $name  BGF=$(bgf "$after" "$before")  before=$before after=$after"
}

# reinstate BGF ALL · axle grease in every bearing · no kidding
# cooks out stuck page-cache / slab / swap / tmp / orphan / measure mud
cmd_reinstant() {
  say "############################################"
  say "# BGF REINSTANT ALL · AXLE GREASE · NO KIDDING"
  say "# instantiate measure pin on EVERY bearing"
  say "# $(date -Iseconds)"
  say "############################################"
  say "LAW: BGS ground · BGF measure ALL · free SPV rides · never fold · linear"
  say "META: BGF = axle grease in the bearings · not optional lube"

  cmd_bearing_inventory

  # drop prior cover samples so reinstate is honest
  rm -f "$OUT/cover_before.txt" "$OUT/cover_after.txt" \
        "$OUT/bgf_reinstant.json" "$OUT/bgf_all_bearings.json" 2>/dev/null || true
  rm -f "$OUT/clflush_cover" "$OUT/clflush_cover.c" 2>/dev/null || true
  # --- bearing: tmp residue ---
  rm -rf /tmp/grok-orphan-* /tmp/rtx_* /tmp/amouranth* /tmp/never_fold* /tmp/bgf_* 2>/dev/null || true
  say "bearing tmp · residue cooked"

  # --- bearing: orphan (field strays) ---
  if [[ -x /usr/local/bin/grok-orphan-kill ]]; then
    /usr/local/bin/grok-orphan-kill >/dev/null 2>&1 || true
    say "bearing orphan · reaper pass OK"
  elif [[ -x "$ROOT/RTXLayer/bin/grok-orphan-kill.sh" ]]; then
    "$ROOT/RTXLayer/bin/grok-orphan-kill.sh" >/dev/null 2>&1 || true
    say "bearing orphan · reaper pass OK (tree)"
  else
    say "bearing orphan · SKIP (no reaper)"
  fi

  # --- baseline ALL bearings ---
  say "=== BASELINE · grease measure before cook ==="
  local before_line
  before_line=$(sample_all_bearings BASELINE | tail -1)
  # shellcheck disable=SC2086
  set -- $before_line
  local b_a=$1 b_f=$2 b_c=$3 b_b=$4 b_ld=$5 b_mhz=$6 b_tmp=$7 b_ck=$8 b_slab=$9 b_pub=${10} b_loc=${11}
  echo "$before_line" >"$OUT/cover_before.txt"
  local fo_a fo_f
  fo_a=$(bgs1 "$b_a"); fo_f=$(bgs1 "$b_f")
  say "field_one thrift MemAvail|1=$fo_a MemFree|1=$fo_f  (odd live · BGS pin)"

  # --- bearing: power/cool ---
  cmd_power

  # --- bearing: page/slab/swap (cleanup) ---
  cmd_cleanup
  sync
  if sudo_run sh -c 'echo 3 > /proc/sys/vm/drop_caches'; then
    say "bearing page · second drop_caches=3 OK"
  fi

  # --- bearing: CPU cache thrash ---
  cmd_cache

  # --- bearing: service units (status only · grease measure) ---
  local dc_a ok_a ri_a
  dc_a=$(systemctl is-active bgrtx-datacenter.service 2>/dev/null || echo dead)
  ok_a=$(systemctl is-active grok-orphan-kill.timer 2>/dev/null || echo dead)
  ri_a=$(systemctl is-active bgf-reinstant.timer 2>/dev/null || echo dead)
  say "bearing service · datacenter=$dc_a orphan_timer=$ok_a reinstant_timer=$ri_a"
  # numeric for BGF: active=1 inactive=0
  local b_dc=0 b_ok=0 b_ri=0 a_dc=0 a_ok=0 a_ri=0
  [[ "$dc_a" == active ]] && b_dc=1
  [[ "$ok_a" == active ]] && b_ok=1
  [[ "$ri_a" == active ]] && b_ri=1

  # --- AFTER · remeasure ALL ---
  say "=== AFTER · grease measure after cook ==="
  local after_line
  after_line=$(sample_all_bearings AFTER | tail -1)
  set -- $after_line
  local a_a=$1 a_f=$2 a_c=$3 a_b=$4 a_ld=$5 a_mhz=$6 a_tmp=$7 a_ck=$8 a_slab=$9 a_pub=${10} a_loc=${11}
  echo "$after_line" >"$OUT/cover_after.txt"
  dc_a=$(systemctl is-active bgrtx-datacenter.service 2>/dev/null || echo dead)
  ok_a=$(systemctl is-active grok-orphan-kill.timer 2>/dev/null || echo dead)
  ri_a=$(systemctl is-active bgf-reinstant.timer 2>/dev/null || echo dead)
  [[ "$dc_a" == active ]] && a_dc=1
  [[ "$ok_a" == active ]] && a_ok=1
  [[ "$ri_a" == active ]] && a_ri=1

  say "=== BGF Δ ON EVERY BEARING · axle grease proof ==="
  grease_bearing "ground/BGS(field_one)" "$fo_a" "$(bgs1 "$a_a")"
  grease_bearing "mem/avail"      "$b_a"    "$a_a"
  grease_bearing "mem/free"       "$b_f"    "$a_f"
  grease_bearing "mem/cached"     "$b_c"    "$a_c"
  grease_bearing "mem/buffers"    "$b_b"    "$a_b"
  grease_bearing "mem/slab"       "$b_slab" "$a_slab"
  grease_bearing "cpu/load"       "$b_ld"   "$a_ld"
  grease_bearing "cpu/mhz"        "$b_mhz"  "$a_mhz"
  grease_bearing "cpu/temp_mC"    "$b_tmp"  "$a_tmp"
  grease_bearing "cache/sysfs_kB" "$b_ck"   "$a_ck"
  grease_bearing "listen/public"  "$b_pub"  "$a_pub"
  grease_bearing "listen/local"   "$b_loc"  "$a_loc"
  grease_bearing "service/dc"     "$b_dc"   "$a_dc"
  grease_bearing "service/orphan" "$b_ok"   "$a_ok"
  grease_bearing "service/reinstant" "$b_ri" "$a_ri"
  say "  ⚙ free/SPV  free_spv=$(spv "$a_a" "$a_f" "$a_ld")  (rides measure · never folds)"
  say "heur_avail_near=$(heur_near "$a_a" "$b_a" 2048)  (1=<2MiB avail drift)"

  # --- atoms on BGF after cook (axle grease with EZZIE PHI THERMO) ---
  local m_fc m_lm tC_a tC_b
  m_fc=$(bgf "$a_f" "$a_c"); m_lm=$(bgf "$a_ld" "$a_mhz")
  tC_a=$(( a_tmp / 1000 )); tC_b=$(( b_tmp / 1000 ))
  local at_ez at_phi at_th
  at_ez=$(ezzie "$m_fc" "$m_lm")
  at_phi=$(phi "$m_fc" 1)
  at_th=$(thermo "$tC_a")
  say "=== ATOMS ON BGF · EZZIE · PHI · THERMO ==="
  say "  EZZIE electric=$(ezzie "$(bgf "$b_f" "$b_c")" "$(bgf "$b_ld" "$b_mhz")") → $at_ez  (free eor)"
  say "  PHI    scale=$(phi "$(bgf "$b_f" "$b_c")" 1) → $at_phi  ((d*s)|1)"
  say "  THERMO heat=$(thermo "$tC_b") → $at_th  (temp_C $tC_b → $tC_a · band|1)"
  say "  BGF Δ thermo_band=$(bgf "$at_th" "$(thermo "$tC_b")")"

  local free_spv bgf_mem bgf_cpu bgf_all
  free_spv=$(spv "$a_a" "$a_f" "$a_ld")
  bgf_mem=$(bgf "$a_f" "$b_f")
  bgf_cpu=$(bgf "$a_ld" "$b_ld")
  # master grease mark · xor mix of primary deltas |1 · free channel not field
  bgf_all=$(spv "$(bgf "$a_a" "$b_a")" "$(bgf "$a_f" "$b_f")" "$(bgf "$a_c" "$b_c")")

  cat >"$OUT/bgf_reinstant.json" <<JSON
{
  "law": "BGS ground · BGF measure ALL bearings · free rides · never fold · linear",
  "meta": "axle grease in the bearings · instantiate ALL · no kidding",
  "bearings": ["ground","mem","cpu","cache","power","page","swap","tmp","orphan","service","listen","free"],
  "before": {
    "mem_avail_kb": $b_a, "mem_free_kb": $b_f, "cached_kb": $b_c, "buffers_kb": $b_b,
    "slab_kb": $b_slab, "loadx100": $b_ld, "mhz": $b_mhz, "temp_mC": $b_tmp,
    "cache_kB": $b_ck, "listen_public": $b_pub, "listen_local": $b_loc,
    "svc_datacenter": $b_dc, "svc_orphan": $b_ok, "svc_reinstant": $b_ri
  },
  "after": {
    "mem_avail_kb": $a_a, "mem_free_kb": $a_f, "cached_kb": $a_c, "buffers_kb": $a_b,
    "slab_kb": $a_slab, "loadx100": $a_ld, "mhz": $a_mhz, "temp_mC": $a_tmp,
    "cache_kB": $a_ck, "listen_public": $a_pub, "listen_local": $a_loc,
    "svc_datacenter": $a_dc, "svc_orphan": $a_ok, "svc_reinstant": $a_ri
  },
  "bgf": {
    "mem_avail": $(bgf "$a_a" "$b_a"),
    "mem_free": $(bgf "$a_f" "$b_f"),
    "cached": $(bgf "$a_c" "$b_c"),
    "buffers": $(bgf "$a_b" "$b_b"),
    "slab": $(bgf "$a_slab" "$b_slab"),
    "load": $(bgf "$a_ld" "$b_ld"),
    "mhz": $(bgf "$a_mhz" "$b_mhz"),
    "temp_mC": $(bgf "$a_tmp" "$b_tmp"),
    "cache_kB": $(bgf "$a_ck" "$b_ck"),
    "listen_public": $(bgf "$a_pub" "$b_pub"),
    "listen_local": $(bgf "$a_loc" "$b_loc"),
    "svc_datacenter": $(bgf "$a_dc" "$b_dc"),
    "svc_orphan": $(bgf "$a_ok" "$b_ok"),
    "svc_reinstant": $(bgf "$a_ri" "$b_ri"),
    "all_grease": $bgf_all
  },
  "atoms_on_bgf": {
    "EZZIE": {"law": "(a^b)|1 free eor electric", "value": $at_ez},
    "PHI":   {"law": "(d*s)|1 scale", "value": $at_phi},
    "THERMO":{"law": "band|1 heat cool<=70 warm<=84 hot", "value": $at_th, "temp_C": $tC_a}
  },
  "free_spv": $free_spv,
  "field_one": {"mem_avail": $fo_a, "mem_free": $fo_f},
  "no_kidding": true,
  "log": "$LOG"
}
JSON
  cp -f "$OUT/bgf_reinstant.json" "$OUT/bgf_all_bearings.json"
  say "wrote $OUT/bgf_reinstant.json"
  say "wrote $OUT/bgf_all_bearings.json"
  say "BGF ALL GREASE mark all_grease=$bgf_all free_spv=$free_spv"
  say "BGF REINSTANT ALL DONE · every bearing greased · remain IN · NO KIDDING"
}

cmd_everything() {
  say "############################################"
  say "# COVER EVERYTHING · BGF axle grease ALL bearings"
  say "# $LOG"
  say "############################################"
  cmd_reinstant
  say "PATH limbs greased: cover bgf_cover bgf bgf_mem bgf_cpu all_mem cool cool_cpu mem_*"
  say "ATOMS on BGF: EZZIE electric · ESSIE seats · PHI · THERMO · business linear"
  say "DONE · remain IN · ALL MEM is BGF · free SPV never folds · NO KIDDING"
  echo "$LOG"
}

cmd_atoms() {
  # prove EZZIE · ESSIE · PHI · THERMO live on BGF · business free thrift
  local a b t m
  a=$(sample_mem_free); b=$(sample_cached); t=$(( $(sample_temp_mc) / 1000 ))
  m=$(bgf "$a" "$b")
  say "=== ATOMS ON BGF · EZZIE · ESSIE · PHI · THERMO · $(date -Iseconds) ==="
  say "LAW: business · linear · ride measure · not side engines · not SDF · free thrift"
  say "BGF(free,cached)=$m  free=$a cached=$b  temp_C=$t"
  say "EZZIE electric=$(ezzie "$a" "$b")  (a^b)|1  limb=ezzie/  · ≠ ESSIE"
  say "ESSIE seats=$(essie "$a" "$b")  quiet→1 else |1  limb=essie/  · ≠ EZZIE"
  say "PHI    scale=$(phi "$m" 1)  (d*s)|1  limb=phi/"
  say "THERMO heat=$(thermo "$t")  band|1  cool≤70 warm≤84 hot  limb=thermo/"
  say "chain: measure → atoms ride grease → free SPV never folds"
  say "remain IN · BigGrinRTX business"
}

cmd_bgs() {
  say "=== BGS GROUND · $(date -Iseconds) ==="
  say "limb=bgs/x86_64.asm · field_one(v)=v|1 · know_her=7|1"
  say "BGS know_her(edi=0)=$(bgs 0)  BGS field_one(edi=1)=$(bgs 1)  field_one(42)=$(bgs 42)"
  say "TX pin (BGS field_one class)=$(tx_pin 1)  RX pin=$(rx_pin 1)  limbs=tx/ rx/ tx_rx/"
  say "ground only · not measure · Hostess 7 top knows this pin"
}

cmd_tx_rx() {
  say "=== TX / RX · BGS field · net measure rides BGF · $(date -Iseconds) ==="
  local ifc rxb txb rxp txp
  ifc=$(sample_net_iface)
  rxb=$(sample_rx_bytes); txb=$(sample_tx_bytes)
  rxp=$(sample_rx_packets); txp=$(sample_tx_packets)
  say "iface=$ifc"
  say "RX bytes=$rxb packets=$rxp  pin=$(rx_pin "$rxp")"
  say "TX bytes=$txb packets=$txp  pin=$(tx_pin "$txp")"
  say "BGF tx_vs_rx_bytes=$(bgf "$txb" "$rxb")  tx_vs_rx_pkts=$(bgf "$txp" "$rxp")"
  say "EZZIE on wire=$(ezzie "$txb" "$rxb")  (free eor · not field rewrite)"
  say "FREE_SPV wire=$(spv "$txb" "$rxb" "$txp")"
  # export for full system JSON
  echo "$ifc $rxb $txb $rxp $txp"
}

cmd_services_pulse() {
  say "=== SERVICES · desk units · $(date -Iseconds) ==="
  local u
  for u in bgrtx-datacenter.service grok-orphan-kill.timer bgf-reinstant.timer bgs-bgf-full.timer; do
    say "  $u  active=$(systemctl is-active "$u" 2>/dev/null || echo n/a)  enabled=$(systemctl is-enabled "$u" 2>/dev/null || echo n/a)"
  done
  local code
  code=$(curl -sS -o /dev/null -w '%{http_code}' --connect-timeout 1 http://127.0.0.1:8766/ 2>/dev/null || echo fail)
  say "  datacenter HTTP $code  (127 only · no xdg)"
}

cmd_peel_brief() {
  say "=== PEEL · BGS+BGF roots · $(date -Iseconds) ==="
  if [[ -x "$ROOT/Build/x" ]]; then
    # peel is loud · capture summary lines only
    "$ROOT/Build/x" peel 2>/dev/null | tee -a "$LOG" | grep -E '^(BGS_|BGF:|PATH total|===|native)' || true
  else
    say "Build/x missing · skip peel"
  fi
}

# FULL SYSTEM · BGS + BGF + atoms + TX/RX + services + reinstant ALL · repeat-ready
cmd_full_system() {
  say "############################################"
  say "# FULL SYSTEM · BGS + BGF · TX/RX · ALL OF IT"
  say "# linear: BGS → BGF(+EZZIE PHI THERMO) → SDF · SPV free"
  say "# $(date -Iseconds) · $LOG"
  say "############################################"

  # 1 ground
  cmd_bgs

  # 2 peel roots
  cmd_peel_brief

  # 3 TX/RX before cook
  say "--- TX/RX BEFORE ---"
  local before_wire after_wire
  before_wire=$(cmd_tx_rx | tail -1)
  # shellcheck disable=SC2086
  set -- $before_wire
  local b_ifc=$1 b_rxb=$2 b_txb=$3 b_rxp=$4 b_txp=$5

  # 4 services pulse
  cmd_services_pulse

  # 5 atoms snapshot
  cmd_atoms

  # 6 full BGF reinstant ALL bearings (grease everything)
  cmd_reinstant

  # 7 TX/RX after cook
  say "--- TX/RX AFTER ---"
  after_wire=$(cmd_tx_rx | tail -1)
  set -- $after_wire
  local a_ifc=$1 a_rxb=$2 a_txb=$3 a_rxp=$4 a_txp=$5

  say "=== FULL SYSTEM BGF Δ · wire + ground ==="
  grease_bearing "tx/bytes" "$b_txb" "$a_txb"
  grease_bearing "rx/bytes" "$b_rxb" "$a_rxb"
  grease_bearing "tx/packets" "$b_txp" "$a_txp"
  grease_bearing "rx/packets" "$b_rxp" "$a_rxp"
  say "  BGS know_her=$(bgs 0) field_one=$(bgs 1)  still ground"
  say "  TX pin=$(tx_pin 1) RX pin=$(rx_pin 1)  BGS class"

  # merge full report
  local free_wire
  free_wire=$(spv "$a_txb" "$a_rxb" "$a_txp")
  cat >"$OUT/bgs_bgf_full.json" <<JSON
{
  "law": "BGS ground · BGF measure ALL · EZZIE PHI THERMO on BGF · TX/RX BGS field · SPV free · never fold",
  "meta": "full system cook · axle grease · no kidding · repeat service",
  "bgs": {"know_her": $(bgs 0), "field_one": $(bgs 1), "tx_pin": $(tx_pin 1), "rx_pin": $(rx_pin 1)},
  "wire": {
    "iface": "$a_ifc",
    "before": {"rx_bytes": $b_rxb, "tx_bytes": $b_txb, "rx_packets": $b_rxp, "tx_packets": $b_txp},
    "after":  {"rx_bytes": $a_rxb, "tx_bytes": $a_txb, "rx_packets": $a_rxp, "tx_packets": $a_txp},
    "bgf": {
      "tx_bytes": $(bgf "$a_txb" "$b_txb"),
      "rx_bytes": $(bgf "$a_rxb" "$b_rxb"),
      "tx_packets": $(bgf "$a_txp" "$b_txp"),
      "rx_packets": $(bgf "$a_rxp" "$b_rxp"),
      "tx_vs_rx": $(bgf "$a_txb" "$a_rxb")
    },
    "ezzie_wire": $(ezzie "$a_txb" "$a_rxb"),
    "free_spv_wire": $free_wire
  },
  "bgf_reinstant": "out/bgf_reinstant.json",
  "atoms": "see bgf_reinstant.json atoms_on_bgf",
  "log": "$LOG",
  "no_kidding": true
}
JSON
  say "wrote $OUT/bgs_bgf_full.json"
  say "FULL SYSTEM DONE · BGS+BGF+TX/RX+atoms+services+grease · remain IN"
  echo "$LOG"
}

# rewrite every live out file every cycle · ZERO FLAT FILES
cmd_write_live_files() {
  local n=${1:-0} mode=${2:-pulse}
  local ma mf mc ld mhz tmp ifc rxb txb rxp txp tC m
  ma=$(sample_mem); mf=$(sample_mem_free); mc=$(sample_cached)
  ld=$(sample_load); mhz=$(sample_mhz); tmp=$(sample_temp_mc)
  ifc=$(sample_net_iface)
  rxb=$(sample_rx_bytes); txb=$(sample_tx_bytes)
  rxp=$(sample_rx_packets); txp=$(sample_tx_packets)
  tC=$(( tmp / 1000 ))
  m=$(bgf "$mf" "$mc")
  local at_ez at_phi at_th free_spv free_wire
  at_ez=$(ezzie "$mf" "$mc")
  at_phi=$(phi "$m" 1)
  at_th=$(thermo "$tC")
  free_spv=$(spv "$ma" "$ld" "$tmp")
  free_wire=$(spv "$txb" "$rxb" "$txp")
  local ts
  ts=$(date -Iseconds)

  # always-moving machine lines
  echo "$ma $mf $mc $ld $mhz $tmp" >"$OUT/cover_before.txt"
  echo "$ma $mf $mc $ld $mhz $tmp" >"$OUT/cover_after.txt"
  echo "$ts cycle=$n mode=$mode BGS=$(bgs 0)/$(bgs 1) BGF=$m EZZIE=$at_ez PHI=$at_phi THERMO=$at_th TX=$txb RX=$rxb free=$free_spv" \
    >"$OUT/bgf_cook_latest.txt"
  echo "$ts ALWAYS COOKING · zero flat · cycle=$n · mode=$mode" >"$OUT/ALWAYS_COOKING"
  # peel stamp stays hot even without full peel
  {
    echo "; PEEL LIVE · $ts · cycle=$n"
    echo "; BGS know_her=$(bgs 0) field_one=$(bgs 1) · BGF measure · atoms EZZIE PHI THERMO"
    echo "; TX=$txb RX=$rxb iface=$ifc · free_spv=$free_spv"
    echo "PATH: always cook · zero flat"
  } >"$OUT/peel.asm"

  cat >"$OUT/always_live.json" <<JSON
{
  "always_cooking": true,
  "zero_flat": true,
  "cycle": $n,
  "mode": "$mode",
  "ts": "$ts",
  "bgs": {"know_her": $(bgs 0), "field_one": $(bgs 1), "tx_pin": $(tx_pin 1), "rx_pin": $(rx_pin 1)},
  "bgf": {
    "mem_free_vs_cache": $m,
    "load_vs_mhz": $(bgf "$ld" "$mhz"),
    "mem_avail_kb": $ma,
    "mem_free_kb": $mf,
    "cached_kb": $mc,
    "loadx100": $ld,
    "mhz": $mhz,
    "temp_mC": $tmp
  },
  "atoms_on_bgf": {
    "EZZIE": $at_ez,
    "PHI": $at_phi,
    "THERMO": $at_th,
    "temp_C": $tC
  },
  "wire": {
    "iface": "$ifc",
    "rx_bytes": $rxb,
    "tx_bytes": $txb,
    "rx_packets": $rxp,
    "tx_packets": $txp,
    "bgf_tx_vs_rx": $(bgf "$txb" "$rxb"),
    "ezzie_wire": $(ezzie "$txb" "$rxb"),
    "free_spv_wire": $free_wire
  },
  "free_spv": $free_spv,
  "law": "BGS → BGF(+EZZIE PHI THERMO) → SDF · SPV free · always cook · zero flat"
}
JSON

  # keep full/reinstant names hot too (no flat mtime)
  cp -f "$OUT/always_live.json" "$OUT/bgs_bgf_full.json"
  # merge-ish reinstant stub if heavy cook not this cycle
  if [[ "$mode" != full && "$mode" != reinstant ]]; then
    cat >"$OUT/bgf_reinstant.json" <<JSON
{
  "law": "BGS ground · BGF measure ALL bearings · free rides · never fold · linear",
  "meta": "always cook pulse · zero flat · full reinstant on schedule",
  "always_cooking": true,
  "cycle": $n,
  "ts": "$ts",
  "bgf": {
    "mem_free_vs_cache": $m,
    "load_vs_mhz": $(bgf "$ld" "$mhz"),
    "all_grease": $(spv "$m" "$(bgf "$ld" "$mhz")" "$at_ez")
  },
  "atoms_on_bgf": {
    "EZZIE": {"law": "(a^b)|1 free eor electric", "value": $at_ez},
    "PHI":   {"law": "(d*s)|1 scale", "value": $at_phi},
    "THERMO":{"law": "band|1 heat", "value": $at_th, "temp_C": $tC}
  },
  "free_spv": $free_spv,
  "no_kidding": true,
  "source": "always_live pulse"
}
JSON
    cp -f "$OUT/bgf_reinstant.json" "$OUT/bgf_all_bearings.json"
  fi

  # touch companion files so nothing sits flat in out/
  touch "$OUT/ALWAYS_COOKING" "$OUT/always_live.json" "$OUT/bgs_bgf_full.json" \
        "$OUT/bgf_reinstant.json" "$OUT/bgf_all_bearings.json" \
        "$OUT/bgf_cook_latest.txt" "$OUT/cover_before.txt" "$OUT/cover_after.txt" \
        "$OUT/peel.asm" 2>/dev/null || true
  # rotating pulse log (bounded)
  {
    echo "[$ts] cycle=$n mode=$mode BGF=$m EZZIE=$at_ez PHI=$at_phi THERMO=$at_th free=$free_spv tx=$txb rx=$rxb"
  } >>"$OUT/always_cook.log"
  # keep log under ~500 lines
  if [[ -f "$OUT/always_cook.log" ]]; then
    local lines
    lines=$(wc -l <"$OUT/always_cook.log" 2>/dev/null || echo 0)
    if (( lines > 600 )); then
      tail -n 400 "$OUT/always_cook.log" >"$OUT/always_cook.log.tmp" && mv "$OUT/always_cook.log.tmp" "$OUT/always_cook.log"
    fi
  fi
}

# one light cycle · CLEAN CACHE every time · no holes · files stay clean
cmd_pulse() {
  local n=${1:-0}
  say "=== PULSE · insta clean · no cache · cycle=$n · $(date -Iseconds) ==="
  # 1 files unclean out
  cmd_clean_files
  # 2 CACHE OUT always · drop twice · no hole
  cmd_drop_cache || true
  # 3 ground + measure after clean
  say "BGS know_her=$(bgs 0) field_one=$(bgs 1) TX=$(tx_pin 1) RX=$(rx_pin 1)"
  local ma mf mc ld mhz tmp
  ma=$(sample_mem); mf=$(sample_mem_free); mc=$(sample_cached)
  ld=$(sample_load); mhz=$(sample_mhz); tmp=$(sample_temp_mc)
  say "BGF free_vs_cache=$(bgf "$mf" "$mc") load_vs_mhz=$(bgf "$ld" "$mhz") free_spv=$(spv "$ma" "$ld" "$tmp")"
  say "CACHED_kB=$mc (post-drop · should stay thin)"
  local ifc rxb txb
  ifc=$(sample_net_iface); rxb=$(sample_rx_bytes); txb=$(sample_tx_bytes)
  say "TX/RX iface=$ifc tx=$txb rx=$rxb BGF=$(bgf "$txb" "$rxb") EZZIE=$(ezzie "$txb" "$rxb")"
  local tC m
  tC=$(( tmp / 1000 )); m=$(bgf "$mf" "$mc")
  say "ATOMS EZZIE=$(ezzie "$mf" "$mc") PHI=$(phi "$m" 1) THERMO=$(thermo "$tC") temp_C=$tC"
  # 4 rewrite live files · zero flat · clean truth only
  cmd_write_live_files "$n" pulse
  # 5 cache again after write · stay clean
  cmd_drop_cache || true
  # 6 light orphan
  say "PULSE CLEAN · cache dropped · files clean · no holes · remain IN"
}

# ALWAYS COOK · forever · cache always cleaned · no unclean files · no holes
cmd_always() {
  local cycle=0
  # short settle only · default 3s · full clean often
  local sleep_s="${COVER_ALWAYS_SLEEP:-3}"
  local full_every="${COVER_FULL_EVERY:-5}"
  say "############################################"
  say "# ALWAYS COOK · INSTA STAY CLEAN · FOREVER"
  say "# NO CACHE left · NO unclean files · NO holes"
  say "# sleep=${sleep_s}s · full reinstant every ${full_every} cycles"
  say "# $(date -Iseconds)"
  say "############################################"
  trap 'say "ALWAYS COOK stop · cycle=$cycle · last drop"; cmd_drop_cache || true; exit 0' TERM INT

  # boot clean hard
  cmd_cleanup || true

  while true; do
    cycle=$((cycle + 1))
    if (( cycle == 1 || cycle % full_every == 0 )); then
      say "--- FULL CLEAN cycle=$cycle ---"
      cmd_cleanup || true
      cmd_full_system || say "full_system WARN cycle=$cycle"
      cmd_write_live_files "$cycle" full
      cmd_drop_cache || true
      cmd_clean_files
    else
      cmd_pulse "$cycle" || say "pulse WARN cycle=$cycle"
    fi
    # stamp still clean for world+us
    echo "CLEAN $(date -Iseconds) cycle=$cycle cached_kB=$(sample_cached)" >"$OUT/STAY_CLEAN"
    # tiny settle only · zero holes · never long flat
    sleep "$sleep_s" &
    wait $! || true
  done
}

cmd_help() {
  cat <<EOF
Desktop/x/Build/cover.sh · ALWAYS COOK · zero flat files · BGS+BGF

  ./Build/cover.sh always      FOREVER · drop_caches every pulse · no unclean files
  ./Build/cover.sh pulse       one insta-clean cycle · cache out · files clean
  ./Build/cover.sh cleanup     files + drop_caches×2 + compact + orphan
  ./Build/cover.sh full        FULL SYSTEM one-shot (inside always)
  ./Build/cover.sh measure     BGF samples only
  ./Build/cover.sh power       governor/temp · COVER_POWERSAVE=1 optional
  ./Build/cover.sh cache       clflush thrash then drop_caches
  ./Build/cover.sh reinstant   BGF ALL bearings grease
  ./Build/cover.sh bgs|tx-rx|atoms|bearings
  ./Build/x always | full | pulse

Law: BGS → BGF(+EZZIE PHI THERMO) → SDF · SPV free · never fold
     ALWAYS COOK · NO CACHE left · NO unclean files · NO holes · stay clean
Service: bgs-bgf-always.service  Restart=always

env:
  SUDO_PASS=mememe
  COVER_ALWAYS_SLEEP=3      settle between pulses (keep small)
  COVER_FULL_EVERY=5        full reinstant frequency
  COVER_CACHE_MB=128
  COVER_CACHE_DROP=1
EOF
}

c="${1:-always}"
case "$c" in
  help|-h|--help) cmd_help ;;
  measure|m) cmd_measure ;;
  cleanup|clean|c) cmd_cleanup ;;
  power|p) cmd_power ;;
  cache|cpu-cache|k) cmd_cache ;;
  bearings|bearing|grease-list) cmd_bearing_inventory ;;
  atoms|ezzie|phi|thermo|e-p-t) cmd_atoms ;;
  bgs|ground) cmd_bgs ;;
  tx-rx|txrx|tx|rx|wire) cmd_tx_rx ;;
  services|svc) cmd_services_pulse ;;
  pulse|tick|live) cmd_pulse 0 ;;
  always|forever|zero-flat|cook-always) cmd_always ;;
  reinstant|reinstate|reinst|r|bgf-all|all-bearings) cmd_reinstant ;;
  full|full-system|system|all-of-it|bgf-bgs|bgs-bgf) cmd_full_system ;;
  all|everything|cover) cmd_everything ;;
  *) cmd_help; exit 2 ;;
esac
