Skip to content

Commit 6d03045

Browse files
Add isolated Ulysses deployment workflow
1 parent aceb716 commit 6d03045

10 files changed

Lines changed: 1045 additions & 13 deletions

‎docs/ULYSSES_DEPLOYMENT.md‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Ulysses source, runtime, and state
2+
3+
Ulysses keeps development, execution, and private state in three independent
4+
trees:
5+
6+
| Path | Purpose | Mutability |
7+
| --- | --- | --- |
8+
| `~/Odysseus/Ulysses` | PR-ready `dev` source checkout | Git commits only |
9+
| `~/Odysseus/Ulysses-build` | Disposable native runtime checkout and `.venv` | Recreated from source |
10+
| `~/Odysseus/Ulysses-state` | Private `.env`, application data, and capture manifest | Durable |
11+
12+
The runtime checkout never receives the production checkout's `.venv`,
13+
`node_modules`, caches, logs, toolchains, or uncommitted source edits.
14+
`Ulysses-build/.env` is an ignored symlink to
15+
`Ulysses-state/ulysses.env`; that file sets `ODYSSEUS_DATA_DIR` to the external
16+
state tree. A runtime rebuild therefore cannot delete user data.
17+
18+
## Inspect without changing anything
19+
20+
From the clean source checkout:
21+
22+
```bash
23+
./scripts/ulysses-deploy --pretty inspect
24+
```
25+
26+
The report verifies that:
27+
28+
- the source is clean, on `dev`, and based on `upstream/dev`;
29+
- production state is selected from an explicit durable allowlist;
30+
- rebuildable caches and accidental nested Bun/Rust toolchains are excluded;
31+
- active production PIDs are reported;
32+
- runtime and state targets are separate.
33+
34+
## Prepare the disposable checkout
35+
36+
```bash
37+
./scripts/ulysses-deploy --pretty prepare
38+
```
39+
40+
This is a local, no-hardlink clone of the exact source commit. Its `source`
41+
remote can fetch from the development checkout but has a disabled push URL.
42+
The official upstream is fetch-only. No service is started and no port is
43+
opened.
44+
45+
If the runtime directory already exists, preparation refuses to overwrite it.
46+
Remove or rename it deliberately only after confirming it contains no state.
47+
48+
## Capture production state
49+
50+
Stop the production web process and model server for a single-point cutover,
51+
then run:
52+
53+
```bash
54+
./scripts/ulysses-deploy --pretty capture
55+
./scripts/ulysses-deploy --pretty attach-state
56+
```
57+
58+
`capture` refuses while a process is using the production checkout. It copies
59+
all SQLite databases through SQLite's online-backup API and atomically publishes
60+
the staged state directory. The state manifest records source provenance,
61+
selected/excluded paths, file sizes and hashes, and critical versions from the
62+
old `.venv`.
63+
64+
For a non-authoritative preview while production is online:
65+
66+
```bash
67+
./scripts/ulysses-deploy --pretty capture --allow-running
68+
```
69+
70+
Use `--replace` only when intentionally replacing a prior captured state. The
71+
old state is retained only during the atomic swap and removed after success;
72+
the command does not create accumulating archive directories.
73+
74+
## Create the native uv environment
75+
76+
The known-good production interpreter is CPython 3.13.12. Build the isolated
77+
candidate only after state is attached:
78+
79+
```bash
80+
./scripts/ulysses-deploy --pretty venv --python 3.13.12
81+
```
82+
83+
The command runs:
84+
85+
1. `uv venv .venv --python 3.13.12 --seed`;
86+
2. `uv pip install --python .venv/bin/python -r requirements.txt`;
87+
3. `.venv/bin/python setup.py` with the imported admin state;
88+
4. `uv pip check`.
89+
90+
It does not install optional inference engines, start tmux, bind ports, or
91+
modify the source checkout. The capture manifest preserves the known-good
92+
production versions (`vllm`, PyTorch, Transformers, ONNX Runtime GPU,
93+
FastEmbed, NumPy, and Triton) so optional engine installation can be reviewed
94+
against that baseline instead of casually upgrading the working stack.
95+
96+
## Cutover gate
97+
98+
Before binding port 7000 or launching a model:
99+
100+
- install the native dependencies shown in Cookbook, including
101+
`liburing-dev` for the Colibri Hy3 `IOURING=1` build;
102+
- validate the WSL/CUDA loader in a new process;
103+
- validate both Colibri model manifests and native binaries;
104+
- run application tests and `uv pip check`;
105+
- confirm ports 7000 and 8000 are free;
106+
- keep `~/Odysseus/odysseus` and its `.venv` unchanged for rollback.
107+
108+
Routine development updates happen in `Ulysses`, rebased or merged against
109+
`upstream/dev`. Recreate `Ulysses-build` from the reviewed source commit rather
110+
than developing inside the runtime checkout.

‎docs/ULYSSES_ROADMAP.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,3 +608,11 @@ corresponding rollback has been tested.
608608
8. [x] Implement Colibri GLM and Colibri Hy3 as separate final provider
609609
integrations. Source build, model load, generation, and 5090 benchmarks
610610
remain human-gated because vLLM and production downloads are active.
611+
9. [x] Separate the PR-ready `Ulysses` checkout, disposable `Ulysses-build`
612+
runtime, and external `Ulysses-state`; add a previewable, SQLite-safe
613+
production-state capture and canonical uv environment workflow.
614+
10. [x] Surface `liburing-dev` as a first-class native Cookbook dependency for
615+
the Colibri Hy3 `IOURING=1` build.
616+
11. [ ] During the maintenance window, capture final production state, create
617+
the candidate venv, validate CUDA/ONNX and Colibri, then benchmark before
618+
any port cutover.

‎docs/backup-restore.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ write can't corrupt the snapshot.
1717
1818
## Quick start
1919

20-
Run the tool from the repository root:
20+
Run the tool from the repository root. If `ODYSSEUS_DATA_DIR` is exported or
21+
set in the checkout's `.env`, the tool snapshots that external data directory
22+
instead of assuming `./data`. It reads the path as configuration text and never
23+
sources `.env` as shell code.
2124

2225
```bash
2326
# Create a snapshot → backups/odysseus-backup-<YYYYMMDD-HHMMSS>.tar.gz

‎routes/shell_routes.py‎

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ def _os_id_from_release(text: str) -> str:
11451145
"make": {"debian": ["make"], "arch": ["make"], "fedora": ["make"], "alpine": ["make"], "suse": ["make"], "macos": []},
11461146
"git": {"debian": ["git"], "arch": ["git"], "fedora": ["git"], "alpine": ["git"], "suse": ["git"], "macos": ["git"]},
11471147
"tmux": {"debian": ["tmux"], "arch": ["tmux"], "fedora": ["tmux"], "alpine": ["tmux"], "suse": ["tmux"], "macos": ["tmux"]},
1148+
# Development package names differ by distro. Presence is probed by
1149+
# the header, not `command -v`, because this package installs no CLI.
1150+
"liburing-dev": {"debian": ["liburing-dev"], "arch": ["liburing"], "fedora": ["liburing-devel"], "alpine": ["liburing-dev"], "suse": ["liburing-devel"], "macos": []},
11481151
}
11491152
_BACKEND_EXTRAS = {
11501153
"cuda": {"debian": ["nvidia-cuda-toolkit"], "arch": ["cuda"], "fedora": ["cuda-toolkit"], "alpine": [], "suse": ["cuda"], "macos": []},
@@ -1256,6 +1259,16 @@ async def list_packages(
12561259
"kind": "system",
12571260
"install_hint": "Install Docker on the selected server and allow this user to run docker.",
12581261
},
1262+
{
1263+
"name": "liburing-dev",
1264+
"pip": "",
1265+
"desc": "Native io_uring headers required by the Colibri Hy3 CUDA build",
1266+
"category": "System",
1267+
"target": "remote",
1268+
"kind": "system",
1269+
"probe_path": "/usr/include/liburing.h",
1270+
"install_hint": "Install the liburing development headers on the selected Linux server. Debian/Ubuntu: sudo apt install -y liburing-dev.",
1271+
},
12591272
# Note: cmake / gcc / git are not separate dependency rows —
12601273
# they're declared as `system_prereqs` on llama_cpp (and any
12611274
# other engine that compiles from source) so they appear as
@@ -1515,9 +1528,16 @@ async def list_packages(
15151528
checks = []
15161529
for name in all_system_names:
15171530
qn = shlex.quote(name)
1518-
checks.append(
1519-
f"PATH=\"$HOME/.local/bin:$HOME/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\"; if command -v {qn} >/dev/null 2>&1; then echo {qn}=1; else echo {qn}=0; fi"
1520-
)
1531+
package = next((p for p in packages if p.get("name") == name), None)
1532+
probe_path = str((package or {}).get("probe_path") or "")
1533+
if probe_path:
1534+
checks.append(
1535+
f"if [ -f {shlex.quote(probe_path)} ]; then echo {qn}=1; else echo {qn}=0; fi"
1536+
)
1537+
else:
1538+
checks.append(
1539+
f"PATH=\"$HOME/.local/bin:$HOME/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\"; if command -v {qn} >/dev/null 2>&1; then echo {qn}=1; else echo {qn}=0; fi"
1540+
)
15211541
checks.append("echo '---OSREL---'; cat /etc/os-release 2>/dev/null || { [ \"$(uname -s 2>/dev/null)\" = \"Darwin\" ] && echo ID=macos; } || true")
15221542
inner = " ; ".join(checks)
15231543
argv = _ssh_base_argv(host, ssh_port) + [inner]
@@ -1572,6 +1592,11 @@ async def list_packages(
15721592
pkg["installed"] = None
15731593
pkg["status_note"] = "Only relevant for Apple Silicon / MLX image serving."
15741594
continue
1595+
if pkg["name"] == "liburing-dev" and target_os_id == "macos":
1596+
pkg["applicable"] = False
1597+
pkg["installed"] = None
1598+
pkg["status_note"] = "Linux-only native build dependency for Colibri Hy3."
1599+
continue
15751600
on_remote = bool(host and pkg.get("target") == "remote")
15761601
probe = None
15771602
if on_remote:
@@ -1596,6 +1621,8 @@ async def list_packages(
15961621
if IS_APPLE_SILICON
15971622
else "Requires a native Apple Silicon Mac with Apple Foundational Models support."
15981623
)
1624+
elif pkg.get("probe_path"):
1625+
pkg["installed"] = Path(str(pkg["probe_path"])).is_file()
15991626
else:
16001627
pkg["installed"] = shutil.which(pkg["name"]) is not None
16011628
elif pkg["name"] == "llama_cpp" and shutil.which("llama-server"):
@@ -1808,7 +1835,7 @@ async def install_package(request: Request):
18081835

18091836
@router.post("/api/cookbook/install-system-deps")
18101837
async def install_system_deps(request: Request):
1811-
"""Install OS-level system packages (cmake/build-essential/git/tmux)
1838+
"""Install allowlisted OS-level system packages
18121839
on a remote target or in the local container. Admin only.
18131840
18141841
Bounded by a per-package allowlist — anything outside the catalog
@@ -1824,20 +1851,26 @@ async def install_system_deps(request: Request):
18241851
ssh_port = body.get("ssh_port")
18251852
# Names users can request — must match canonical names used in the
18261853
# deps catalog's `system_prereqs` field and on the System rows.
1827-
ALLOWED = {"cmake", "build-essential", "g++", "gcc", "git", "tmux", "make"}
1854+
ALLOWED = {"cmake", "build-essential", "g++", "gcc", "git", "tmux", "make", "liburing-dev"}
18281855
pkgs = [str(p).strip() for p in raw if str(p).strip() in ALLOWED]
18291856
if not pkgs:
18301857
return {"ok": False, "error": "no installable packages requested (allowlist: " + ", ".join(sorted(ALLOWED)) + ")"}
18311858
# Re-map to the right package name per OS. apt/dpkg use the names
18321859
# as-is; pacman has base-devel for build-essential, etc.
18331860
def _apt(names): return list(names)
18341861
def _pacman(names):
1835-
return ["base-devel" if n == "build-essential" else n for n in names]
1862+
return [
1863+
"base-devel" if n == "build-essential"
1864+
else "liburing" if n == "liburing-dev"
1865+
else n
1866+
for n in names
1867+
]
18361868
def _dnf(names):
18371869
out = []
18381870
for n in names:
18391871
if n == "build-essential": out += ["gcc", "gcc-c++", "make"]
18401872
elif n == "g++": out += ["gcc-c++"]
1873+
elif n == "liburing-dev": out += ["liburing-devel"]
18411874
else: out.append(n)
18421875
return out
18431876
def _apk(names):
@@ -1851,10 +1884,11 @@ def _zypper(names):
18511884
for n in names:
18521885
if n == "build-essential": out += ["gcc-c++", "make"]
18531886
elif n == "g++": out.append("gcc-c++")
1887+
elif n == "liburing-dev": out.append("liburing-devel")
18541888
else: out.append(n)
18551889
return out
18561890
def _brew(names):
1857-
return [n for n in names if n not in ("build-essential", "g++", "gcc", "make")]
1891+
return [n for n in names if n not in ("build-essential", "g++", "gcc", "make", "liburing-dev")]
18581892
# Build a single shell snippet that detects the package manager and
18591893
# runs the right install. Non-interactive sudo (-n) only — if sudo
18601894
# asks for a password the script reports it instead of hanging.

‎scripts/odysseus-backup‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,38 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "_lib"))
2424
from cli import quiet_logs, emit, fail, common_parser, run, REPO_ROOT as _REPO_ROOT
2525
quiet_logs()
2626

27-
import argparse, json, logging, os, shutil, sqlite3, subprocess, sys, tarfile, tempfile
27+
import argparse, json, logging, os, re, shutil, sqlite3, subprocess, sys, tarfile, tempfile
2828
from datetime import datetime
2929
from pathlib import Path, PurePosixPath
3030

31-
_DATA_DIR = _REPO_ROOT / "data"
31+
def _configured_data_dir() -> Path:
32+
"""Resolve the same external data root used by native app launches.
33+
34+
Keep this CLI standard-library-only: read the single path setting from
35+
``.env`` when it was not already exported. Values are treated as data,
36+
never evaluated as shell source.
37+
"""
38+
value = os.environ.get("ODYSSEUS_DATA_DIR", "").strip()
39+
if not value:
40+
env_path = _REPO_ROOT / ".env"
41+
if env_path.is_file():
42+
for line in env_path.read_text(encoding="utf-8-sig").splitlines():
43+
match = re.match(r"^\s*ODYSSEUS_DATA_DIR\s*=\s*(.*?)\s*$", line)
44+
if not match:
45+
continue
46+
value = match.group(1)
47+
if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'":
48+
value = value[1:-1]
49+
break
50+
if not value:
51+
return _REPO_ROOT / "data"
52+
expanded = Path(os.path.expandvars(os.path.expanduser(value)))
53+
return expanded if expanded.is_absolute() else (_REPO_ROOT / expanded)
54+
55+
56+
_DATA_DIR = _configured_data_dir()
3257
_BACKUP_DIR = _REPO_ROOT / "backups"
58+
_SQLITE_SUFFIXES = {".db", ".sqlite", ".sqlite3"}
3359

3460
# Stuff inside data/ that we explicitly skip — anything we can re-derive
3561
# from the SQLite DB + JSON state. Keeps the tarball small.
@@ -81,7 +107,11 @@ def cmd_snapshot(args):
81107
_reject_output_inside_data(out_path)
82108
out_path.parent.mkdir(parents=True, exist_ok=True)
83109

84-
sqlite_dbs = [p for p in _DATA_DIR.rglob("*.db") if p.is_file() and not p.is_symlink()]
110+
sqlite_dbs = [
111+
p
112+
for p in _DATA_DIR.rglob("*")
113+
if p.is_file() and not p.is_symlink() and p.suffix in _SQLITE_SUFFIXES
114+
]
85115
files_added = 0
86116
total_bytes = 0
87117

0 commit comments

Comments
 (0)