Files
junction/examples/olivia.conf
T
Hermes 5f8ef9bab7 Provider-Namen, Endpunkte aus der Umgebung, ein Modell zur Zeit, echte Erreichbarkeit
Vier Dinge, die zusammengehören: der Router soll sagen, WER bezahlt wird, er soll nicht
für jeden Schlüssel einen Block verlangen, er soll eine lokale Box nicht überfahren, und
er soll wissen, ob ein Ziel überhaupt da ist.

Namen: `cloud` heißt jetzt `opencode-go`, `cloud-free` heißt `opencode-go-free`. Ein Name,
der eine Betriebsform beschreibt („cloud"), sagt nichts darüber, wer die Rechnung
schickt. In der Live-Konfiguration und in allen Beispielen umbenannt, alle Verweise mit.

Schlüssel = Endpunkt (`auto_endpoints on`): OPENCODE_GO_API_KEY[_N] → opencode-go[N],
OLLAMA_KEY[_N] → ollama[N], ANTHROPIC_API_KEY oder CLAUDE_API_KEY[_N] → claude[N]. Die
Datei gewinnt, wo sie spricht; die Automatik füllt nur Lücken. <PROVIDER>_BASE biegt die
Basis um (für Tests und einen eigenen Proxy). Kein erfundener context: Grenzen gehören
den Modellen und kommen aus ihrer Liste. Eine Datei ohne Endpunkt-Blöcke ist damit
gültig, wenn die Umgebung sie liefert.

`max_model_inflight 1` am Endpunkt: eine Anfrage je (Endpunkt, Modell), der Rest wartet
in der Schlange. Gemessen mit einem 2-s-Stub: dasselbe Modell zweimal braucht 4 s (also
nacheinander), zwei verschiedene Modelle 2 s (also gleichzeitig). `strip "local/"` an der
Regel schneidet das Präfix ab, bevor die Anfrage den Router verlässt — auch im Rumpf, was
ohne `as_model` nur im Router passiert wäre; der Stub bestätigt, dass die Box
qwen3.6-35b sieht und nicht local/qwen3.6-35b. `strip` muss vor `pass` stehen, weil
`pass` die Zeile beendet.

Erreichbarkeit (`probe_interval`, `probe_timeout`, `probe off`): ein Hintergrundfaden
holt die Modellliste jedes Endpunkts. Entscheidend ist der TCP-Verbindungsaufbau, nicht
der Statuscode: `-w '%{time_connect}'` gleich 0 heißt unerreichbar. Beide falschen
Abkürzungen sind mir dabei passiert und beide sind jetzt ausgeschlossen — „jeder
curl-Fehler ist offline" nimmt langsame Ziele dauerhaft aus dem Verkehr, „nur 6/7 ist
offline" hält einen Host für gesund, der Pakete verwirft (die lokalen Ports auf
172.25.206.3 taten genau das: 28 nach Zeitablauf, also laut erster Regel „lebt").

Live: probe meldet lokal1–local4 und den lokalen opencode-Serve korrekt offline
(TCP kommt nicht zustande), eine Anfrage auf local/qwen3.6-35b antwortet in 1,7 s mit
`503 no_endpoint_available` statt nach 6 s in vier Verbindungszeitabläufe zu laufen.

Tests: drei neue Abschnitte (17 Prüfungen) — gleiches Modell 4 s, zwei Modelle 2 s,
Präfix weg; toter Endpunkt ohne Anfrage erkannt, Anfrage überspringt ihn in 1,2 ms, kommt
von selbst zurück, `probe off` hält ein Ziel heraus; Schlüssel aus der Umgebung ergeben
Endpunkte, OLLAMA_KEY2 wird ollama2 und nicht ein größerer Pool, `auto_endpoints off`
erfindet nichts. tests/run.sh räumt Provider-Variablen weg, sonst legt eine zufällig
gesetzte Variable in der Shell Endpunkte an, die kein Test erwartet.
make test: PASS, 249 Prüfungen, 174 s.
2026-11-08 15:09:29 +00:00

170 lines
7.0 KiB
Plaintext

# ============================================================================
# junction.conf — Olivia
#
# One front door for every model endpoint in the van. Clients (Hermes, scripts,
# editors) talk to 127.0.0.1:8090 and never learn which machine answered.
#
# Shape of the file: keyword, arguments, braces. '#' comments, "" groups words,
# first matching rule wins. A typo is a hard error with a line number — this file
# decides where requests go, so silence would be the worst behaviour.
# ============================================================================
listen 0.0.0.0:8090
# Same thing over TLS, no proxy in front (clients must then use https://):
# listen 0.0.0.0:8443 tls /etc/junction/tls/olivia-cert.pem /etc/junction/tls/olivia-key.pem
log_prefix olivia
connect_timeout_ms 1200 # a box that cannot answer a SYN in 1.2 s is asleep
offline_hold_s 20 # stop retrying a dead box for this long
max_body_bytes 67108864 # 64 MiB: a long conversation, not a file upload
# Two slots in flight; everything else waits its turn instead of being refused. A
# streaming client is told why it waits (SSE comments, invisible to any parser).
max_inflight 2
queue_timeout 300
# Answers to identical requests, kept in RAM. Only complete, non-streamed 200s are
# stored; streams and "no-store" responses never are. 0 disables the cache.
cache_ttl 120
cache_entries 256
cache_bytes 67108864
# ---------------------------------------------------------------------------
# The two slots on the workstation, over the WireGuard tunnel. Both serve the same
# loaded model, and only while its kanban is idle, so "reachable" is not the same as
# "free": check-http.sh asks /v1/models and hook_retry gives it a moment to finish.
# The real id, as their own /v1/models reports it, is
# Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M
# A single-model box answers to that id and can hang on any other name, which is what
# the "as" rewrites below are for.
# ---------------------------------------------------------------------------
endpoint peer-a {
base http://172.25.206.3:8081/v1
kind local
context 65536
priority 10
timeout 900 # long jobs are fine, but not unbounded
idle_timeout 45 # ... as long as something arrives every 45 s
cooldown 60
hook /usr/local/share/junction/hooks/check-http.sh
hook_retry 45 # up to 45 s of "kanban still running, wait"
hook_backoff 5
header "X-Junction-Peer: a"
}
endpoint peer-b {
base http://172.25.206.3:8082/v1
kind local
context 65536
priority 20
timeout 900
idle_timeout 45
cooldown 60
hook /usr/local/share/junction/hooks/check-http.sh
hook_retry 45
hook_backoff 5
header "X-Junction-Peer: b"
}
# ---------------------------------------------------------------------------
# The embedding model on the other machine: small, always on, never woken.
# ---------------------------------------------------------------------------
endpoint kitt-embed {
base http://192.168.1.116:11434/v1
kind local
context 2048
priority 5
timeout 120
idle_timeout 15
cooldown 120
cache off # embeddings are cheap to repeat, not worth the RAM
}
# ---------------------------------------------------------------------------
# A machine that sleeps. The hooks decide whether it is worth waking, the wake
# command runs once, and the request waits up to four minutes for it to come back.
# WoL is layer 2 and does NOT cross the tunnel, so this endpoint is a box on n95's
# own segment. For a tunnel peer, the wake hook must talk to something on THAT side
# (a router's WoL feature, a small helper host) instead of broadcasting here.
# ---------------------------------------------------------------------------
endpoint desk {
base http://192.168.1.99:8080/v1 # placeholder: your box on this LAN
kind local
context 128000
priority 5
timeout 3600
idle_timeout 60
cooldown 120
wake /usr/local/share/junction/hooks/wake-wol.sh
hook_retry 240
hook_backoff 10
hook /usr/local/share/junction/hooks/check-http.sh
hook /usr/local/share/junction/hooks/check-budget.sh # only when the sun pays
}
# ---------------------------------------------------------------------------
# The opencode-go. Last resort for context that does not fit, models the van does not
# have, and anything the local boxes refuse. Key never lives in this file.
# ---------------------------------------------------------------------------
endpoint opencode-go {
base https://opencode.ai/zen/go/v1
kind opencode-go
context 200000
priority 90
timeout 900
idle_timeout 120
cache off # never store answers from outside
tls_verify on
api_key_env OPENCODE_API_KEY
}
# ===========================================================================
# Rules. Read top to bottom, first match wins. Everything below is a policy
# decision, so each line says what it is for.
# ===========================================================================
# Metadata calls are cheap and must never wake anything.
req path "/v1/models" check none pass peer-a, peer-b, opencode-go
# Embeddings stay local. No opencode-go fallback: a travelling text does not belong
# in a request to a third party, and the local box has the model.
req for "*embed*" check none pass kitt-embed
# If the CLIENT declares an output budget the peers' 64k cannot hold, they are not a
# candidate. "need" only ever reads max_tokens/max_completion_tokens from the request:
# no character counting, no assumed default — a request that states no budget matches
# this rule not at all, and the router does not pretend to know its size.
req need >65536 pass desk, opencode-go
# Coding work wants the big context local box; the workstation gets woken for it,
# then the peers, then (reluctantly) the opencode-go.
req for "*coder*" check hooks retry 300 pass desk, peer-a, peer-b, opencode-go
# The peers answer to a different id than clients ask for: "as <model>" after a target
# rewrites the model field for THAT target only, so the opencode-go still gets the name the
# client asked for.
req for "Qwen3.8-Flash-Next*" retry 60 pass peer-a, peer-b, opencode-go
# Anything with the local-only prefix never leaves the van, and if the vans own
# boxes are down the request fails loudly instead of going out.
req for "local-only-*" pass peer-a, peer-b
# Cloud-only model ids.
req for "deepseek-*" pass opencode-go
req for "gpt-*" pass opencode-go
# A model that must never be called at all. Refused with 403 and the rule's line
# number, which is the fastest way to answer "why is this not working?".
req for "blocked-*" block
# Everything else: local first. Because a single-model box hangs on an id it does not
# know, the catch-all hands it the id that is really loaded — the client may ask for
# whatever it likes, the van answers with what it has. The opencode-go keeps the client's
# own name and is only reached when nothing local answers.
req for "*" pass peer-a as "Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M", peer-b as "Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M", desk, opencode-go