26 lines
846 B
Bash
26 lines
846 B
Bash
|
|
#!/bin/sh
|
||
|
|
# heal(): thin observability wrapper around fx(). fx()/f() (see
|
||
|
|
# ../fx/fx.sh, ../../src/f.sh) already do the actual healing across every
|
||
|
|
# tier plus the manual "[LEARN] ... Enter a fix" fallback -- this adds
|
||
|
|
# nothing to that logic. It only appends one structured line when every
|
||
|
|
# tier AND the manual prompt come up empty, so an external caller or
|
||
|
|
# orchestrator has something to grep for instead of only a bare nonzero
|
||
|
|
# exit code.
|
||
|
|
#
|
||
|
|
# Usage:
|
||
|
|
# . src/f.sh
|
||
|
|
# . contrib/fx/fx.sh
|
||
|
|
# . contrib/heal/heal.sh
|
||
|
|
# heal some-command-that-might-fail --with args
|
||
|
|
HEAL_LOG="${HEAL_LOG:-/var/log/glyphos-heal.log}"
|
||
|
|
|
||
|
|
heal() {
|
||
|
|
if fx "$@"; then
|
||
|
|
return 0
|
||
|
|
fi
|
||
|
|
ec=$?
|
||
|
|
ts=$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo unknown-time)
|
||
|
|
printf '%s MISS cmd="%s"\n' "$ts" "$*" >> "$HEAL_LOG" 2>/dev/null
|
||
|
|
return "$ec"
|
||
|
|
}
|