Schema¶
Pydantic v2 models for request/response objects.
app.schema is now a package that re-exports the public model names for backward-compatible imports such as from app.schema import GenerateRequest. The models themselves are organized by domain submodule:
app.schema.axis— shared axis primitives and payloadsapp.schema.generate— character-description generation and loggingapp.schema.save— save/export/import request and response modelsapp.schema.analysis— signal-isolation and transformation-map modelsapp.schema.chat— chat translation and chat save/import modelsapp.schema.mud— mud-server proxy request and response models
app.schema¶
Domain-organised Pydantic v2 models for the Axis Descriptor Lab API.
This package replaces the previous monolithic app/schema.py module while
preserving the original import surface. Existing imports such as
from app.schema import AxisPayload remain valid because this package
re-exports every public schema name from the domain submodules below.
Submodules¶
axis– shared axis primitives used across multiple endpoints.generate– generate/log request and response models.save– save/import and manifest models.analysis– signal-isolation and transformation-map models.chat– chat translation, chat save, and chat import models.mud– mud-server proxy request and response models.
- class app.schema.AxisPayload(*, axes, policy_hash, seed, world_id)[source]¶
Bases:
BaseModelThe complete deterministic state object that drives a single descriptive generation. This is the “source of truth” handed to the LLM as a JSON string in the user turn.
axes is keyed by axis name (for example, “demeanor”) and stores AxisValue entries. policy_hash captures the SHA-256 digest of the policy rules in force when the payload was produced. seed records the deterministic RNG seed used to produce the scores, and world_id identifies the Pipe-Works world context.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.AxisValue(*, label, score)[source]¶
Bases:
BaseModelA single named axis entry consisting of a human-readable label and a normalised score in [0, 1].
The label is the interpretive colour (e.g. “resentful”, “weary”). The score is the underlying deterministic value produced by the engine. Both are forwarded verbatim to the LLM; the LLM must not treat them as facts – they are tonal hints only.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.ChatCharacterInput(*, axes, ooc_message, channel='say', active_axes=None, character_name=None)[source]¶
Bases:
BaseModelAxis profile and OOC message for a single character in a chat translation request.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.ChatImportResponse(*, folder_name, metadata, character_a=None, character_b=None, system_prompt, game_log_entries=<factory>, model, temperature, max_tokens, seed, manifest_valid, files, warnings=<factory>)[source]¶
Bases:
BaseModelResponse body for
POST /api/import_chat.Contains everything the frontend needs to restore a chat translation session from an uploaded chat save-package zip.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.ChatLogEntry(*, ch, channel, ooc_message=None, ic_text=None, model, ipc_id=None, status='success', error_detail=None, sent_at=None, duration_ms=None, input_hash=None, system_prompt_hash=None, system_prompt=None, output_hash=None)[source]¶
Bases:
BaseModelA single entry in the in-game chat log produced during live mode.
Captured when a per-character Send succeeds. Stored in chatState.gameLog on the frontend and serialised here for server-side persistence.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.ChatSaveRequest(*, entries, character_a=None, character_b=None, character_a_name=None, character_b_name=None, model, temperature=0.7, max_tokens=128, seed, system_prompt=None)[source]¶
Bases:
BaseModelRequest body for POST /api/save_chat.
Saves a complete in-game chat log session to a timestamped folder under the configured writable save root, including optional character payloads and the system prompt.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- entries: list[ChatLogEntry]¶
- class app.schema.ChatSaveResponse(*, folder_name, files, timestamp)[source]¶
Bases:
BaseModelResponse body for POST /api/save_chat.
Returns the save folder name and the list of files written.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.ChatTranslationRequest(*, character_a=None, character_b=None, model, temperature=0.7, max_tokens=128, seed, prompt_name=None, system_prompt=None, ollama_host=None, strict_mode=True, max_output_chars=280, world_id=None)[source]¶
Bases:
BaseModelRequest body for POST /api/translate_chat.
Translates OOC messages for one or two characters using the OOC→IC translation pipeline. Each character’s profile is built from its axes, filtered by active_axes, and rendered into the system prompt template before calling Ollama /api/chat.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- character_a: ChatCharacterInput | None¶
- character_b: ChatCharacterInput | None¶
- class app.schema.ChatTranslationResponse(*, character_a=None, character_b=None)[source]¶
Bases:
BaseModelResponse body for POST /api/translate_chat.
Contains results for Character A and optionally Character B.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- character_a: ChatTranslationResult | None¶
- character_b: ChatTranslationResult | None¶
- class app.schema.ChatTranslationResult(*, ic_text, status, input_hash=None, system_prompt_hash=None, output_hash=None, ipc_id=None, model=None, error_detail=None)[source]¶
Bases:
BaseModelResult for a single character’s OOC→IC translation attempt.
ic_text is None when translation failed (status explains why). The IPC fields form the provenance chain for this translation.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.DeltaRequest(*, baseline_text, current_text)[source]¶
Bases:
BaseModelRequest body for
POST /api/analyze-delta.Accepts two plain-text strings (baseline and current) for signal isolation analysis. The backend runs both through the NLP pipeline (tokenise → lemmatise → filter stopwords) and returns the set difference as sorted word lists.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.DeltaResponse(*, removed, added)[source]¶
Bases:
BaseModelResponse body for
POST /api/analyze-delta.Contains two alphabetically sorted lists of content lemmas that represent meaningful lexical differences between the baseline and current texts, after stopword removal and lemmatisation.
The lists are set differences, not positional diffs:
removed= content lemmas in A but absent from B.added= content lemmas in B but absent from A.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.GenerateRequest(*, payload, model, temperature=0.2, max_tokens=120, system_prompt=None, ollama_host=None)[source]¶
Bases:
BaseModelFull request body for POST /api/generate.
The frontend serialises its current in-memory state into this object and sends it to the backend, which forwards the payload to Ollama.
Optional fields allow the frontend to override per-request settings (model, temperature, token budget, custom system prompt) without restarting the server.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- payload: AxisPayload¶
- class app.schema.GenerateResponse(*, text, model, temperature, usage=None, input_hash=None, system_prompt_hash=None, output_hash=None, ipc_id=None)[source]¶
Bases:
BaseModelResponse body for POST /api/generate.
Carries the raw LLM output plus enough metadata to reconstruct the exact call for logging, diffing, and repeatability analysis.
The four hash fields (
input_hash,system_prompt_hash,output_hash,ipc_id) form the Interpretive Provenance Chain (IPC) — a complete fingerprint of every variable that influenced the generation. Together they enable drift detection and reproducibility audits.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.ImportResponse(*, folder_name, metadata, payload, system_prompt, output=None, baseline=None, model, temperature, max_tokens, manifest_valid, files, warnings=<factory>)[source]¶
Bases:
BaseModelResponse body for
POST /api/import.Contains everything the frontend needs to fully restore session state from an uploaded save-package zip file. The backend parses the zip, validates manifest checksums (if present), and extracts plain text from the Markdown files so the frontend can populate the UI directly without any further parsing.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- payload: AxisPayload¶
- class app.schema.IndicatorConfig(*, compression_ratio=2.0, expansion_ratio=2.0, min_tokens=2, modality_density_threshold=0.3, enabled=None)[source]¶
Bases:
BaseModelOptional tuning parameters for micro-indicator detection.
Sent as an optional field in
TransformationMapRequest. When absent, conservative defaults apply. All thresholds are designed to minimise false positives — users can loosen them for exploratory use.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.LogEntry(*, input_hash, payload, output, model, temperature, max_tokens, timestamp, system_prompt_hash=None, output_hash=None, ipc_id=None)[source]¶
Bases:
BaseModelSchema for a single structured log record written by POST /api/log.
Captures everything needed to reproduce a run and detect drift across repeated calls with the same seed / policy hash. input_hash groups runs that should be identical, payload stores the full deterministic input, and the remaining fields capture the generated output plus the runtime parameters and timestamp needed for later audit or drift analysis.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- payload: AxisPayload¶
- class app.schema.ManifestFileEntry(*, sha256, role, size_bytes)[source]¶
Bases:
BaseModelA single file’s entry in the save-package manifest.
Provides the SHA-256 checksum, role classification, and byte size for one file within a save folder. Used inside the
manifestsection ofmetadata.jsonto make save packages self-describing and verifiable.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudCompileImagePromptRequest(*, world_id, species='goblin', gender='male', axes, world_context=<factory>, occupation_signals=<factory>, model_id=None, aspect_ratio=None, seed=None)[source]¶
Bases:
BaseModelRequest body for
POST /api/mud/compile-image-prompt.This mirrors the mud server’s canonical image compile request while intentionally keeping the surface minimal for the lab’s phase-1 canonical mode.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudImagePolicyBundleResponse(*, world_id, policy_schema=None, policy_bundle_id=None, policy_bundle_version=None, policy_hash, composition_order=<factory>, required_runtime_inputs=<factory>, missing_components=<factory>)[source]¶
Bases:
BaseModelResponse body for
GET /api/mud/world-image-policy-bundle/{world_id}.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudLoginRequest(*, username, password)[source]¶
Bases:
BaseModelRequest body for
POST /api/mud/login.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudLoginResponse(*, authenticated, role=None, message=None)[source]¶
Bases:
BaseModelResponse body for
POST /api/mud/login.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudModeOption(*, key, label, translation_mode, server_url=None)[source]¶
Bases:
BaseModelOne runtime-selectable chat translation mode.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudModeRequest(*, mode_key, server_url=None)[source]¶
Bases:
BaseModelRequest body for
POST /api/mud/mode.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudModeResponse(*, mode_key, translation_mode, active_server_url=None, available_modes)[source]¶
Bases:
BaseModelResponse body for
GETandPOST/api/mud/mode.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- available_modes: list[MudModeOption]¶
- class app.schema.MudPipelineBootstrapResponse(*, world_id, world_summary=<factory>, policy_bundle, policy_source=None, runtime_options=<factory>, required_fields=<factory>)[source]¶
Bases:
BaseModelResponse body for
GET /api/mud/pipeline-build/bootstrap/{world_id}.This aggregated payload keeps the frontend stateless by returning all stage-1 and stage-2 inputs in one call.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- policy_bundle: MudImagePolicyBundleResponse¶
- policy_source: MudPipelinePolicySource | None¶
- runtime_options: MudPipelineRuntimeOptions¶
- class app.schema.MudPipelineGenerateConditionAxisEntityInputs(*, species, identity)[source]¶
Bases:
BaseModelEntity input block for canonical condition-axis generation.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelineGenerateConditionAxisIdentityInputs(*, gender)[source]¶
Bases:
BaseModelIdentity input block for canonical condition-axis generation.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelineGenerateConditionAxisInputs(*, entity)[source]¶
Bases:
BaseModelRuntime inputs wrapper for canonical condition-axis generation.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelineGenerateConditionAxisRequest(*, world_id, seed=None, inputs)[source]¶
Bases:
BaseModelRequest body for
POST /api/mud/pipeline-build/generate-condition-axis.This contract mirrors the mud server canonical route and includes strict runtime identity inputs used by policy validation.
seedmay be omitted (or null) to request server-side random seeding.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelinePolicySource(*, source_kind, source_label, source_path=None, reference=None)[source]¶
Bases:
BaseModelTruthful source metadata for Policy Bundle display surfaces.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- source_kind: Literal['mud_server_canonical', 'local_world', 'lab_only', 'legacy', 'offline', 'unknown']¶
- reference: MudPipelinePolicySourceReference | None¶
- class app.schema.MudPipelinePolicySourceReference(*, world_id, policy_bundle_id=None, policy_bundle_version=None, policy_hash, served_via='/api/mud/pipeline-build/bootstrap/{world_id}')[source]¶
Bases:
BaseModelCanonical reference metadata for one resolved policy source.
This model deliberately avoids filesystem assumptions for remote policy sources. It identifies the policy bundle by deterministic IDs and hashes so UI surfaces can remain truthful across local vs remote environments.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelineResolveRequest(*, world_id, species='goblin', gender='male', axes, world_context=<factory>, occupation_signals=<factory>)[source]¶
Bases:
BaseModelRequest body for
POST /api/mud/pipeline-build/resolve-image-selection.The request intentionally excludes generation-only controls so the response can represent pre-prompt selection/resolve state for stages 5-7.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelineResolveResponse(*, selected_blocks, descriptor_layer=None, tone_profile=None, composition_order=<factory>, policy_hash, axis_hash, compiler_input_hash)[source]¶
Bases:
BaseModelResponse body for
POST /api/mud/pipeline-build/resolve-image-selection.This response intentionally omits the compiled prompt text so stage-5/6/7 UI state can be rendered without coupling to stage-8 side effects.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- selected_blocks: MudPipelineSelectedBlocks¶
- class app.schema.MudPipelineRuntimeOptions(*, species=<factory>, gender=<factory>, world_context_tags=<factory>, occupation_tags=<factory>)[source]¶
Bases:
BaseModelRuntime option sets used by Pipeline Build stage controls.
The bootstrap endpoint uses this model to expose optional selector values without forcing the frontend to infer them from world configuration files.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudPipelineSelectedBlocks(*, species_canon_block=None, clothing_block=<factory>)[source]¶
Bases:
BaseModelSelected block IDs returned by the resolve preview endpoint.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudSelectWorldRequest(*, world_id)[source]¶
Bases:
BaseModelRequest body for
POST /api/mud/select-world.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.MudSessionResponse(*, authenticated, role=None, selected_world_id=None, mode_key, translation_mode, active_server_url=None)[source]¶
Bases:
BaseModelResponse body for
GET /api/mud/session.- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.SaveRequest(*, payload, output=None, baseline=None, payload_name=None, model, temperature=0.2, max_tokens=120, system_prompt, transformation_map=None, diff_change_pct=None)[source]¶
Bases:
BaseModelFull request body for POST /api/save.
The frontend collects all in-memory state at the moment the user clicks Save and sends it here. The backend writes individual files to a timestamped subfolder under the configured writable save root.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- payload: AxisPayload¶
- transformation_map: list[TransformationMapRow] | None¶
- class app.schema.SaveResponse(*, folder_name, files, input_hash, timestamp, system_prompt_hash=None, output_hash=None, ipc_id=None)[source]¶
Bases:
BaseModelResponse body for POST /api/save.
Returns the save folder name and the list of files written so the frontend can display a confirmation message in the status bar.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class app.schema.TransformationMapRequest(*, baseline_text, current_text, include_all=False, indicator_config=None)[source]¶
Bases:
BaseModelRequest body for
POST /api/transformation-map.Accepts two plain-text strings (baseline and current) for clause-level alignment analysis. The backend runs sentence-aware alignment followed by token-level diffing to extract replacement pairs, then classifies each row with structural micro-indicators.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- indicator_config: IndicatorConfig | None¶
- class app.schema.TransformationMapResponse(*, rows)[source]¶
Bases:
BaseModelResponse body for
POST /api/transformation-map.Contains a list of clause-level replacement pairs extracted by sentence-aware alignment and token-level diffing.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- rows: list[TransformationMapRow]¶
- class app.schema.TransformationMapRow(*, removed, added, indicators=<factory>)[source]¶
Bases:
BaseModelA single clause-level replacement pair with optional micro-indicators.
The
indicatorsfield contains zero or more structural pattern labels computed by themicro_indicatorsmodule. Each label is a deterministic heuristic tag such as"compression","embodiment shift", or"intensity ↑".- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].