mud_server.translation.config
Translation layer configuration.
TranslationLayerConfig is a frozen dataclass that mirrors the
translation_layer block inside each world’s world.json. It is
loaded once when the World is initialised and never mutated at runtime.
Configuration precedence (locked)
If server-level
ollama_translation.enabled = false→ translation is OFF globally (enforced in World._init_translation_service).Else if world.json
translation_layer.enabled = true→ translation is ON for that world.Otherwise → OFF.
World config may override individual field values (model, timeout, etc.), but it cannot override the server master switch.
Deterministic mode
When deterministic = true the renderer will clamp temperature to 0.0
and use an integer seed derived from the IPC hash.
IPC hash sourcing (FUTURE — axis engine integration)
Currently translate() accepts an optional ipc_hash: str | None
parameter. When it is None (the default) deterministic mode is
skipped even if deterministic = true in config, because there is no
seed available yet.
Once the axis engine is built and integrated, it will call:
ipc_hash = axis_engine.compute_ipc(world_id, entity_a, entity_b, turn)
and pass that hash to service.translate(..., ipc_hash=ipc_hash). At
that point deterministic mode will activate automatically when
deterministic = true and the hash is provided.
See _working/translation_layer/ooc_ic_translator_design_principles.md
section 3 (Determinism Mode) for the full specification.
Classes
Immutable, world-scoped configuration for the OOC→IC translation layer. |
Module Contents
- class mud_server.translation.config.TranslationLayerConfig[source]
Immutable, world-scoped configuration for the OOC→IC translation layer.
Loaded from the
translation_layerblock in a world’sworld.jsonand frozen after construction so that no runtime code can mutate it.- enabled
Master switch. If
Falsethe service will not be instantiated and the layer is inactive.
- model
Ollama model tag (e.g.
"gemma2:2b").
- ollama_base_url
Base URL of the running Ollama instance. The
/api/chatpath is appended automatically.
- timeout_seconds
HTTP request timeout for Ollama calls. On expiry the service returns
Noneand the caller falls back to the OOC message.
- keep_alive
Ollama
keep_aliveduration string. Controls how long the model stays loaded in GPU/CPU memory after each request (e.g."5m"). Prevents cold-start reloads between consecutive requests.
- strict_mode
When
True, any non-compliant LLM output (multi-line, forbidden patterns, over-length) triggers an immediate fallback rather than a best-effort cleanup.
- max_output_chars
Hard ceiling on IC output length. Responses exceeding this are rejected (strict) or truncated (non-strict).
- prompt_policy_id
Canonical prompt policy id selector used for runtime resolution (for example
prompt:translation.prompts.ic:default).
- active_axes
Subset of axis names to include in the character profile sent to the LLM. An empty list means “all axes that exist for this character”.
- deterministic
When
Trueand a non-Noneipc_hashis provided totranslate(), the renderer will usetemperature=0.0and a seed derived from the IPC hash. See module docstring for IPC sourcing status.
- classmethod from_dict(data, *, world_root)[source]
Parse a
translation_layerconfig block fromworld.json.Missing optional fields fall back to safe defaults so that a minimal
{"enabled": true}block is sufficient for basic operation.- Parameters:
data (dict) – The
translation_layerdict fromworld.json.world_root (pathlib.Path) – Passed for future use (e.g. resolving relative paths at parse time). Currently unused at construction but kept in the signature to avoid a breaking change later.
- Returns:
A fully-populated, frozen
TranslationLayerConfig.- Return type: