add jarvis bootstrap script with pinned engine deps; guppy becomes ollama-only
This commit is contained in:
1 parent
d866d94d04
commit
67027ecc20
3 files changed
+274
-17
No files matched your search
@@ -52,13 +52,17 @@ dashboard.py stdlib http.server + JSON API (tree/trace/dream/status +
|
||||
|
||||
Dev machine is a thin client (no GPU, ~1.4G disk): only pure stdlib unit tests
|
||||
run here (`python3 -m pytest tests/ -q --ignore=tests/integration`).
|
||||
Integration tests run on the staging machine `jarvis` (see "### jarvis (staging)").
|
||||
|
||||
## Git / sync
|
||||
|
||||
- Canonical repo lives on Gitea: `git.manyworlds.fit`, **SSH on port 222**
|
||||
(`ssh://git@git.manyworlds.fit:222/gabby/semif-agent.git`). Key
|
||||
`~/.ssh/id_ed25519` is registered there. The box `guppy` keeps a working copy
|
||||
at `~/semif-agent`; the dev machine at `~/Repos/semif-agent`. Push/pull from
|
||||
`~/.ssh/id_ed25519` is registered there. The staging machine `jarvis` clones
|
||||
to `~/semif-agent` (via `scripts/bootstrap.sh`); the old box working copy is
|
||||
at `~/repos/semif-agent` (its editable install still points at the moved
|
||||
`~/semif-agent`, so `import semif_agent` is broken there — moot, guppy runs
|
||||
ollama only now); the dev machine at `~/Repos/semif-agent`. Push/pull from
|
||||
Gitea — never rsync/tar the code.
|
||||
- **`config.json` is gitignored and per-machine** (dev and the box use different
|
||||
engine/LLM paths). Copy `config.example.json` to `config.json` and edit.
|
||||
@@ -74,7 +78,10 @@ run here (`python3 -m pytest tests/ -q --ignore=tests/integration`).
|
||||
- Decision rows logged before the `run_id` threading landed show up under
|
||||
run_id `"?"` in the dashboard — that's expected, not a bug.
|
||||
|
||||
The AMD box `guppy` (`abby@192.168.8.181`) is the real run target. Key facts:
|
||||
Machine split (Sep 2026): **guppy** is the ollama **model server only**;
|
||||
**jarvis** is the staging/test target (semif-agent + SemIf engine + deps).
|
||||
Provision jarvis with `scripts/bootstrap.sh` (see "### jarvis (staging)").
|
||||
Guppy key facts:
|
||||
|
||||
- ssh key `~/.ssh/id_ed25519` is passphrase-protected. Load it into an agent at
|
||||
a fixed socket before connecting (the default flatpak `SSH_AUTH_SOCK` refuses):
|
||||
@@ -84,18 +91,11 @@ The AMD box `guppy` (`abby@192.168.8.181`) is the real run target. Key facts:
|
||||
SSH_ASKPASS=/tmp/opencode/askpass.sh SSH_ASKPASS_REQUIRE=force setsid -w ssh-add ~/.ssh/id_ed25519
|
||||
```
|
||||
The agent dies if this machine restarts; redo it each session.
|
||||
- `semif_agent` is editable-installed into the box venv
|
||||
(`pip install -e ~/semif-agent --no-deps`), so `python -m semif_agent.cli ...`
|
||||
works from any directory on the box, not just the repo root.
|
||||
- Run the agent on the box:
|
||||
```sh
|
||||
cd ~/semif-agent && export HF_HOME=/home/abby/hf
|
||||
~/semif-venv/bin/python -m semif_agent.cli run # REPL
|
||||
~/semif-venv/bin/python -m semif_agent.cli run --script demo.jsonl
|
||||
~/semif-venv/bin/python -m semif_agent.cli dream # cost report
|
||||
~/semif-venv/bin/python -m semif_agent.cli relabel <id> <outcome>
|
||||
~/semif-venv/bin/python -m semif_agent.cli dashboard --port 8765
|
||||
```
|
||||
- The agent on guppy is **deprecated** (guppy is ollama-only now). The box
|
||||
venv's editable install (`__editable__.semif_agent_0_1_0_finder.py`) still
|
||||
maps to `/home/abby/semif-agent`, which was moved to `~/repos/semif-agent`,
|
||||
so `import semif_agent` fails there — expected, not a bug. Run the agent on
|
||||
**jarvis** instead (below).
|
||||
- Dashboard: runs as a systemd **user** service on the box
|
||||
(`semif-dashboard.service`, linger enabled, binds `0.0.0.0:8765`), so it's up
|
||||
after reboots with no manual launch — browser UI at http://192.168.8.181:8765/.
|
||||
@@ -205,6 +205,36 @@ unit tests (24) + box integration tests (2).
|
||||
also works but is huge/slow.
|
||||
- If generation hangs with no log output, restart the service
|
||||
(`sudo systemctl restart ollama`) — the ROCm runner can wedge.
|
||||
- Ollama already binds `OLLAMA_HOST=0.0.0.0`, so jarvis reaches it as a plain
|
||||
remote API at `http://192.168.8.181:11434` (no auth — LAN-visible, same
|
||||
exposure as the old dashboard POST endpoints).
|
||||
|
||||
### jarvis (staging)
|
||||
|
||||
- Provision a fresh Ubuntu machine into a running staging box:
|
||||
`scripts/bootstrap.sh --peer-ollama http://192.168.8.181:11434`.
|
||||
Idempotent and rerunnable; every stage no-ops on existing state, so it also
|
||||
boots an unknown-state machine. It installs **no ollama** — llm + codegen
|
||||
both point at guppy.
|
||||
- All pins are read from `config.example.json`'s `engine` block: `semif_repo`
|
||||
(public GitHub `TheoLeeCJ/SemIf`), `semif_ref` (pinned commit the box runs),
|
||||
`gguf_url`/`gguf_sha256` (verified after download), and the HF tokenizer
|
||||
`source`/`revision`. **Maintenance**: bump those pins in `config.example.json`,
|
||||
rerun the script, re-run the integration tests. The script never guesses.
|
||||
- Generates `~/semif-agent/config.json` with `codegen.timeout: 3600` (codegen
|
||||
now travels the LAN) and a backup of any prior file. `--threads N` overrides
|
||||
engine threads; `--copy-data SRC` rsyncs guppy's `data/` for continuity;
|
||||
`--public-dashboard` binds the dashboard to `0.0.0.0`.
|
||||
- Run / verify on jarvis:
|
||||
```sh
|
||||
cd ~/semif-agent && export HF_HOME=~/hf
|
||||
~/semif-venv/bin/python -m semif_agent.cli run # REPL
|
||||
~/semif-venv/bin/python -m semif_agent.cli dream # cost report
|
||||
~/semif-venv/bin/python -m pytest tests/integration -q -s # ~100s, background+poll
|
||||
~/semif-venv/bin/python -m semif_agent.cli dashboard --port 8765
|
||||
```
|
||||
- First run downloads the 2.8G GGUF and builds `llama-cpp-python` from source
|
||||
(~10 min on 6 cores); reruns are fast no-ops.
|
||||
|
||||
### codegen (skill bodies, box)
|
||||
- Skill **bodies** are written by a separate OpenAI-compatible model, configured
|
||||
@@ -513,7 +543,8 @@ WARN 100–200K, DUMB>200K), so limits are a total-context budget
|
||||
the max (1.0) so low items catch up; uniform additive boosts do nothing.
|
||||
- CLI subcommands must not crash when the engine is unavailable — `submit`
|
||||
catches `EngineUnavailable` and returns `("error", ...)`.
|
||||
- Keep deps stdlib-only in the core; heavy deps live on the box venv.
|
||||
- Keep deps stdlib-only in the core; heavy deps live on the staging venv
|
||||
(`~/semif-venv`, provisioned by `scripts/bootstrap.sh`).
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -521,6 +552,7 @@ WARN 100–200K, DUMB>200K), so limits are a total-context budget
|
||||
Includes the dashboard API tests (`tests/test_dashboard_api.py`), which spin
|
||||
up the stdlib HTTP server on an ephemeral port with the engine never loaded,
|
||||
and `tests/test_codegen.py` for prompt/parse/validate + body store round-trips.
|
||||
- `tests/integration/` — box only; requires real SemIf + real ollama.
|
||||
- `tests/integration/` — jarvis only (staging); requires real SemIf + real
|
||||
ollama (guppy serves the models over the LAN).
|
||||
- After touching scheduler/skills/codegen/engine, re-run both; the integration
|
||||
tests are the only end-to-end verification.
|
||||
@@ -8,6 +8,10 @@
|
||||
"source": "Qwen/Qwen3.5-4B",
|
||||
"revision": "851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
|
||||
"gguf": "/home/abby/models/Qwen3.5-4B-Q4_K_M.gguf",
|
||||
"gguf_url": "https://huggingface.co/bartowski/Qwen_Qwen3.5-4B-GGUF/resolve/main/Qwen_Qwen3.5-4B-Q4_K_M.gguf",
|
||||
"gguf_sha256": "13c16f426047e2de38cd075bdade4a7bcbc8c774384876f677740cda65f8a983",
|
||||
"semif_repo": "https://github.com/TheoLeeCJ/SemIf.git",
|
||||
"semif_ref": "1f2dea3e25379f9dfc98cb83c324f00ab5deda37",
|
||||
"context_tokens": 4096,
|
||||
"threads": 8
|
||||
},
|
||||
|
||||
Executable
+221
@@ -0,0 +1,221 @@
|
||||
#!/usr/bin/env bash
|
||||
# Provision a new Ubuntu machine into a running semif-agent staging box.
|
||||
#
|
||||
# Idempotent: safe to rerun; every stage no-ops on already-provisioned state,
|
||||
# so it can also bootstrap a machine of unknown state. All LLM traffic points
|
||||
# at a peer ollama endpoint (default: guppy) — this script installs NO ollama.
|
||||
#
|
||||
# Pins (SemIf git commit, GGUF url+sha256, python deps) are read from
|
||||
# config.example.json's engine block, which is the single source of truth;
|
||||
# bump those there and rerun to upgrade.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/bootstrap.sh [--peer-ollama URL] [--threads N] [--copy-data SRC]
|
||||
# [--public-dashboard] [-h]
|
||||
#
|
||||
# Run as the human user; sudo is used internally for system bits.
|
||||
set -euo pipefail
|
||||
|
||||
PEER_OLLAMA="http://192.168.8.181:11434"
|
||||
THREADS=""
|
||||
COPY_DATA=""
|
||||
PUBLIC_DASHBOARD=0
|
||||
|
||||
usage() {
|
||||
sed -n '2,12p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
|
||||
echo
|
||||
echo " --peer-ollama URL remote ollama API for llm+codegen (default: $PEER_OLLAMA)"
|
||||
echo " --threads N engine threads for config.json (default: config.example value)"
|
||||
echo " --copy-data SRC rsync SRC (e.g. abby@box:~/repos/semif-agent/data) to data/ — opt-in"
|
||||
echo " --public-dashboard bind dashboard to 0.0.0.0 instead of 127.0.0.1"
|
||||
echo " -h this help"
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--peer-ollama) PEER_OLLAMA="$2"; shift 2 ;;
|
||||
--threads) THREADS="$2"; shift 2 ;;
|
||||
--copy-data) COPY_DATA="$2"; shift 2 ;;
|
||||
--public-dashboard) PUBLIC_DASHBOARD=1; shift ;;
|
||||
-h|--help) usage 0 ;;
|
||||
*) echo "unknown option: $1" >&2; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
EXAMPLE="$REPO_ROOT/config.example.json"
|
||||
|
||||
if [[ ! -f "$EXAMPLE" ]]; then
|
||||
echo "config.example.json not found at $EXAMPLE — run from a semif-agent checkout" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- read pins from config.example.json ------------------------------------
|
||||
read -r SEMIF_REPO SEMIF_REF GGUF_URL GGUF_SHA256 HF_SOURCE HF_REV < <(
|
||||
python3 - "$EXAMPLE" <<'PY'
|
||||
import json, sys
|
||||
cfg = json.load(open(sys.argv[1]))
|
||||
e = cfg["engine"]
|
||||
print(
|
||||
" ".join(
|
||||
[
|
||||
e.get("semif_repo", ""),
|
||||
e.get("semif_ref", ""),
|
||||
e.get("gguf_url", ""),
|
||||
e.get("gguf_sha256", ""),
|
||||
e.get("source", ""),
|
||||
e.get("revision", ""),
|
||||
]
|
||||
)
|
||||
)
|
||||
PY
|
||||
)
|
||||
|
||||
if [[ -z "$SEMIF_REPO" || -z "$SEMIF_REF" || -z "$GGUF_URL" || -z "$GGUF_SHA256" ]]; then
|
||||
echo "engine pins missing in $EXAMPLE (semif_repo/semif_ref/gguf_url/gguf_sha256)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "== pins: semif @ $SEMIF_REF | gguf sha256 ${GGUF_SHA256:0:12}… | peer $PEER_OLLAMA"
|
||||
|
||||
# --- stage 0: system prereqs -------------------------------------------------
|
||||
PKGS=(ca-certificates curl git rsync build-essential python3-dev python3-venv pkg-config cmake)
|
||||
missing=()
|
||||
for p in "${PKGS[@]}"; do
|
||||
dpkg -s "$p" >/dev/null 2>&1 || missing+=("$p")
|
||||
done
|
||||
if [[ ${#missing[@]} -gt 0 ]]; then
|
||||
echo "== installing prereqs: ${missing[*]}"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "${missing[@]}"
|
||||
fi
|
||||
|
||||
# --- stage 1: python ----------------------------------------------------------
|
||||
PY=python3
|
||||
if ! "$PY" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' 2>/dev/null; then
|
||||
echo "== python3 < 3.11; installing python3.13 from deadsnakes"
|
||||
sudo apt-get install -y software-properties-common
|
||||
sudo add-apt-repository -y ppa:deadsnakes/ppa
|
||||
sudo apt-get install -y python3.13 python3.13-venv python3.13-dev
|
||||
PY=python3.13
|
||||
fi
|
||||
echo "== python: $("$PY" --version)"
|
||||
|
||||
# --- stage 2: ssh key + clones -------------------------------------------------
|
||||
mkdir -p ~/.ssh
|
||||
if [[ ! -f ~/.ssh/id_ed25519 ]]; then
|
||||
echo "== generating ~/.ssh/id_ed25519"
|
||||
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
|
||||
fi
|
||||
|
||||
if [[ ! -d ~/semif-agent/.git ]]; then
|
||||
echo "== cloning semif-agent from Gitea"
|
||||
if ! git clone ssh://git@git.manyworlds.fit:222/gabby/semif-agent.git ~/semif-agent; then
|
||||
echo "clone failed — register this key on Gitea, then rerun:" >&2
|
||||
cat ~/.ssh/id_ed25519.pub >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
git -C ~/semif-agent pull --ff-only || true
|
||||
fi
|
||||
|
||||
if [[ ! -d ~/semif/.git ]]; then
|
||||
echo "== cloning SemIf engine from $SEMIF_REPO"
|
||||
git clone "$SEMIF_REPO" ~/semif
|
||||
fi
|
||||
if [[ "$(git -C ~/semif rev-parse HEAD 2>/dev/null)" != "$SEMIF_REF" ]]; then
|
||||
echo "== pinning SemIf engine to $SEMIF_REF"
|
||||
git -C ~/semif fetch origin
|
||||
git -C ~/semif checkout "$SEMIF_REF"
|
||||
fi
|
||||
|
||||
# --- stage 3: venv + deps -------------------------------------------------------
|
||||
if [[ ! -d ~/semif-venv ]]; then
|
||||
echo "== creating ~/semif-venv"
|
||||
"$PY" -m venv ~/semif-venv
|
||||
fi
|
||||
PIP=~/semif-venv/bin/pip
|
||||
echo "== installing engine deps into venv"
|
||||
"$PIP" install --upgrade pip setuptools wheel
|
||||
"$PIP" install -e ~/semif --no-deps
|
||||
"$PIP" install numpy==2.3.5 transformers==5.17.0 tokenizers==0.23.2 huggingface-hub
|
||||
CMAKE_BUILD_PARALLEL_LEVEL=6 MAKEFLAGS=-j6 "$PIP" install llama-cpp-python==0.3.35
|
||||
"$PIP" install -e ~/semif-agent --no-deps
|
||||
"$PIP" install pytest
|
||||
|
||||
# --- stage 4: GGUF --------------------------------------------------------------
|
||||
GGUF_DIR=~/models
|
||||
GGUF_NAME="$(basename "$GGUF_URL")"
|
||||
GGUF="$GGUF_DIR/$GGUF_NAME"
|
||||
mkdir -p "$GGUF_DIR"
|
||||
sha_ok() { [[ -f "$GGUF" ]] && [[ "$(sha256sum "$GGUF" | cut -d' ' -f1)" == "$GGUF_SHA256" ]]; }
|
||||
if ! sha_ok; then
|
||||
echo "== downloading GGUF ($GGUF_NAME)"
|
||||
rm -f "$GGUF" "$GGUF.tmp"
|
||||
curl -fL --retry 3 -o "$GGUF.tmp" "$GGUF_URL"
|
||||
mv "$GGUF.tmp" "$GGUF"
|
||||
fi
|
||||
sha_ok || { echo "GGUF sha256 mismatch: expected $GGUF_SHA256" >&2; exit 1; }
|
||||
echo "== GGUF verified ($GGUF)"
|
||||
|
||||
# --- stage 5: HF tokenizer cache --------------------------------------------------
|
||||
export HF_HOME="$HOME/hf"
|
||||
mkdir -p "$HF_HOME"
|
||||
echo "== pre-fetching tokenizer $HF_SOURCE @ $HF_REV"
|
||||
~/semif-venv/bin/python - "$HF_SOURCE" "$HF_REV" <<'PY'
|
||||
import sys
|
||||
from transformers import AutoTokenizer
|
||||
AutoTokenizer.from_pretrained(sys.argv[1], revision=sys.argv[2])
|
||||
PY
|
||||
|
||||
# --- stage 6: config.json -----------------------------------------------------------
|
||||
if [[ -f "$REPO_ROOT/config.json" ]]; then
|
||||
cp "$REPO_ROOT/config.json" "$REPO_ROOT/config.json.bak.$(date +%s)"
|
||||
fi
|
||||
echo "== writing config.json (llm/codegen -> $PEER_OLLAMA)"
|
||||
python3 - "$REPO_ROOT/config.example.json" "$REPO_ROOT/config.json" "$THREADS" "$PEER_OLLAMA" "$([ "$PUBLIC_DASHBOARD" = 1 ] && echo 0.0.0.0 || echo 127.0.0.1)" <<'PY'
|
||||
import json, os, sys
|
||||
example, out, threads, peer, dash_host = sys.argv[1:]
|
||||
cfg = json.load(open(example))
|
||||
eng = cfg["engine"]
|
||||
eng["gguf"] = os.path.join(os.path.expanduser("~"), "models", os.path.basename(eng["gguf_url"]))
|
||||
if threads and threads != "__example__":
|
||||
eng["threads"] = int(threads)
|
||||
cfg["llm"]["base_url"] = peer
|
||||
cfg["codegen"]["base_url"] = peer
|
||||
cfg["codegen"]["timeout"] = 3600
|
||||
cfg.setdefault("dashboard", {})["port"] = 8765
|
||||
cfg["dashboard"]["host"] = dash_host
|
||||
json.dump(cfg, open(out, "w"), indent=2)
|
||||
PY
|
||||
|
||||
# --- stage 7: optional data copy -----------------------------------------------------
|
||||
if [[ -n "$COPY_DATA" ]]; then
|
||||
echo "== rsync data from $COPY_DATA"
|
||||
mkdir -p ~/semif-agent/data
|
||||
rsync -a "$COPY_DATA/" ~/semif-agent/data/
|
||||
fi
|
||||
|
||||
# --- stage 8: verify --------------------------------------------------------------------
|
||||
echo "== verifying imports"
|
||||
~/semif-venv/bin/python -c "import semif_phase1, semif_agent; print('engine + agent import OK')"
|
||||
echo "== peer ollama check ($PEER_OLLAMA)"
|
||||
PEER_TAGS="$(curl -sf --max-time 5 "$PEER_OLLAMA/api/tags" || true)"
|
||||
if grep -qE "qwen3\.5:4b" <<<"$PEER_TAGS"; then
|
||||
echo "peer serves qwen3.5:4b (self-assessment): OK"
|
||||
else
|
||||
echo "WARN: peer /api/tags shows no qwen3.5:4b" >&2
|
||||
fi
|
||||
if grep -qE "qwen38-iq3s" <<<"$PEER_TAGS"; then
|
||||
echo "peer serves qwen38-iq3s (codegen): OK"
|
||||
else
|
||||
echo "WARN: peer /api/tags shows no qwen38-iq3s" >&2
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Done. Next steps:"
|
||||
echo " cd ~/semif-agent"
|
||||
echo " HF_HOME=~/hf ~/semif-venv/bin/python -m semif_agent.cli run"
|
||||
echo " HF_HOME=~/hf ~/semif-venv/bin/python -m pytest tests/integration -q -s (box needs real engine+LLM)"
|
||||
echo " HF_HOME=~/hf ~/semif-venv/bin/python -m semif_agent.cli dashboard --port 8765"
|
||||
Reference in new issue
Block a user