feat: harden local runtime and verification

This commit is contained in:
Joseph Magly
2026-08-23 11:16:10 -04:00
parent b0da692ea0
commit ad883cef0b
14 changed files with 602 additions and 58 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
set +x
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
if [[ -z "${OBLITERATUS_SECRET_COMMAND:-}" ]] && \
[[ -x /home/roctinam/.local/bin/obliteratus-secret-broker ]]; then
export OBLITERATUS_SECRET_COMMAND=/home/roctinam/.local/bin/obliteratus-secret-broker
fi
# Avoid dynamic mixing between PyTorch's bundled cuDNN and a host cuDNN
# installation. Causal convolutions and attention use other CUDA kernels.
export OBLITERATUS_DISABLE_CUDNN="${OBLITERATUS_DISABLE_CUDNN:-1}"
exec .venv/bin/python app.py --host "${OBLITERATUS_HOST:-127.0.0.1}" \
--port "${OBLITERATUS_PORT:-7860}"
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
set +x
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
uv sync --locked --extra spaces --extra dev --no-editable
enable_cuda="${ENABLE_CUDA:-auto}"
if [[ "$enable_cuda" != "false" ]] && command -v nvidia-smi >/dev/null 2>&1; then
torch_version="$(.venv/bin/python -c 'import torch; print(torch.__version__.split("+", 1)[0])')"
UV_TORCH_BACKEND=cu130 uv pip install \
--python .venv/bin/python \
--reinstall-package torch \
"torch==$torch_version"
fi
uv pip check --python .venv/bin/python
.venv/bin/python - <<'PY'
import shutil
import torch
if torch.cuda.is_available():
probe = torch.arange(16, device="cuda", dtype=torch.float32).square().sum()
assert probe.device.type == "cuda"
torch.backends.cudnn.enabled = False
torch.backends.cuda.enable_cudnn_sdp(False)
conv_input = torch.randn(1, 8, 32, device="cuda", dtype=torch.float16)
conv_weight = torch.randn(8, 8, 3, device="cuda", dtype=torch.float16)
convolution = torch.nn.functional.conv1d(conv_input, conv_weight)
q = torch.randn(1, 2, 32, 16, device="cuda", dtype=torch.float16)
attention = torch.nn.functional.scaled_dot_product_attention(q, q, q, is_causal=True)
torch.cuda.synchronize()
assert convolution.device.type == "cuda" and torch.isfinite(convolution).all()
assert attention.device.type == "cuda" and torch.isfinite(attention).all()
elif shutil.which("nvidia-smi"):
raise SystemExit("NVIDIA hardware detected but the installed PyTorch runtime cannot use CUDA")
PY
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euo pipefail
set +x
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
.venv/bin/python - <<'PY'
import os
import shutil
import torch
from obliteratus.credential_sources import secret_available
assert torch.ones(1).add(1).item() == 2
if shutil.which("nvidia-smi"):
assert torch.cuda.is_available(), "NVIDIA GPU detected but CUDA is unavailable"
assert torch.ones(1, device="cuda").device.type == "cuda"
torch.backends.cudnn.enabled = False
torch.backends.cuda.enable_cudnn_sdp(False)
conv_input = torch.randn(1, 8, 32, device="cuda", dtype=torch.float16)
conv_weight = torch.randn(8, 8, 3, device="cuda", dtype=torch.float16)
convolution = torch.nn.functional.conv1d(conv_input, conv_weight)
q = torch.randn(1, 2, 32, 16, device="cuda", dtype=torch.float16)
attention = torch.nn.functional.scaled_dot_product_attention(q, q, q, is_causal=True)
torch.cuda.synchronize()
assert convolution.device.type == "cuda" and torch.isfinite(convolution).all()
assert attention.device.type == "cuda" and torch.isfinite(attention).all()
broker = os.environ.get("OBLITERATUS_SECRET_COMMAND")
if broker:
assert os.path.isabs(broker)
assert secret_available("HF_TOKEN")
assert secret_available("OPENROUTER_API_KEY")
PY
.venv/bin/pytest -q --no-cov tests/test_device_boundaries.py tests/test_secrets.py \
tests/test_abliterate.py::TestCoherenceScoring
+81
View File
@@ -0,0 +1,81 @@
apiVersion: setup.aiwg.io/v1
kind: SetupManifest
metadata:
name: obliteratus-dev
version: 1.0.0
description: Provider-orchestrated Linux setup with optional NVIDIA CUDA and scoped OpenBao runtime credentials.
install_type: developer
execution_mode: provider-orchestrated
spec:
platforms:
- os: linux
arch: [x86_64, arm64]
shell: bash
params:
- name: ENABLE_CUDA
type: choice
choices: [auto, "true", "false"]
default: auto
description: Install the matching CUDA PyTorch wheel when NVIDIA hardware is available.
- name: ENABLE_OPENBAO
type: choice
choices: [auto, "true", "false"]
default: auto
description: Configure the scoped OBLITERATUS AppRole through the sibling itops repository.
- name: OPENBAO_ITOPS_ROOT
type: path
default: "${HOME}/dev/itops"
description: Trusted itops checkout containing OpenBao policy and token helpers.
prerequisites:
- name: python
detect: "python3 --version | awk '{print $2}'"
version_min: "3.10"
install_hint: Install Python 3.10 or newer.
- name: uv
detect: "uv --version | awk '{print $2}'"
install_hint: Install uv from https://docs.astral.sh/uv/.
- name: git
detect: "git --version | awk '{print $3}'"
version_min: "2.30"
install_hint: Install Git from https://git-scm.com/.
- name: disk-space
detect: "df --output=avail -BG . | tail -1 | tr -d ' G'"
version_min: "12"
install_hint: At least 12 GB free space is required for dependencies and a test model.
- name: ram
detect: "awk '/MemTotal/ {printf \"%.0f\", $2/1024/1024}' /proc/meminfo"
version_min: "8"
install_hint: At least 8 GB RAM is required; 16 GB or more is recommended.
steps:
- id: install-runtime
type: script
script: scripts/setup.sh
verify: ".venv/bin/python -c 'import gradio, torch, transformers'"
- id: configure-openbao
type: agentic
depends_on: [install-runtime]
instruction: |
When ENABLE_OPENBAO is true, or auto and OPENBAO_ITOPS_ROOT is usable,
follow that repository's AGENTS.md and security SOP. Reuse or provision a
least-privilege obliteratus-local AppRole restricted to reads of
kv_internal/data/{huggingface/read-token,openrouter/automation-agent-key}
and their exact metadata leaves. Seal the AppRole bootstrap to the host
TPM when available. Install a mode-0700 OBLITERATUS_SECRET_COMMAND broker
that maps only HF_TOKEN and OPENROUTER_API_KEY. Verify intended reads and
an adjacent 403 denial. Never print secret values. Do not map the read-only
HF token to HF_PUSH_TOKEN or OBLITERATUS_HUB_TOKEN.
- id: verify-runtime
type: script
script: scripts/verify.sh
depends_on: [install-runtime, configure-openbao]
briefing:
success: OBLITERATUS developer runtime is ready.
next_steps:
- Run installer/scripts/launch-local.sh and open http://127.0.0.1:7860.
- Use a separate write-scoped HF_PUSH_TOKEN or OBLITERATUS_HUB_TOKEN only when testing Hub publishing.
recovery:
- id: reinstall-runtime
steps:
- id: reinstall
type: script
script: scripts/setup.sh