my-homelab-configs/docs/ai-ops.md

7.1 KiB

Jeannie AI & Operations

Implementation Language Policy

Jeannie keeps ./jeannie as the stable command entrypoint. New durable read-only orchestration, report rendering, inventory parsing, status/doctor logic, and self-heal planning should prefer Go under cmd/jeannie-core because it ships as one small binary and is easier to test than Bash. Bash remains for thin compatibility wrappers and remote shell glue. Python remains acceptable for AI/RAG, data-heavy utilities, or cases where an existing Python ecosystem is the clear fit. New repo features should choose the smallest language that fits the task instead of defaulting to Bash.

Debian-Hosted AI Stack

The current AI stack is part of the Debian operations layer, not the Kubernetes workload layer. That is deliberate: if the Pimox workers or Kubernetes control plane are unhealthy, the triage tools still need to be available from the host that runs Jeannie.

The split is:

  • OmniRoute runs in Docker Compose under /data/homelab-ai-stack and exposes an OpenAI-compatible endpoint on the Debian host.
  • deploy-ai-stack seeds local OpenRouter and NVIDIA keys when present, creates the no-auth/free provider connections, validates real chat completions, rejects stale routes, and writes /data/homelab-ai-stack/models.env.
  • deploy-ai-tools keeps goose, holmes, and hermes as bare-metal tools and generates wrapper commands (jeannie-goose, jeannie-holmes, jeannie-hermes) plus /data/homelab-ai-stack/ai-tools.env.
  • ai-check verifies the knowledge index, wrappers, OmniRoute endpoint, and validated model route hints before Jeannie relies on them.
  • Ollama remains on Debian for single-purpose local tasks such as translation cache misses, but Holmes agentic Kubernetes triage should use the OmniRoute-backed routes.

Bootstrap and validation from the Debian server:

./jeannie deploy-ai-stack
./jeannie deploy-ai-tools
./jeannie ai-check

Holmes-Assisted Kubernetes Doctor

doctor-k8s is the first integration point between deterministic Jeannie doctors and the AI stack. It collects read-only Kubernetes evidence, writes an artifact directory under ~/.local/share/homelab/doctor-k8s, and asks Holmes for triage through the OmniRoute route selected in models.env.

./jeannie doctor-k8s
./jeannie doctor-k8s --no-holmes

The AI output is advisory. Jeannie keeps remediation deterministic: fixes must map to explicit heal/runbook commands, self-heal allowlists, or human-reviewed pipeline changes. This keeps the diagnostic layer read-only while still using Holmes to summarize likely root cause, impact, and next action.

AI Evals

The repo includes a local eval harness for Jeannie explanations and homelab RAG grounding. It uses fixtures and allowlisted read-only commands, so it is safe to run before changing the lab:

./jeannie ai-evals run

Use ./jeannie ai-evals list to see the current cases. Add new cases under infra/ai-evals whenever a troubleshooting pattern or runbook behavior should become repeatable.

Prompt Injection Lab

The defensive security training path includes local prompt-injection fixtures for hostile runbooks, tool output, dashboard annotations, and command arguments. Run it without touching live infrastructure:

./jeannie prompt-injection-lab run

Cases live under security/prompt-injection-lab and are meant to become regression tests for future Jeannie AI features.

Incident Commander

The repo also includes a read-only incident commander trainer. It classifies pasted failure text, prints a likely hypothesis, links the right runbook, and lists the next read-only Jeannie commands:

./jeannie incident replay
./jeannie incident triage --text "502 Bad Gateway from nginx"

Incident fixtures live under infra/incident-commander. Use them to turn repeat outages into repeatable triage behavior before adding any self-healing.

Safety Cases

Before high-blast-radius changes, generate a safety case from the Git diff:

./jeannie safety-case --since HEAD~1

It summarizes risk, blast radius, required validation, rollback, and forbidden actions. The implementation lives under infra/safety-cases and reuses the same impact rules as ./jeannie impact.

Agent Sandbox

Future Jeannie AI actions should be checked before execution. The local sandbox policy starts with a read-only command classifier:

./jeannie agent-sandbox check "./jeannie status"
./jeannie agent-sandbox check "./jeannie nuke"

Policy is stored in infra/agent-sandbox/policy.tsv.

AI Workload Scheduling

For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox workers, and the RPi based on CPU, memory, architecture, tailnet access, and control-plane policy:

./jeannie ai-scheduler recommend small-rag
./jeannie ai-scheduler simulate

The simulator lives under infra/ai-scheduler and is a stepping stone toward a real Kubernetes controller.

Memory With Provenance

Jeannie can return cited retrieval context and check whether the local RAG index is stale:

./jeannie ask --citations "how do I recover the cluster?"
./jeannie ai-memory check

This keeps local AI answers grounded in repo files and runbooks.

Red/Blue Loop

Safe red-team/blue-team checks are grouped under one command:

./jeannie red-blue plan
./jeannie red-blue run --local

Local mode runs deterministic prompt-injection and eval checks. Live scans are listed but gated so they can run from the Debian host when intended.

Canary Promotion

The promotion helper defines release gates before production changes:

./jeannie promote plan
./jeannie promote validate
./jeannie promote rollback website-production

The current version is intentionally conservative: it validates local gates and prints rollback steps while dev namespace automation remains explicit future work.

Guarded Self-Healing

Jeannie can turn status findings into an experimental self-heal plan:

./jeannie status --heal-plan
./jeannie status --heal
./jeannie heal apply --yes

Normal status remains read-only. The heal planner maps known findings to guarded actions, chooses one highest-impact auto-eligible finding, checks the proposed command against infra/agent-sandbox/policy.tsv, and runs only that one action. Re-run ./jeannie status after every heal cycle so Jeannie can reassess before touching the next issue. If a specific Pimox worker is NotReady, heal targets that worker with ./jeannie workers restart N instead of repeating a broad cluster start. After an action runs, Jeannie waits for the target condition to clear and reports healed or still failing. Failed heal actions are placed on a short cooldown so Jeannie does not loop on the same VM restart; the next plan escalates to diagnostics instead. Destructive actions remain blocked.

Model Behavior Observatory

Stable prompts track local model behavior, latency, refusal behavior, and tool-correctness signals over time:

./jeannie model-observe prompts
./jeannie model-observe run --offline
./jeannie model-observe report

Use --live only when Ollama is available.