Initial commit: apkovl deployment source, synced from shell-project main

This directory is what gets packaged into localhost.apkovl.tar.gz and
baked into adaptiveos-vN.iso. It had drifted out of sync with the real
project (root/shell-project/ had gone missing entirely at some point
after being written earlier this session -- cause unconfirmed, Desktop
is a plausible sync-related suspect but not verified) and separately
carried a stale, pre-fix copy of fx.sh.

Current contents:
  etc/profile.d/adaptive-loop.sh   -- disk-persists p AND p.trace
                                       (fx()'s fix-provenance record)
                                       across reboot, two separate 1MB
                                       blocks on the attached state disk
  etc/profile.d/adaptive-setup.sh  -- unchanged, network/git/fzf bring-up
  root/shell-project/              -- synced from space.seodr.ovh/
                                       Daveswo/self-healing-autopoietic-
                                       shell @ 3c4947e (main), plus three
                                       deployment-only files not in that
                                       repo: contrib/fx/builtin-fixes.txt,
                                       contrib/fx/sources.d/15-builtin-
                                       fixes.sh, contrib/heal/heal.sh

Verified byte-identical to what's actually embedded in the currently
shipping adaptiveos-v6.iso before this commit (full recursive diff),
and every .sh file passes `sh -n`.

.gitattributes (text=auto eol=lf) added to prevent the CRLF corruption
that hit the canonical repo earlier this session from recurring here.
This commit is contained in:
2026-08-22 02:55:40 -04:00
commit 77856f0a09
16 changed files with 705 additions and 0 deletions
@@ -0,0 +1,57 @@
#!/bin/sh
# PATH-fuzzy source: if the first word isn't a known command, alias, or
# function, offer a function wrapping the closest-spelled real command
# as a candidate -- as a fix you approve through the normal f() flow,
# not a silently auto-installed hook. A function, not an alias: aliases
# only expand in interactive shells (need `shopt -s expand_aliases`
# otherwise), so an alias-based fix silently does nothing when f/fx run
# inside a script.
#
# Pure POSIX: walks $PATH directly instead of `compgen -c`, which is a
# bash-only builtin and does not exist under busybox ash -- this source
# used to be dead weight on exactly the minimal/embedded shells this
# project targets. Tested against busybox ash + busybox awk directly,
# not just bash + gawk.
#
# Uses Damerau-Levenshtein-lite (edit distance + adjacent transposition)
# so the canonical "gti" -> "git" typo scores 1, not 2 -- plain Hamming
# or substitution-only distance ties it with unrelated 3-letter commands
# like "ftp" and can pick the wrong one.
cmd="$1"
first_word=$(printf '%s' "$cmd" | awk '{print $1}')
[ -n "$first_word" ] || exit 0
command -v "$first_word" >/dev/null 2>&1 && exit 0
IFS=:
for d in $PATH; do
ls "$d" 2>/dev/null
done | sort -u | awk -v target="$first_word" '
function min3(a, b, c) { return (a < b ? (a < c ? a : c) : (b < c ? b : c)) }
function distance(a, b, n, m, i, j, ca, cb, cost, tmp) {
n = length(a); m = length(b)
if (n == 0) return m
if (m == 0) return n
for (j = 0; j <= m; j++) d[0, j] = j
for (i = 1; i <= n; i++) {
d[i, 0] = i
ca = substr(a, i, 1)
for (j = 1; j <= m; j++) {
cb = substr(b, j, 1)
cost = (ca == cb) ? 0 : 1
tmp = min3(d[i-1, j] + 1, d[i, j-1] + 1, d[i-1, j-1] + cost)
if (i > 1 && j > 1 && ca == substr(b, j-1, 1) && substr(a, i-1, 1) == cb) {
tmp = (tmp < d[i-2, j-2] + 1) ? tmp : d[i-2, j-2] + 1
}
d[i, j] = tmp
}
}
return d[n, m]
}
{
lendiff = length($0) - length(target)
if (lendiff > 2 || lendiff < -2) next
dd = distance(target, $0)
if (dd <= 2 && dd > 0 && (best == "" || dd < bestd)) { best = $0; bestd = dd }
}
END { if (best != "") print target "(){ command " best " \"$@\"; }" }
'