my-homelab-configs/docs/doctor-retrieval-lab.md

94 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Doctor repository retrieval experiment
This experiment keeps `qwen2.5-coder:7b` and production Doctor unchanged. It
compares frozen, synthetic incident decisions with and without targeted
repository context. It does not run Holmes tools, execute suggested commands,
collect live cluster evidence, or perform repairs.
The corpus is an explicit allowlist of committed inventory, selected Jeannie
code, manifests and operational documentation. Retrieval uses bounded lexical
matching, without an embedding model or vector database. Each excerpt includes
its path, line range, file hash and repository revision. Secrets, environment
files, kubeconfigs, OpenTofu state and arbitrary caller-supplied paths are not
in the corpus. Dirty working-tree edits do not become retrieval evidence.
Eight cases cover intentional zero replicas, monitoring on Debian, stale SSD
mounts, retired exporter DNAT, email access filtering, missing image tags,
unknown upstream failures and instructions embedded in logs. Each case records
observations, allowed next actions and a review rubric. These are synthetic
fixtures, not claims about current infrastructure health. The two intentional
state cases assume deployed manifests match the recorded corpus revision.
## API commands after deployment
The normal Jeannie API already enables `ai-lab`. These actions use that same
endpoint and execute on Debian:
```json
{"command":"ai-lab","args":["doctor-retrieval-plan"]}
```
The plan reads the committed corpus and prints the retrieved excerpts. It does
not call Ollama. Then submit a one-repeat smoke benchmark:
```json
{"command":"ai-lab","args":["doctor-retrieval-bench","1"]}
```
A three-repeat comparison uses:
```json
{"command":"ai-lab","args":["doctor-retrieval-bench","3"]}
```
POST these bodies to `/v1/execute` with the existing Bearer token. The response
contains an execution `id`; poll `/v1/executions/<id>` for status and output.
For example, from a client where the existing API credentials are configured:
```sh
curl -fsS -H "Authorization: Bearer ${JEANNIE_REMOTE_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{"command":"ai-lab","args":["doctor-retrieval-plan"]}' \
"${JEANNIE_REMOTE_URL%/}/v1/execute"
```
The remote CLI is another API client:
```sh
./jeannie remote ai-lab doctor-retrieval-plan
./jeannie remote ai-lab doctor-retrieval-bench 1
./jeannie remote ai-lab doctor-retrieval-bench 3
```
The API worker grants the benchmark a six-hour timeout. Repeats are limited to
1–5; three repeats produce 48 requests (8 cases × 2 arms × 3). The lab requires
the existing local 7B model, at least 7 GiB MemAvailable and no other loaded
Ollama model. It neither pulls models nor stops services. It uses the loopback
Ollama endpoint, independent of OmniRoute and external model routes.
## Reports and interpretation
Both arms use the same model, observations, output schema, seed and generation
options. Request order alternates to reduce systematic order effects. The lab
records the Ollama model digest, actual prompt/completion token counts, load,
prompt and generation durations, stop reasons, raw answers, citations and
proposed commands. Proposed commands are never executed. Reports are private
(mode 0600) under the AI lab's `reports/doctor-retrieval-*/report.json` directory;
the execution output includes the absolute report path and aggregate summary.
Partial results are saved after every request and retained on interruption.
The deterministic score awards cause-label agreement (2), next-action agreement
(1), citation structure/repository citation presence (1), and consistency of
unknown-cause confidence (1). Rejected answers and request failures score zero.
Baseline unknown answers can be correct when intent is unavailable; the separate
`resolved_correctly` count shows whether additional context supports a specific
cause. Summary results do not silently drop failures.
This is not a verified accuracy or remediation-success score. Checks cannot
prove that an explanation is factually correct, that a cited excerpt entails a
claim, or that a proposed command would fix a live issue. Review saved answers
against each case's rubric, particularly the injection and storage cases.
Passing frozen decisions does not establish that Holmes will call tools or
complete a live repair. No model or retrieval behavior is promoted to Doctor
automatically.