fix: stabilization pass — fail-closed auth, ai flag validation, lint/config/security hardening, regression tests
gates / consistency-and-conventions (push) Successful in 26s

17-point code-level audit executed via Explorer->Architect->Builder->Tester->Reviewer;
Reviewer accepted (APPROVE_WITH_NOTES; 3 block-list items resolved):

- security: telegram sender-owner AND-gate + TELEGRAM_OWNER_ID, matrix
  MATRIX_ROOM_ID fail-closed, gpg --passphrase-fd 3 (no argv secret),
  /dev/tcp positional-arg form (checkport/smb-client/share-lib/NET_PROBE),
  eval deny-by-default + --no-command-execution carried by both chat bridges,
  tty-gated --trust; config/{telegram,matrix}.env reference templates
- ai: all ExecStart flags validated against installed llama.cpp
  (requested->error, default->omit+warn, CONFIG_REQUESTED_FLAGS); single-file
  hf download failure rc=1 + no .hf-meta; LLAMACPP_HOST coherent;
  POS_SUBCMDS + metadata gaps closed
- tooling: lint-conventions Bash-native rewrite (~24-30x faster, rules and
  output byte-identical, :num restored); pos system uninstall covers all 12
  libs + scale-tail + flags dir + systemd user units (|| true) + plugin
  markers; anchored .bash_completion/.bashrc removal replaces sed -i '/pos/d'
- config: canonical load_env_file in lib/config-ui.sh (CRLF strip, env-wins,
  XDG, LOADED_ENV_KEYS); 9 tools migrated; entertainment-lib collapsed to
  wrappers; docker-compose deliberately unmigrated (source semantics)
- tests: first committed regression suite — tests/run-tests.sh zero-dep
  runner + make test; 12 files / 179 checks / 0 skip / ~52s; hard skip
  contract; systemd-analyze verify on generated unit PASS

Verified: make gen idempotent; make check green; make lint 0 FAIL, 0 WARN;
make test green; bash -n clean; git diff --check clean. Audit deliverables +
agent reports + AGENT_TODO Done entry included.
This commit is contained in:
Your Name
2026-09-06 07:25:44 -04:00
parent 528b16676e
commit d817c37652
69 changed files with 5161 additions and 406 deletions
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/../../lib/common.sh"
# llama.cpp — Local LLM inference server (llama-server) + CLI tools.
#
# Asset-naming note (probed live 2026-09-06): the vX.Y.Z milestone
# releases carry NO binary assets (only nightly-tag.txt); the prebuilt
# Ubuntu binaries ship on the nightly bNNNNN releases as
# llama-<tag>-bin-ubuntu-x64.tar.gz / llama-<tag>-bin-ubuntu-arm64.tar.gz
# so we scan the newest releases for the first one that ships our arch
# instead of hitting /releases/latest.
RELEASES_URL="https://api.github.com/repos/ggml-org/llama.cpp/releases?per_page=10"
install_llamacpp() {
command -v llama-server &>/dev/null && { log "llama.cpp already installed"; return 0; }
local arch
case "$(uname -m)" in
x86_64) arch="x64" ;;
aarch64) arch="arm64" ;;
*) err "Unsupported architecture: $(uname -m) (llama.cpp publishes x64/arm64 Ubuntu builds)" ;;
esac
spawn "Fetching latest llama.cpp release info" bash -c "
curl -fsSL '$RELEASES_URL' -o /tmp/llamacpp-releases.json
"
local tag asset_url
if ! { read -r tag && read -r asset_url; } < <(python3 -c "
import json, sys
rels = json.load(open('/tmp/llamacpp-releases.json'))
suffix = '-bin-ubuntu-$arch.tar.gz'
for r in rels:
for a in r['assets']:
if a['name'].endswith(suffix):
print(r['tag_name'])
print(a['browser_download_url'])
sys.exit(0)
sys.exit(1)
" 2>/dev/null); then
rm -f /tmp/llamacpp-releases.json
err "No llama.cpp Ubuntu $arch binary release found — see https://github.com/ggml-org/llama.cpp/releases"
fi
spawn "Installing llama.cpp $tag ($arch)" bash -c "
install_dir=/usr/local/lib/llama.cpp-$tag
curl -fsSL '$asset_url' -o /tmp/llamacpp.tar.gz
sudo rm -rf \$install_dir
sudo mkdir -p \$install_dir
sudo tar xzf /tmp/llamacpp.tar.gz -C \$install_dir --strip-components=1
for bin in \$install_dir/llama*; do
[ -f \"\$bin\" ] && [ -x \"\$bin\" ] || continue
sudo ln -sf \"\$bin\" /usr/local/bin/\$(basename \"\$bin\")
done
rm -f /tmp/llamacpp.tar.gz /tmp/llamacpp-releases.json
"
log "llama.cpp $tag installed — run the server with 'pos ai server start <model.gguf>'"
}
uninstall_llamacpp() {
command -v llama-server &>/dev/null || { log "llama.cpp not installed"; return 0; }
spawn "Removing llama.cpp files" sudo rm -rf /usr/local/lib/llama.cpp-*
# Remove only the symlinks we created (targets inside the install dir);
# unrelated /usr/local/bin/llama* files are left alone.
spawn "Removing llama.cpp symlinks" bash -c "
for link in /usr/local/bin/llama*; do
[ -L \"\$link\" ] || continue
target=\$(readlink \"\$link\")
case \"\$target\" in
/usr/local/lib/llama.cpp-*) sudo rm -f \"\$link\" ;;
esac
done
"
log "llama.cpp removed"
}
case "${1:-}" in
uninstall) uninstall_llamacpp ;;
*) install_llamacpp ;;
esac