Files
junction/examples/olivia.conf
T
Hermes Agent c34082f51d junction: threads, a queue, and status lines a parser cannot see
One thread per connection plus max_inflight upstream slots; further requests wait in
line (queue_timeout) instead of being refused. A waiting caller that asked for a
stream is told why it waits with SSE comment lines (': junction: waiting for a free
slot (0 ahead of you)'), which the spec says every parser must ignore — a human
watching curl sees progress, a client sees nothing it could misinterpret. The real
answer then starts in the same stream and the comments simply stop.

Trade-off, stated in the README: a streaming caller gets its 200 before the upstream
is chosen, so a later upstream failure cannot be an HTTP status any more — it travels
as a data: {"error":...} event. Non-streaming callers get nothing injected and keep
their true status code.

Also: cache and endpoint state are locked (they are shared between threads now), and
the test stub forks per connection — a serial stub made a concurrent router look
serialised, which is exactly the kind of test that lies.
2026-10-29 15:01:36 +00:00

170 lines
6.9 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 cloud. 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 cloud {
base https://opencode.ai/zen/go/v1
kind cloud
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, cloud
# Embeddings stay local. No cloud 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, cloud
# Coding work wants the big context local box; the workstation gets woken for it,
# then the peers, then (reluctantly) the cloud.
req for "*coder*" check hooks retry 300 pass desk, peer-a, peer-b, cloud
# 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 cloud still gets the name the
# client asked for.
req for "Qwen3.8-Flash-Next*" retry 60 pass peer-a, peer-b, cloud
# 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 cloud
req for "gpt-*" pass cloud
# 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 cloud 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, cloud