Codebase Reference
High-Level Overview
This codebase is a full-stack simulation platform centered on a Python backend package, with a React frontend and Mongo-backed persistence. Reporting, analysis, and admin tooling lives in dcs_utils, and run/game/experiment configuration is primarily YAML-driven.
The main runtime entry point is the Typer CLI and the FastAPI app factory in dcs_simulation_engine/api/app.py. The React frontend is optional; the engine runtime is the API server.
Design Considerations
This repository is organized as a monorepo so the engine, frontend, docs, examples, tests, and operational tooling can evolve together. Keeping these pieces in one place reduces version skew between the API, UI, run configurations, and evaluation workflows, which matters because DCS use cases (research workflows for AI and CogSci, etc.) depend on all of them staying aligned.
The backend is asynchronous and WebSocket-driven because gameplay shouldn't be limited to turn-based synchronous interactions. It is event-based, latency-sensitive, and often concurrent across human and AI players. Async I/O keeps the API responsive when it is handling persistence, model calls, or other external work, while WebSockets let the server stream state updates during a session instead of forcing a request/response loop.
The React frontend is optional by design. The engine exposes an API endpoint so the same runtime can support the built-in UI, custom clients, automated agents, and non-visual integrations. The default frontend and Fly.io deployment path make the project easy to start quickly, but the containerized runtime keeps it portable for other deployment targets.
The HITL pipeline exists because characters are treated as artifacts that need iterative evaluation, not static content. It gives developers a repeatable way to generate scenarios, inspect behavior, and refine character sheets before promotion.
The character release policy enforces quality thresholds before characters are promoted to production. Evaluations are fingerprinted to the character + model + prompt configuration, so material changes require re-evaluation of role-playing simulation quality. This keeps low-quality or under-evaluated characters out of the default database and makes the promotion process explicit and reviewable.
Run harnessing is provided to support repeatable AI evaluation workflows. Like other benchmarking frameworks, it standardizes orchestration across common providers. We support models from OpenRouter and Hugging Face by default so model runs can be executed consistently and compared with less setup overhead.
Run configurations are intentionally only as configurable as needed to support internal use cases. This keeps the configuration surface manageable and testable; exposing every possible toggle would create a combinatorial space that is difficult to reason about and validate, making engine quality and robustness harder to maintain. The goal is minimal configuration for common workflows, with extension points for cases that genuinely need customization. The examples/ folder contains the DCS group's internal configurations and serves as the primary functional test surface for run configuration behavior.
The CLI design intentionally departs from strict noun-verb command conventions to support a mixed user base of AI researchers and less technical operators. Common engine operations are exposed as simple commands for local and remote runs (start, status, save, stop) plus basic report generation, while advanced workflows are grouped under admin subcommands (for example, server and database management, HITL pipelines, and related tooling). This keeps advanced capabilities available without overwhelming users who only need core run operations.
The architecture also leaves room for future interaction patterns and client modalities. Because the engine is built around session state, event streaming, and a clean client/server boundary, it can support richer multi-turn behavior and additional frontends without restructuring the core runtime.
As a design trade-off, we prioritize Python for research velocity, readability, and ease of extension, accepting that peak throughput may be lower than in lower-level implementations and may require scaling or optimization for high-load deployments.
Repo Structure
├── database_seeds # seed data (characters and related collections)
├── dcs_simulation_engine
│ ├── core # core engine components (e.g. session manager)
│ ├── dal # data access layer for MongoDB
│ ├── deployments # fly deployment assets (toml files)
│ ├── games # core games
│ ├── infra #...
├── dcs_utils # reporting/analysis/admin tooling
├── ui # React + Bun frontend
├── docs
├── docker
├── examples
├── tests
├── character-release-policy.yml
Main Components
⚠️ This section needs completion.
The backend API layer dcs_simulation_engine/api/app.py ...hands off work between ...
SessionManager in dcs_simulation_engine/core manages the gameplay sessions.
SessionRegistry
EngineRunManager ...
Data Flow
⚠️ This section needs completion.
At a high level, the system lets a player start a text-based “game” against a simulated character, routes each turn through a game engine implementation, optionally calls an LLM-backed AI client to generate or validate responses, persists the transcript and session metadata to MongoDB, and streams events back to the browser over WebSockets.
For running the engine, the flow is:
-
Startup begins in the CLI calls the
create_appfunction indcs_simulation_engine/api/app.py -
When a session starts, the API enforces auth and returns allowed games, characters and run state.
-
On WebSocket connection (), the server calls the
SessionManager.step_async()to create the opening scene of a game. -
Each message by the player and/or simulator is recorded as an event by
SessionEventRecorder... -
On termination, the session is finalized in Mongo with the exit reason, turn count, and last sequence number.
For normal gameplay, the flow is: 1. The browser loads the frontend and fetches ...
-
The player registers/authenticates through ...
-
The player opens a game setup page
/api/play/setup/{game}and the backend loads the game config, queries the data layer for valid characters and returns allowed PC/NPC choices. -
The UI POSTs
/api/play/gameand callsSessionManagerwhich constructs a session object around that game. -
The new session is inserted into the in-memory
SessionRegistry
DCS-SE Codebase Reference
dcs_simulation_engine
DCS Simulation Engine package.
api
FastAPI server surface for programmatic DCS access.
create_app(*, provider=None, mongo_uri=None, shutdown_dump_dir=None, server_mode='standard', default_experiment_name=None, remote_management_enabled=False, bootstrap_token=None, session_ttl_seconds=DEFAULT_SESSION_TTL_SECONDS, sweep_interval_seconds=DEFAULT_SWEEP_INTERVAL_SECONDS, cors_origins=None)
Create and configure the FastAPI server application.
Source code in dcs_simulation_engine/api/app.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
app
FastAPI application factory for the DCS server.
create_app(*, provider=None, mongo_uri=None, shutdown_dump_dir=None, server_mode='standard', default_experiment_name=None, remote_management_enabled=False, bootstrap_token=None, session_ttl_seconds=DEFAULT_SESSION_TTL_SECONDS, sweep_interval_seconds=DEFAULT_SWEEP_INTERVAL_SECONDS, cors_origins=None)
Create and configure the FastAPI server application.
Source code in dcs_simulation_engine/api/app.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
auth
Authentication and app-state access helpers for the FastAPI API layer.
api_key_from_request(request)
Extract api_key from Authorization: Bearer header.
Source code in dcs_simulation_engine/api/auth.py
137 138 139 | |
api_key_from_websocket(websocket)
Extract api_key from Authorization: Bearer header on a WebSocket.
Source code in dcs_simulation_engine/api/auth.py
142 143 144 | |
authenticate_player(*, provider, api_key)
Return the player for a raw API key, or None if invalid.
Source code in dcs_simulation_engine/api/auth.py
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
authenticate_player_async(*, provider, api_key)
async
Async variant of authenticate_player that supports sync/async providers.
Source code in dcs_simulation_engine/api/auth.py
170 171 172 173 174 175 176 177 178 179 180 181 182 | |
build_server_config(*, server_mode, default_experiment_name=None)
Translate the active mode into frontend-readable capability flags.
Source code in dcs_simulation_engine/api/auth.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
get_default_experiment_name_from_request(request)
Fetch the configured default experiment name from app state for an HTTP request.
Source code in dcs_simulation_engine/api/auth.py
48 49 50 | |
get_default_experiment_name_from_websocket(websocket)
Fetch the configured default experiment name from app state for a websocket.
Source code in dcs_simulation_engine/api/auth.py
53 54 55 | |
get_provider_from_request(request)
Fetch the data provider stored on app state for an HTTP request.
Source code in dcs_simulation_engine/api/auth.py
18 19 20 | |
get_provider_from_websocket(websocket)
Fetch the data provider stored on app state for a WebSocket connection.
Source code in dcs_simulation_engine/api/auth.py
28 29 30 | |
get_registry_from_request(request)
Fetch the session registry stored on app state for an HTTP request.
Source code in dcs_simulation_engine/api/auth.py
23 24 25 | |
get_registry_from_websocket(websocket)
Fetch the session registry stored on app state for a WebSocket connection.
Source code in dcs_simulation_engine/api/auth.py
33 34 35 | |
get_server_mode_from_request(request)
Fetch the configured server mode from app state for an HTTP request.
Source code in dcs_simulation_engine/api/auth.py
38 39 40 | |
get_server_mode_from_websocket(websocket)
Fetch the configured server mode from app state for a WebSocket connection.
Source code in dcs_simulation_engine/api/auth.py
43 44 45 | |
has_remote_admin_async(*, provider)
async
Return True when any player currently holds the remote admin role.
Source code in dcs_simulation_engine/api/auth.py
119 120 121 122 123 124 | |
is_remote_admin(player)
Return True when the player carries the remote admin role.
Source code in dcs_simulation_engine/api/auth.py
114 115 116 | |
is_remote_management_enabled_from_request(request)
Return whether the app is running in remote-managed mode for this request.
Source code in dcs_simulation_engine/api/auth.py
58 59 60 | |
is_remote_management_enabled_from_websocket(websocket)
Return whether the app is running in remote-managed mode for this websocket.
Source code in dcs_simulation_engine/api/auth.py
63 64 65 | |
require_player(*, provider, api_key)
Return authenticated player or raise a 401 HTTPException.
Source code in dcs_simulation_engine/api/auth.py
162 163 164 165 166 167 | |
require_player_async(*, provider, api_key)
async
Return authenticated player or raise 401 for sync/async providers.
Source code in dcs_simulation_engine/api/auth.py
185 186 187 188 189 190 | |
require_remote_admin_async(*, provider, api_key)
async
Return the authenticated remote admin player or raise 403.
Source code in dcs_simulation_engine/api/auth.py
193 194 195 196 197 198 | |
require_remote_management_from_request(request, *, detail)
Raise a 409 when remote-management-only endpoints are used outside remote mode.
Source code in dcs_simulation_engine/api/auth.py
108 109 110 111 | |
require_standard_mode(*, server_mode, detail)
Raise a 409 when an endpoint is disabled in free-play mode.
Source code in dcs_simulation_engine/api/auth.py
97 98 99 100 | |
require_standard_mode_from_request(request, *, detail)
Ensure an HTTP endpoint is only used while the server runs in standard mode.
Source code in dcs_simulation_engine/api/auth.py
103 104 105 | |
resolve_remote_deployment_mode(*, server_mode, default_experiment_name)
Collapse app state into a public deployment mode for remote status.
Source code in dcs_simulation_engine/api/auth.py
84 85 86 87 88 89 90 91 92 93 94 | |
client
Python client wrapper for the DCS FastAPI server.
Provides APIClient and SimulationRun for ergonomic use in research scripts.
APIClient
Client for the DCS FastAPI server.
Source code in dcs_simulation_engine/api/client.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
__enter__()
Enter the context manager.
Source code in dcs_simulation_engine/api/client.py
155 156 157 | |
__exit__(exc_type, exc_val, exc_tb)
Exit the context manager, closing the HTTP client.
Source code in dcs_simulation_engine/api/client.py
159 160 161 | |
__init__(url='http://localhost:8080', api_key='', timeout=30.0)
Initialize the API client with a base URL, default API key, and request timeout.
Source code in dcs_simulation_engine/api/client.py
145 146 147 148 149 | |
auth(*, api_key=None)
Validate an API key and return player_id + authenticated.
Source code in dcs_simulation_engine/api/client.py
167 168 169 170 171 | |
close()
Close the underlying HTTP client transport.
Source code in dcs_simulation_engine/api/client.py
151 152 153 | |
create_character(body)
Create a new character. Returns character_id.
Source code in dcs_simulation_engine/api/client.py
216 217 218 | |
delete_character(character_id)
Delete a character by id. Returns character_id.
Source code in dcs_simulation_engine/api/client.py
224 225 226 | |
health()
Check server liveness.
Source code in dcs_simulation_engine/api/client.py
248 249 250 251 252 | |
list_characters()
List available characters.
Source code in dcs_simulation_engine/api/client.py
212 213 214 | |
list_games()
List available games.
Source code in dcs_simulation_engine/api/client.py
208 209 210 | |
list_sessions(*, api_key=None)
List active in-memory sessions for the authenticated player.
Source code in dcs_simulation_engine/api/client.py
177 178 179 180 181 182 183 184 185 186 187 | |
register_player(body)
Register a new player and return player_id + api_key.
Source code in dcs_simulation_engine/api/client.py
163 164 165 | |
request_infer_intent_evaluation(session_id, *, api_key=None)
Generate or fetch the cached Infer Intent evaluation for one completed session.
Source code in dcs_simulation_engine/api/client.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
server_config()
Fetch server capability flags for the active runtime mode.
Source code in dcs_simulation_engine/api/client.py
173 174 175 | |
setup_options(*, game_name, api_key=None)
Fetch setup authorization and valid character choices for a game.
Source code in dcs_simulation_engine/api/client.py
234 235 236 237 238 239 240 241 242 243 244 245 246 | |
start_game(body)
Create a new simulation session and return a SimulationRun.
Source code in dcs_simulation_engine/api/client.py
228 229 230 231 232 | |
update_character(character_id, body)
Update an existing character by id. Returns character_id.
Source code in dcs_simulation_engine/api/client.py
220 221 222 | |
SimulationRun
Lightweight wrapper around an active server-side simulation session.
Source code in dcs_simulation_engine/api/client.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
history
property
All WSEventFrames received so far, in order.
is_complete
property
True if the simulation has reached an exit condition.
simulator_output
property
Content of the latest AI event, if any.
turns
property
Number of completed turns, or 0 if no turn has ended yet.
__enter__()
Enter the context manager.
Source code in dcs_simulation_engine/api/client.py
59 60 61 | |
__exit__(exc_type, exc_val, exc_tb)
Exit the context manager, closing the session silently on error.
Source code in dcs_simulation_engine/api/client.py
63 64 65 66 67 68 | |
__init__(client, session_id, game_name, api_key)
Initialize a SimulationRun bound to an existing server-side session.
Source code in dcs_simulation_engine/api/client.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
close()
Close the server-side session.
Source code in dcs_simulation_engine/api/client.py
109 110 111 112 113 114 115 116 | |
get_state()
Fetch current session status without advancing a turn.
Source code in dcs_simulation_engine/api/client.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
step(user_input='')
Advance the simulation by one step.
Source code in dcs_simulation_engine/api/client.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
infer_intent_evaluation
Helpers for generating or loading Infer Intent evaluations from persisted sessions.
InferIntentEvaluationUnavailableError
Bases: ValueError
Raised when a requested Infer Intent evaluation cannot be produced.
Source code in dcs_simulation_engine/api/infer_intent_evaluation.py
24 25 | |
extract_infer_intent_scoring_inputs(events)
Rebuild the transcript and saved player intent prediction from persisted session events.
Source code in dcs_simulation_engine/api/infer_intent_evaluation.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
generate_or_get_infer_intent_evaluation(*, provider, session_id, player_id, condition=None)
async
Return a cached Infer Intent evaluation or generate and persist it once.
Source code in dcs_simulation_engine/api/infer_intent_evaluation.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
models
Pydantic models and payload parsers for the API layer.
AuthRequest
Bases: BaseModel
Payload for API-key authentication checks.
Source code in dcs_simulation_engine/api/models.py
36 37 38 39 | |
AuthResponse
Bases: BaseModel
Response payload for successful API-key auth.
Source code in dcs_simulation_engine/api/models.py
42 43 44 45 46 47 | |
CharacterChoice
Bases: BaseModel
A selectable character option for setup screens.
Source code in dcs_simulation_engine/api/models.py
106 107 108 109 110 | |
CharacterSummary
Bases: BaseModel
A single character entry.
Source code in dcs_simulation_engine/api/models.py
413 414 415 416 417 | |
CharactersListResponse
Bases: BaseModel
Response payload for characters list endpoint.
Source code in dcs_simulation_engine/api/models.py
420 421 422 423 | |
ClearSessionEventFeedbackResponse
Bases: BaseModel
Response payload after feedback is removed from a session event.
Source code in dcs_simulation_engine/api/models.py
283 284 285 286 287 288 | |
CreateGameRequest
Bases: BaseModel
Payload for creating a new gameplay session.
Source code in dcs_simulation_engine/api/models.py
88 89 90 91 92 93 94 95 | |
CreateGameResponse
Bases: BaseModel
Response payload for newly created sessions.
Source code in dcs_simulation_engine/api/models.py
98 99 100 101 102 103 | |
DeleteCharacterResponse
Bases: BaseModel
Response payload after deletion.
Source code in dcs_simulation_engine/api/models.py
439 440 441 442 | |
EligibleAssignmentOption
Bases: BaseModel
One eligible game+character option returned in player_choice mode.
Source code in dcs_simulation_engine/api/models.py
175 176 177 178 179 | |
EligibleAssignmentOptionsResponse
Bases: BaseModel
List of eligible assignment options for a player in player_choice mode.
Source code in dcs_simulation_engine/api/models.py
182 183 184 185 | |
ExperimentAssignmentSummary
Bases: BaseModel
Assignment summary returned by experiment endpoints.
Source code in dcs_simulation_engine/api/models.py
125 126 127 128 129 130 131 | |
ExperimentGameStatusResponse
Bases: BaseModel
Per-game status counts for an experiment.
Source code in dcs_simulation_engine/api/models.py
142 143 144 145 146 147 | |
ExperimentPlayerRequest
Bases: BaseModel
Entry-form payload for experiment registration.
Source code in dcs_simulation_engine/api/models.py
195 196 197 198 | |
ExperimentPlayerResponse
Bases: BaseModel
Assignment response after an authenticated player submits before-play forms.
Source code in dcs_simulation_engine/api/models.py
201 202 203 204 | |
ExperimentPostPlayRequest
Bases: BaseModel
Payload for storing experiment post-play form answers.
Source code in dcs_simulation_engine/api/models.py
213 214 215 216 | |
ExperimentProgressResponse
Bases: BaseModel
Finite progress payload for the usability experiment.
Source code in dcs_simulation_engine/api/models.py
134 135 136 137 138 139 | |
ExperimentSessionRequest
Bases: BaseModel
Payload for creating a session from the current assignment.
Source code in dcs_simulation_engine/api/models.py
207 208 209 210 | |
ExperimentSetupResponse
Bases: BaseModel
Setup payload for the experiment landing page.
Source code in dcs_simulation_engine/api/models.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
ExperimentStatusResponse
Bases: BaseModel
Aggregate status payload for an experiment.
Source code in dcs_simulation_engine/api/models.py
150 151 152 153 154 155 156 | |
GameSetupOptionsResponse
Bases: BaseModel
Preflight setup data for a specific game + authenticated player.
Source code in dcs_simulation_engine/api/models.py
113 114 115 116 117 118 119 120 121 122 | |
GameSummary
Bases: BaseModel
A single game entry.
Source code in dcs_simulation_engine/api/models.py
399 400 401 402 403 404 | |
GamesListResponse
Bases: BaseModel
Response payload for games list endpoint.
Source code in dcs_simulation_engine/api/models.py
407 408 409 410 | |
InferIntentEvaluation
Bases: BaseModel
Parsed Infer Intent evaluation payload returned by the scorer.
Source code in dcs_simulation_engine/api/models.py
237 238 239 240 241 242 | |
InferIntentEvaluationResponse
Bases: BaseModel
Response payload for the cached-or-generated Infer Intent evaluation.
Source code in dcs_simulation_engine/api/models.py
245 246 247 248 249 250 251 | |
RegistrationRequest
Bases: BaseModel
Payload for creating a new player and issuing an API key.
Source code in dcs_simulation_engine/api/models.py
19 20 21 22 23 24 25 26 | |
RegistrationResponse
Bases: BaseModel
Response payload for registration.
Source code in dcs_simulation_engine/api/models.py
29 30 31 32 33 | |
RemoteBootstrapResponse
Bases: BaseModel
Bootstrap response containing the newly issued remote admin key.
Source code in dcs_simulation_engine/api/models.py
68 69 70 71 72 73 | |
RemoteStatusResponse
Bases: BaseModel
Public status payload for remote-managed or generic deployments.
Source code in dcs_simulation_engine/api/models.py
76 77 78 79 80 81 82 83 84 85 | |
SelectAssignmentRequest
Bases: BaseModel
Payload for player-directed assignment selection.
Source code in dcs_simulation_engine/api/models.py
188 189 190 191 192 | |
ServerConfigResponse
Bases: BaseModel
Response payload describing server capabilities for the active mode.
Source code in dcs_simulation_engine/api/models.py
50 51 52 53 54 55 56 57 | |
SessionEventFeedback
Bases: BaseModel
Stored reaction, comment, and issue flags attached to one assistant message.
Source code in dcs_simulation_engine/api/models.py
254 255 256 257 258 259 260 261 262 | |
SessionSummary
Bases: BaseModel
A single in-memory session summary for list responses.
Source code in dcs_simulation_engine/api/models.py
219 220 221 222 223 224 225 226 227 228 | |
SessionsListResponse
Bases: BaseModel
Response payload for session list endpoint.
Source code in dcs_simulation_engine/api/models.py
231 232 233 234 | |
StatusResponse
Bases: BaseModel
Response payload describing process liveness and uptime.
Source code in dcs_simulation_engine/api/models.py
60 61 62 63 64 65 | |
SubmitSessionEventFeedbackRequest
Bases: BaseModel
Payload for storing feedback on a single assistant session event.
Source code in dcs_simulation_engine/api/models.py
265 266 267 268 269 270 271 272 | |
SubmitSessionEventFeedbackResponse
Bases: BaseModel
Response payload after feedback is stored on a session event.
Source code in dcs_simulation_engine/api/models.py
275 276 277 278 279 280 | |
UpsertCharacterRequest
Bases: BaseModel
Payload for creating or updating a character.
Source code in dcs_simulation_engine/api/models.py
426 427 428 429 430 | |
UpsertCharacterResponse
Bases: BaseModel
Response payload after upsert.
Source code in dcs_simulation_engine/api/models.py
433 434 435 436 | |
WSAdvanceRequest
Bases: BaseModel
WebSocket frame for advancing the game.
Source code in dcs_simulation_engine/api/models.py
298 299 300 301 302 | |
WSAuthRequest
Bases: BaseModel
WebSocket first-message auth frame (browser clients only).
Source code in dcs_simulation_engine/api/models.py
291 292 293 294 295 | |
WSCloseRequest
Bases: BaseModel
WebSocket frame for closing a session.
Source code in dcs_simulation_engine/api/models.py
311 312 313 314 | |
WSClosedFrame
Bases: BaseModel
WebSocket frame indicating session closure.
Source code in dcs_simulation_engine/api/models.py
359 360 361 362 363 | |
WSErrorFrame
Bases: BaseModel
WebSocket frame describing a protocol or auth error.
Source code in dcs_simulation_engine/api/models.py
366 367 368 369 370 | |
WSEventFrame
Bases: BaseModel
WebSocket frame representing a single game event.
Source code in dcs_simulation_engine/api/models.py
330 331 332 333 334 335 336 337 | |
WSReplayEndFrame
Bases: BaseModel
WebSocket frame signaling the end of a historical event replay burst.
Source code in dcs_simulation_engine/api/models.py
391 392 393 394 395 396 | |
WSReplayEventFrame
Bases: BaseModel
WebSocket frame carrying one historical event during replay.
Source code in dcs_simulation_engine/api/models.py
380 381 382 383 384 385 386 387 388 | |
WSReplayStartFrame
Bases: BaseModel
WebSocket frame signaling the start of a historical event replay burst.
Source code in dcs_simulation_engine/api/models.py
373 374 375 376 377 | |
WSSessionMetaFrame
Bases: BaseModel
WebSocket frame sent once after auth, carrying session metadata.
Source code in dcs_simulation_engine/api/models.py
320 321 322 323 324 325 326 327 | |
WSStatusFrame
Bases: BaseModel
WebSocket frame reporting current session status.
Source code in dcs_simulation_engine/api/models.py
349 350 351 352 353 354 355 356 | |
WSStatusRequest
Bases: BaseModel
WebSocket frame for requesting session status.
Source code in dcs_simulation_engine/api/models.py
305 306 307 308 | |
WSTurnEndFrame
Bases: BaseModel
WebSocket frame emitted at the end of each completed turn.
Source code in dcs_simulation_engine/api/models.py
340 341 342 343 344 345 346 | |
parse_ws_auth(raw)
Parse a first-message auth frame. Returns None if not an auth message.
Source code in dcs_simulation_engine/api/models.py
445 446 447 448 449 450 451 452 453 454 455 456 | |
parse_ws_request(raw)
Parse and validate a raw JSON websocket request payload.
Source code in dcs_simulation_engine/api/models.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
registry
In-memory session registry with TTL cleanup for FastAPI server sessions.
SessionEntry
dataclass
Represents one in-memory API session record.
Source code in dcs_simulation_engine/api/registry.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
touch()
Refresh the last-activity timestamp.
Source code in dcs_simulation_engine/api/registry.py
33 34 35 | |
SessionRegistry
Thread-safe in-memory session store with async TTL sweeping.
Source code in dcs_simulation_engine/api/registry.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
size
property
Current number of live session entries.
__init__(*, ttl_seconds=3600, sweep_interval_seconds=60)
Initialize registry settings and empty storage.
Source code in dcs_simulation_engine/api/registry.py
41 42 43 44 45 46 47 48 49 50 51 52 | |
add(*, player_id, game_name, manager, experiment_name=None, assignment_id=None)
Create and store a new session entry.
Source code in dcs_simulation_engine/api/registry.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
close(session_id)
Mark a session as closed but keep it until explicit removal/TTL expiry.
Source code in dcs_simulation_engine/api/registry.py
128 129 130 131 132 133 134 135 | |
get(session_id)
Get a session entry by id, or None if it does not exist.
Source code in dcs_simulation_engine/api/registry.py
78 79 80 81 | |
list_for_player(player_id)
List sessions owned by a specific player, newest first.
Source code in dcs_simulation_engine/api/registry.py
83 84 85 86 87 | |
mark_opening_sent(session_id)
Mark that the opening turn has already been sent.
Source code in dcs_simulation_engine/api/registry.py
96 97 98 99 100 101 | |
pause(session_id)
Mark a session as paused; keep it and its manager alive for resume.
Source code in dcs_simulation_engine/api/registry.py
103 104 105 106 107 108 109 110 | |
remove(session_id)
Remove and return a session entry if it exists.
Source code in dcs_simulation_engine/api/registry.py
137 138 139 140 141 142 143 | |
set_active(session_id)
Mark a paused session as active again after a successful reconnect.
Source code in dcs_simulation_engine/api/registry.py
112 113 114 115 116 117 118 119 | |
set_ws_connected(session_id, connected)
Update the WebSocket connection flag for a session.
Source code in dcs_simulation_engine/api/registry.py
121 122 123 124 125 126 | |
start()
async
Start background TTL sweeping if it is not already running.
Source code in dcs_simulation_engine/api/registry.py
169 170 171 172 173 | |
stop()
async
Stop the background TTL sweeper task.
Source code in dcs_simulation_engine/api/registry.py
175 176 177 178 179 180 181 182 | |
sweep_async()
async
Async sweep variant that awaits async session finalization when available.
Source code in dcs_simulation_engine/api/registry.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
touch(session_id)
Refresh a session's idle timer if present.
Source code in dcs_simulation_engine/api/registry.py
89 90 91 92 93 94 | |
routers
API router exports.
catalog
HTTP endpoints for listing, creating, updating, and deleting games and characters.
create_character(body, request)
async
Create a new character.
Source code in dcs_simulation_engine/api/routers/catalog.py
35 36 37 38 39 40 | |
delete_character(character_id, request)
async
Delete a character by id.
Source code in dcs_simulation_engine/api/routers/catalog.py
55 56 57 58 59 60 61 62 63 | |
list_characters_endpoint(request)
async
List available characters.
Source code in dcs_simulation_engine/api/routers/catalog.py
26 27 28 29 30 31 32 | |
list_games_endpoint()
List available games.
Source code in dcs_simulation_engine/api/routers/catalog.py
19 20 21 22 23 | |
update_character(character_id, body, request)
async
Update an existing character.
Source code in dcs_simulation_engine/api/routers/catalog.py
43 44 45 46 47 48 49 50 51 52 | |
experiments
Experiment-scoped endpoints for assignment-driven study flows.
create_experiment_session(experiment_name, body, request)
async
Create a session for the authenticated player's current experiment assignment.
Source code in dcs_simulation_engine/api/routers/experiments.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
experiment_progress(experiment_name, request)
async
Return the current finite progress for the usability experiment.
Source code in dcs_simulation_engine/api/routers/experiments.py
212 213 214 215 216 217 218 219 220 221 222 223 224 | |
experiment_setup(experiment_name, request)
async
Return experiment metadata, form schemas, and current player assignment state.
Source code in dcs_simulation_engine/api/routers/experiments.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
experiment_status(experiment_name, request)
async
Return the current aggregate status for one experiment.
Source code in dcs_simulation_engine/api/routers/experiments.py
274 275 276 277 278 279 280 281 282 283 284 285 286 | |
get_eligible_options(experiment_name, request)
async
Return eligible game/character pairs for the authenticated player in player_choice mode.
Source code in dcs_simulation_engine/api/routers/experiments.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
register_experiment_player(experiment_name, body, request)
async
Store before-play experiment forms for the authenticated participant and generate an assignment.
Source code in dcs_simulation_engine/api/routers/experiments.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
select_assignment(experiment_name, body, request)
async
Create an assignment for the authenticated player based on their explicit game/character selection.
Source code in dcs_simulation_engine/api/routers/experiments.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
submit_experiment_post_play(experiment_name, body, request)
async
Store the experiment post-play form on the latest completed assignment.
Source code in dcs_simulation_engine/api/routers/experiments.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
play
Gameplay session creation and WebSocket interaction endpoints.
create_game(body, request)
async
Create a session-owned game instance and return websocket connect info.
Source code in dcs_simulation_engine/api/routers/play.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
play_ws(websocket, session_id)
async
WebSocket endpoint for game play requests and streamed turn events.
Source code in dcs_simulation_engine/api/routers/play.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
setup_options(game_name, request)
async
Return setup-ready authorization and valid character choices for a game.
Source code in dcs_simulation_engine/api/routers/play.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
remote
Remote deployment bootstrap, status, and export endpoints.
bootstrap_remote_deployment(request)
async
Seed the uploaded database snapshot and provision the remote admin access key.
Source code in dcs_simulation_engine/api/routers/remote.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
export_remote_database(request, format='tar.gz')
async
Stream an archive of the current database state to the remote admin.
Source code in dcs_simulation_engine/api/routers/remote.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
remote_status(request)
async
Return a public status summary for remote-managed experiment deployments.
Source code in dcs_simulation_engine/api/routers/remote.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
sessions
HTTP endpoints for listing in-memory API sessions.
clear_session_event_feedback(session_id, event_id, request)
async
Remove feedback from one persisted NPC-message event.
Source code in dcs_simulation_engine/api/routers/sessions.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
get_session_reconstruction(session_id, request)
async
Return complete persisted metadata + event stream for transcript replay.
Source code in dcs_simulation_engine/api/routers/sessions.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
get_session_status(session_id, request)
async
Return the current status of a session. Works in both standard and free-play modes.
Used by the frontend to verify a stored session_id is still paused and resumable.
Source code in dcs_simulation_engine/api/routers/sessions.py
73 74 75 76 77 78 79 80 81 82 83 84 | |
list_sessions(request)
async
List active in-memory sessions for the player tied to the provided API key.
Source code in dcs_simulation_engine/api/routers/sessions.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
request_infer_intent_evaluation(session_id, request)
async
Return a cached Infer Intent evaluation or generate and persist it on first request.
Source code in dcs_simulation_engine/api/routers/sessions.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
submit_session_event_feedback(session_id, event_id, body, request)
async
Store or overwrite feedback on one persisted NPC-message event.
Source code in dcs_simulation_engine/api/routers/sessions.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
users
Player registration, auth, and management endpoints.
auth_user(body, request)
async
Authenticate a user API key and return the associated player id.
Source code in dcs_simulation_engine/api/routers/users.py
110 111 112 113 114 115 116 117 118 119 120 | |
register_user(body, request)
async
Register a new player record and return a newly issued API key.
Source code in dcs_simulation_engine/api/routers/users.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
cli
CLI package.
app
Root cli app wiring.
main(ctx, quiet=typer.Option(False, '--quiet', '-q', help='Suppress non-error output.'), verbose=typer.Option(0, '-v', '--verbose', count=True, help='Increase verbosity: -v for INFO, -vv for DEBUG.'), yes=typer.Option(False, '--yes', '-y', help='Assume "yes" for all prompts (non-interactive mode).'), config=typer.Option(None, '--config', help='Optional global config file.', exists=False, dir_okay=False, file_okay=True, readable=True), mongo_uri=typer.Option(None, '--mongo-uri', envvar='MONGO_URI', help='MongoDB connection URI. Overrides MONGO_URI environment value.'), server_url=typer.Option('http://localhost:8000', '--server-url', envvar='DCS_SERVER_URL', help='DCS API server URL.'))
Initialize global CLI options and context.
Source code in dcs_simulation_engine/cli/app.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
bootstrap
CLI bootstrap: single entrypoint for backend wiring and lifecycle.
create_async_provider(*, mongo_uri=None)
async
Return an AsyncMongoProvider wired to a resolved MongoDB URI.
Source code in dcs_simulation_engine/cli/bootstrap.py
38 39 40 41 | |
create_provider_admin(*, mongo_uri=None)
Return a MongoAdmin wired to a resolved MongoDB URI.
Source code in dcs_simulation_engine/cli/bootstrap.py
50 51 52 53 | |
create_sync_db(*, mongo_uri=None)
Return a sync MongoDB database handle wired to a resolved MongoDB URI.
Source code in dcs_simulation_engine/cli/bootstrap.py
44 45 46 47 | |
commands
Command groups for the CLI.
admin
CLI admin commands for database administration.
backup(ctx, outdir=typer.Argument(help='Directory to write the backup to. A timestamped subdirectory is created inside.'))
Backup the entire database to a directory.
Source code in dcs_simulation_engine/cli/commands/admin.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
keygen(ctx)
Generate a deployment-ready admin key without storing it anywhere.
Source code in dcs_simulation_engine/cli/commands/admin.py
42 43 44 45 46 47 48 | |
seed(ctx, seeds_dir=typer.Argument(help='Directory of JSON/NDJSON seed files. Defaults to database_seeds/dev.'))
Seed the database from JSON files.
Source code in dcs_simulation_engine/cli/commands/admin.py
13 14 15 16 17 18 19 20 21 | |
dump
CLI command for dumping Mongo collections to JSON files.
dump(ctx, outdir=typer.Argument(..., help='Directory to write the dump to. A timestamped subdirectory is created inside.', file_okay=False, dir_okay=True, writable=True, readable=True, resolve_path=False))
Dump all Mongo collections to JSON files.
Source code in dcs_simulation_engine/cli/commands/dump.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
remote
Remote Fly deployment and lifecycle commands.
deploy(ctx, config=typer.Option(None, '--config', exists=True, dir_okay=False, file_okay=True, readable=True, resolve_path=True, help='Experiment YAML config to deploy. Omit when using --free-play.'), free_play=typer.Option(False, '--free-play', help='Deploy the stack in anonymous free-play mode instead of experiment mode.'), openrouter_key=typer.Option(..., '--openrouter-key', envvar='OPENROUTER_API_KEY', help='OpenRouter API key forwarded to the remote API deployment.'), fly_io_key=typer.Option(None, '--fly-io-key', envvar='FLY_API_TOKEN', help='Fly API token used for deploy and destroy operations.'), mongo_seed_path=typer.Option(..., '--mongo-seed-path', exists=True, dir_okay=True, file_okay=True, readable=True, resolve_path=True, help='Local seed source for Mongo bootstrap: a .zip/.tar.gz archive, a .json/.ndjson dump, or a directory.'), admin_key=typer.Option(None, '--admin-key', envvar='DCS_ADMIN_KEY', help='Optional explicit remote admin key to install during bootstrap. Must match the dcs-ak- key format.'), region=typer.Option(None, '--regions', '--region', help='Fly region(s) to try in order. Example: --regions lax sjc dfw'), only_app=typer.Option(None, '--only-app', help='Redeploy only the selected app(s): api, ui, or db. Repeat the flag to deploy multiple apps.'), api_app=typer.Option(None, '--api-app', help='Optional explicit Fly app name for the API.'), ui_app=typer.Option(None, '--ui-app', help='Optional explicit Fly app name for the UI.'), db_app=typer.Option(None, '--db-app', help='Optional explicit Fly app name for MongoDB.'), json_output=typer.Option(False, '--json', help='Print the deployment result as JSON.'))
Deploy one remote-managed stack to Fly as API, UI, and Mongo apps.
Source code in dcs_simulation_engine/cli/commands/remote.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
save(ctx, uri=typer.Option(..., '--uri', help='Remote API base URL.'), admin_key=typer.Option(..., '--admin-key', envvar='DCS_ADMIN_KEY', help='Admin access key returned by remote deploy.'), save_db_path=typer.Option(..., '--save-db-path', dir_okay=False, file_okay=True, writable=True, resolve_path=True, help='Local path for the downloaded database export archive (.tar.gz or .zip).'))
Download the remote database export archive to a local file.
Source code in dcs_simulation_engine/cli/commands/remote.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
status(ctx, uri=typer.Option(..., '--uri', help='Remote API base URL.'), admin_key=typer.Option(..., '--admin-key', envvar='DCS_ADMIN_KEY', help='Saved remote admin access key.'), json_output=typer.Option(False, '--json', help='Print the status result as JSON.'))
Return the authenticated status payload for one remote deployment.
Source code in dcs_simulation_engine/cli/commands/remote.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
stop(ctx, uri=typer.Option(..., '--uri', help='Remote API base URL.'), admin_key=typer.Option(..., '--admin-key', envvar='DCS_ADMIN_KEY', help='Admin access key returned by remote deploy.'), save_db_path=typer.Option(..., '--save-db-path', dir_okay=False, file_okay=True, writable=True, resolve_path=True, help='Local path for the downloaded database export archive (.tar.gz or .zip).'), api_app=typer.Option(..., '--api-app', help='Fly API app name.'), ui_app=typer.Option(..., '--ui-app', help='Fly UI app name.'), db_app=typer.Option(..., '--db-app', help='Fly Mongo app name.'), fly_io_key=typer.Option(None, '--fly-io-key', envvar='FLY_API_TOKEN', help='Fly API token used to destroy the remote apps.'))
Save the remote DB archive, then destroy all Fly apps for the experiment.
Source code in dcs_simulation_engine/cli/commands/remote.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
server
CLI server command.
server(ctx, host=typer.Option(DEFAULT_HOST, '--host', envvar='DCS_SERVER_HOST', help='Host to bind the server to.'), port=typer.Option(DEFAULT_PORT, '--port', envvar='DCS_SERVER_PORT', help='Port to bind the server to.'), ttl_seconds=typer.Option(DEFAULT_SESSION_TTL_SECONDS, '--session-ttl', envvar='DCS_SESSION_TTL_SECONDS', help='Session TTL in seconds.'), sweep_interval_seconds=typer.Option(DEFAULT_SWEEP_INTERVAL_SECONDS, '--sweep-interval', envvar='DCS_SESSION_SWEEP_INTERVAL_SECONDS', help='Session sweep interval in seconds.'), mongo_seed_dir=typer.Option(None, '--mongo-seed-dir', envvar='DCS_MONGO_SEED_DIR', help='Seed MongoDB from this directory of JSON/NDJSON files on startup.'), dump_dir=typer.Option(None, '--dump', envvar='DCS_DUMP_DIR', help='Dump all Mongo collections to this directory when the server shuts down.'), fake_ai_response=typer.Option(None, '--fake-ai-response', help='Return this string for all AI responses instead of calling OpenRouter.'), free_play=typer.Option(False, '--free-play', help='Run the server in anonymous free play mode without registration or experiments.'), remote_managed=typer.Option(False, '--remote-managed', envvar='DCS_REMOTE_MANAGED', help='Run the server as a remote-managed deployment with bootstrap/export endpoints enabled.'), default_experiment=typer.Option(None, '--default-experiment', envvar='DCS_DEFAULT_EXPERIMENT_NAME', help='Default experiment name for experiment-centric deployments.'), bootstrap_token=typer.Option(None, '--bootstrap-token', envvar='DCS_REMOTE_BOOTSTRAP_TOKEN', help='One-time bootstrap token used to seed a remote-managed deployment.'), cors_origin=typer.Option(None, '--cors-origin', help='Additional allowed CORS origin. Repeat the flag to allow multiple origins.'))
Start the DCS API server.
Source code in dcs_simulation_engine/cli/commands/server.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
common
Shared cli utilities.
GlobalOptions
dataclass
Global options for the CLI.
Source code in dcs_simulation_engine/cli/common.py
26 27 28 29 30 31 32 33 34 | |
echo(ctx, message, style='white')
Respect global quiet flag; print only if not quiet.
Source code in dcs_simulation_engine/cli/common.py
45 46 47 48 49 50 51 52 53 54 | |
get_client(ctx)
Return an APIClient configured from the CLI context.
Source code in dcs_simulation_engine/cli/common.py
37 38 39 40 41 42 | |
seed_database(ctx, seed_dir)
Seed the database from JSON/NDJSON files.
Source code in dcs_simulation_engine/cli/common.py
72 73 74 75 76 77 78 79 80 81 | |
step(msg)
Context manager for displaying a step with a spinner.
Source code in dcs_simulation_engine/cli/common.py
57 58 59 60 61 62 63 64 65 66 67 68 69 | |
core
Di Simulation Engine core components.
assignment_strategies
Assignment strategy registry.
get_assignment_strategy(strategy_name)
Resolve one registered assignment strategy by name.
Source code in dcs_simulation_engine/core/assignment_strategies/__init__.py
11 12 13 14 15 16 17 | |
base
Assignment strategy protocol for experiment workflows.
AssignmentStrategy
Bases: Protocol
Behavior contract for experiment assignment strategies.
Source code in dcs_simulation_engine/core/assignment_strategies/base.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
compute_progress_async(*, provider, config)
async
Return experiment progress payload for the public API.
Source code in dcs_simulation_engine/core/assignment_strategies/base.py
23 24 | |
compute_status_async(*, provider, config)
async
Return experiment status payload for the public API.
Source code in dcs_simulation_engine/core/assignment_strategies/base.py
26 27 | |
get_or_create_assignment_async(*, provider, config, player)
async
Return the current assignment for a player or create one.
Source code in dcs_simulation_engine/core/assignment_strategies/base.py
29 30 31 32 33 34 35 36 | |
max_assignments_per_player(*, config)
Return the maximum number of assignments one player may complete.
Source code in dcs_simulation_engine/core/assignment_strategies/base.py
20 21 | |
validate_config(*, config)
Validate strategy-specific config constraints.
Source code in dcs_simulation_engine/core/assignment_strategies/base.py
17 18 | |
random_unique
Random unique assignment strategy implementation.
RandomUniqueAssignmentStrategy
Assign each player a deterministic random game without repeats.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
compute_progress_async(*, provider, config)
async
Compute progress while closing the study on counted quota saturation.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
compute_status_async(*, provider, config)
async
Compute per-game counts with quota openness based on active plus finished players.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
generate_remaining_assignments_async(*, provider, config, player)
async
Pre-generate all remaining assignments up to max_assignments_per_player.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
get_eligible_options_async(*, provider, config, player)
async
Return all eligible {game_name, character_hid} options for the player to choose from.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
get_or_create_assignment_async(*, provider, config, player)
async
Reuse active work or create a new random unique assignment for a player.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
max_assignments_per_player(*, config)
Return the configured max assignments, capped by the game list.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
36 37 38 39 40 41 | |
validate_config(*, config)
Validate the required knobs for the random-unique strategy.
Source code in dcs_simulation_engine/core/assignment_strategies/random_unique.py
23 24 25 26 27 28 29 30 31 32 33 34 | |
constants
Constants for core module.
experiment_config
Experiment-level configuration models for assignment-driven studies.
AssignmentStrategyConfig
Bases: BaseModel
Flexible assignment-strategy shape that can parse current and future strategies.
Source code in dcs_simulation_engine/core/experiment_config.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
validate_games(values)
classmethod
Normalize experiment game references when they are supplied.
Source code in dcs_simulation_engine/core/experiment_config.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
ExperimentConfig
Bases: SerdeMixin, BaseModel
Top-level experiment configuration for assignment-driven studies.
Source code in dcs_simulation_engine/core/experiment_config.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
games
property
Canonical list of games included in the experiment assignment strategy.
forms_for_phase(*, before_or_after)
Return forms matching one phase.
Source code in dcs_simulation_engine/core/experiment_config.py
121 122 123 | |
load(path)
classmethod
Load an experiment config from YAML.
Source code in dcs_simulation_engine/core/experiment_config.py
125 126 127 128 | |
normalize_forms(value)
classmethod
Accept forms as either a list or a mapping keyed by form name.
Source code in dcs_simulation_engine/core/experiment_config.py
93 94 95 96 97 98 99 100 101 102 103 | |
validate_config()
Validate strategy-specific constraints and form names.
Source code in dcs_simulation_engine/core/experiment_config.py
105 106 107 108 109 110 111 112 113 114 | |
experiment_manager
Experiment orchestration for assignment-driven study flows.
ExperimentManager
Loads experiment configs and resolves experiment assignment workflows.
Source code in dcs_simulation_engine/core/experiment_manager.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
compute_progress_async(*, provider, experiment_name)
async
classmethod
Compute finite usability progress from assignment state.
Source code in dcs_simulation_engine/core/experiment_manager.py
106 107 108 109 110 111 | |
compute_status_async(*, provider, experiment_name)
async
classmethod
Compute quota-centric status counts for an experiment.
Source code in dcs_simulation_engine/core/experiment_manager.py
113 114 115 116 117 118 | |
create_player_choice_assignment_async(*, provider, experiment_name, player, game_name, character_hid)
async
classmethod
Create a specific assignment for a player who selected game+character manually.
Source code in dcs_simulation_engine/core/experiment_manager.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
ensure_experiment_async(*, provider, experiment_name)
async
classmethod
Persist the experiment config snapshot if it is not already stored.
Source code in dcs_simulation_engine/core/experiment_manager.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
get_eligible_options_async(*, provider, experiment_name, player)
async
classmethod
Return eligible {game_name, character_hid} options for a player in player_choice mode.
Source code in dcs_simulation_engine/core/experiment_manager.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
get_experiment_config_cached(experiment)
classmethod
Return a defensive copy of a cached experiment config.
Source code in dcs_simulation_engine/core/experiment_manager.py
47 48 49 50 51 | |
get_latest_assignment_for_player_async(*, provider, player_id)
async
classmethod
Return the latest experiment assignment for a player across all experiments.
Source code in dcs_simulation_engine/core/experiment_manager.py
360 361 362 363 364 365 366 | |
get_or_create_assignment_async(*, provider, experiment_name, player)
async
classmethod
Return the active assignment for a player or create one on demand.
Source code in dcs_simulation_engine/core/experiment_manager.py
217 218 219 220 221 222 223 224 225 226 227 228 | |
get_player_state_async(*, provider, experiment_name, player_id)
async
classmethod
Return the assignment state visible to one authenticated player.
Source code in dcs_simulation_engine/core/experiment_manager.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
handle_session_terminal_state_async(*, provider, experiment_name, assignment_id, exit_reason)
async
classmethod
Map a gameplay terminal reason onto an assignment lifecycle status.
Source code in dcs_simulation_engine/core/experiment_manager.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
normalize_form_submissions(*, forms, responses)
classmethod
Validate and normalize submitted answers for one or more named forms.
Source code in dcs_simulation_engine/core/experiment_manager.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
preload_experiment_configs()
classmethod
Load all valid experiment configs from disk into the in-memory cache.
Source code in dcs_simulation_engine/core/experiment_manager.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
start_assignment_session_async(*, provider, registry, experiment_name, player, source='experiment')
async
classmethod
Start a gameplay session for the current assignment.
Source code in dcs_simulation_engine/core/experiment_manager.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
store_form_payloads_async(*, provider, assignment_id, forms_payload)
async
classmethod
Store one or more named form payloads on an assignment row.
Source code in dcs_simulation_engine/core/experiment_manager.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
store_player_form_payloads_async(*, provider, player_id, experiment_name, forms_payload)
async
classmethod
Store one or more named before-play form payloads on the player forms record.
Source code in dcs_simulation_engine/core/experiment_manager.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
store_post_play_async(*, provider, experiment_name, player_id, responses)
async
classmethod
Store all after-play forms on the latest completed assignment.
Source code in dcs_simulation_engine/core/experiment_manager.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
submit_before_play_async(*, provider, experiment_name, player_id, responses)
async
classmethod
Store before-play form answers for an authenticated player and return their assignment.
Source code in dcs_simulation_engine/core/experiment_manager.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
forms
Shared form models for experiment workflows.
ExperimentForm
Bases: BaseModel
Named experiment form shown before or after gameplay.
Source code in dcs_simulation_engine/core/forms.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
assign_question_keys()
Ensure every question has a stable key.
Source code in dcs_simulation_engine/core/forms.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
name_format(value)
classmethod
Normalize and validate form names.
Source code in dcs_simulation_engine/core/forms.py
64 65 66 67 68 69 70 71 | |
ExperimentFormQuestion
Bases: BaseModel
Question model used by experiment forms.
Source code in dcs_simulation_engine/core/forms.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
validate_question()
Validate options vs answer type.
Source code in dcs_simulation_engine/core/forms.py
45 46 47 48 49 50 51 52 | |
game
Base classes for new-style game implementations.
Game
Base class for new-style games.
Replaces build_graph_config() / SimulationGraph for games that prefer to express their logic directly in Python rather than as a LangGraph graph.
SessionManager drives this class instead of RunManager.
Source code in dcs_simulation_engine/core/game.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
exit_reason
property
Reason the game ended, or empty string.
exited
property
True if the game has ended.
create_from_context(pc, npc, **kwargs)
classmethod
Factory method called by SessionManager.
Receives character records loaded from the DB and any additional kwargs (e.g. model names). Returns a fully initialised Game instance.
Source code in dcs_simulation_engine/core/game.py
55 56 57 58 59 60 61 62 | |
exit(reason)
Signal the game to end.
Source code in dcs_simulation_engine/core/game.py
41 42 43 | |
step(user_input=None)
async
Advance the game one turn.
Async-yields one or more GameEvents. Handles command detection, validation, AI calls, and lifecycle transitions internally.
Source code in dcs_simulation_engine/core/game.py
33 34 35 36 37 38 39 | |
GameEvent
Bases: NamedTuple
A single event yielded by a game step.
Source code in dcs_simulation_engine/core/game.py
10 11 12 13 14 15 16 17 18 19 20 21 | |
now(*, type, content, command_response=False)
classmethod
Build an event stamped with the current wall-clock time.
Source code in dcs_simulation_engine/core/game.py
18 19 20 21 | |
game_config
Base game config module.
GameConfig
Bases: SerdeMixin, BaseModel
Top-level configuration for the game.
Source code in dcs_simulation_engine/core/game_config.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
get_game_class_instance()
Dynamically import and instantiate the game engine class.
Source code in dcs_simulation_engine/core/game_config.py
42 43 44 45 46 47 | |
get_valid_characters(*, player_id=None, provider, pc_eligible_only=False)
Return (valid_pcs, valid_npcs) as (display_string, hid) tuples.
Source code in dcs_simulation_engine/core/game_config.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
get_valid_characters_async(*, player_id=None, provider, pc_eligible_only=False)
async
Async-safe variant of get_valid_characters for async providers.
Source code in dcs_simulation_engine/core/game_config.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
load(path)
classmethod
Load a GameConfig from a YAML file.
Source code in dcs_simulation_engine/core/game_config.py
49 50 51 52 | |
session_event_recorder
Session event persistence for deterministic transcript reconstruction.
RecordedSessionEvent
Bases: NamedTuple
Metadata for an event that has been queued for persistence.
Source code in dcs_simulation_engine/core/session_event_recorder.py
214 215 216 217 218 | |
SessionEventRecorder
Session-scoped persistence helper for sessions + session_events.
Source code in dcs_simulation_engine/core/session_event_recorder.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
flush_pending()
async
Force currently buffered event docs to Mongo.
Source code in dcs_simulation_engine/core/session_event_recorder.py
84 85 86 | |
session_manager
SessionManager: drives new-style Game classes.
SessionManager
Manages a single session of a Game.
Source code in dcs_simulation_engine/core/session_manager.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
exit_reason
property
Return the terminal reason string, if available.
exited
property
Return True when the session or game lifecycle is finished.
runtime_seconds
property
Return elapsed runtime in seconds.
turns
property
Return completed AI turns.
__init__(name, game, game_config, provider, source='unknown', player_id=None, stopping_conditions=None)
Initialize session state, runtime counters, and persistence hooks.
Source code in dcs_simulation_engine/core/session_manager.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
create_async(game, provider, source='unknown', pc_choice=None, npc_choice=None, player_id=None)
async
classmethod
Create a session for async runtime paths.
Source code in dcs_simulation_engine/core/session_manager.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
exit_async(reason)
async
Mark session ended, finalize persistence, and close recorder.
Source code in dcs_simulation_engine/core/session_manager.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
flush_persistence_async()
async
Flush any queued transcript events so follow-on writes can target them safely.
Source code in dcs_simulation_engine/core/session_manager.py
318 319 320 321 | |
get_game_config_cached(game)
classmethod
Return a defensive copy of a cached game config, loading it on first use.
Source code in dcs_simulation_engine/core/session_manager.py
57 58 59 60 61 | |
preload_game_configs()
classmethod
Load all valid game configs from disk into the in-memory cache.
Source code in dcs_simulation_engine/core/session_manager.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
save()
Compatibility no-op; session transcript writes now use session_events.
Source code in dcs_simulation_engine/core/session_manager.py
323 324 325 326 | |
start_persistence(*, session_id)
async
Initialize session + event persistence once session_id is assigned.
Source code in dcs_simulation_engine/core/session_manager.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
step_async(user_input=None)
async
Advance one turn asynchronously and return normalized event dicts.
Source code in dcs_simulation_engine/core/session_manager.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
dal
Data abstraction layer.
base
DAL base: record types and DataProvider interface.
AssignmentRecord
Bases: NamedTuple
A persisted experiment assignment row.
Source code in dcs_simulation_engine/dal/base.py
68 69 70 71 72 73 74 75 76 77 78 | |
CharacterRecord
Bases: NamedTuple
A character loaded from the data store.
Source code in dcs_simulation_engine/dal/base.py
6 7 8 9 10 11 12 | |
DataProvider
Abstract data provider interface.
Subclasses implement storage-specific logic. All methods raise NotImplementedError by default.
Source code in dcs_simulation_engine/dal/base.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
append_session_event(*, session_id, player_id, direction, event_type, event_source, content, content_format, turn_index, visible_to_user)
Append one owned session event to an existing persisted session.
Source code in dcs_simulation_engine/dal/base.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
clear_session_event_feedback(*, session_id, player_id, event_id)
Remove feedback from a persisted NPC-message event.
Source code in dcs_simulation_engine/dal/base.py
174 175 176 177 178 179 180 181 182 | |
create_assignment(*, assignment_doc, allow_concurrent=False)
Persist a new experiment assignment row.
Source code in dcs_simulation_engine/dal/base.py
208 209 210 | |
create_player(*, player_data, player_id=None, issue_access_key=False, access_key=None)
Create or upsert a player.
Returns:
| Type | Description |
|---|---|
tuple[PlayerRecord, str | None]
|
(record, raw_key) where raw_key is None unless an access key was issued or explicitly provided. |
Source code in dcs_simulation_engine/dal/base.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
delete_character(character_id)
Delete a character by id.
Source code in dcs_simulation_engine/dal/base.py
131 132 133 | |
delete_player(player_id)
Delete a player by id.
Source code in dcs_simulation_engine/dal/base.py
135 136 137 | |
get_active_assignment(*, experiment_name, player_id)
Return the current active assignment for one player in one experiment.
Source code in dcs_simulation_engine/dal/base.py
216 217 218 | |
get_assignment(*, assignment_id)
Return one assignment row by assignment id.
Source code in dcs_simulation_engine/dal/base.py
212 213 214 | |
get_character(*, hid)
Return the character with the given HID.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no character with that HID exists. |
Source code in dcs_simulation_engine/dal/base.py
88 89 90 91 92 93 94 | |
get_characters(*, hid=None)
Return all characters, or a single character if hid is given.
Source code in dcs_simulation_engine/dal/base.py
96 97 98 | |
get_experiment(*, experiment_name)
Return a persisted experiment record by name.
Source code in dcs_simulation_engine/dal/base.py
184 185 186 | |
get_latest_experiment_assignment_for_player(*, player_id)
Return the newest experiment assignment for one player across experiments.
Source code in dcs_simulation_engine/dal/base.py
220 221 222 | |
get_player(*, player_id)
Return a single player by id, or None if not found.
Source code in dcs_simulation_engine/dal/base.py
104 105 106 | |
get_player_forms(*, player_id, experiment_name)
Return the before-play form responses for a player in an experiment.
Source code in dcs_simulation_engine/dal/base.py
266 267 268 269 270 271 272 273 | |
get_players(*, access_key=None)
Return all players, or a single player by access key.
Source code in dcs_simulation_engine/dal/base.py
123 124 125 | |
get_session(*, session_id, player_id)
Return one persisted session header for a player.
Source code in dcs_simulation_engine/dal/base.py
139 140 141 | |
list_assignments(*, experiment_name, player_id=None, statuses=None, game_name=None)
List experiment assignments matching the provided filters.
Source code in dcs_simulation_engine/dal/base.py
224 225 226 227 228 229 230 231 232 233 | |
list_characters()
Return all characters.
Source code in dcs_simulation_engine/dal/base.py
100 101 102 | |
list_session_events(*, session_id)
Return ordered persisted events for a session.
Source code in dcs_simulation_engine/dal/base.py
143 144 145 | |
set_assignment_form_response(*, assignment_id, form_key, response)
Store one experiment form response payload on an assignment row.
Source code in dcs_simulation_engine/dal/base.py
245 246 247 248 249 250 251 252 253 | |
set_experiment_progress(*, experiment_name, progress)
Persist the latest experiment progress snapshot.
Source code in dcs_simulation_engine/dal/base.py
199 200 201 202 203 204 205 206 | |
set_player_form_response(*, player_id, experiment_name, form_key, response)
Store one before-play form response in the forms collection.
Source code in dcs_simulation_engine/dal/base.py
255 256 257 258 259 260 261 262 263 264 | |
set_session_event_feedback(*, session_id, player_id, event_id, feedback)
Store feedback on a persisted NPC-message event.
Source code in dcs_simulation_engine/dal/base.py
163 164 165 166 167 168 169 170 171 172 | |
update_assignment_status(*, assignment_id, status, active_session_id=None)
Update assignment status and lifecycle timestamps.
Source code in dcs_simulation_engine/dal/base.py
235 236 237 238 239 240 241 242 243 | |
upsert_character(data, *, character_id=None)
Create or update a character. Returns the character's id string.
Source code in dcs_simulation_engine/dal/base.py
127 128 129 | |
upsert_experiment(*, experiment_name, description, config_snapshot, progress)
Create or update a persisted experiment metadata record.
Source code in dcs_simulation_engine/dal/base.py
188 189 190 191 192 193 194 195 196 197 | |
ExperimentRecord
Bases: NamedTuple
A persisted experiment metadata record.
Source code in dcs_simulation_engine/dal/base.py
49 50 51 52 53 54 55 | |
PlayerFormsRecord
Bases: NamedTuple
Before-play form responses for a player in a specific experiment.
Source code in dcs_simulation_engine/dal/base.py
58 59 60 61 62 63 64 65 | |
PlayerRecord
Bases: NamedTuple
A player record (non-PII fields only).
Source code in dcs_simulation_engine/dal/base.py
15 16 17 18 19 20 21 | |
SessionEventRecord
Bases: NamedTuple
A persisted event row for a session transcript.
Source code in dcs_simulation_engine/dal/base.py
35 36 37 38 39 40 41 42 43 44 45 46 | |
SessionRecord
Bases: NamedTuple
A persisted chat session header record.
Source code in dcs_simulation_engine/dal/base.py
24 25 26 27 28 29 30 31 32 | |
mongo
MongoDB DAL: provider and admin classes.
AsyncMongoProvider
Async provider backed by PyMongo AsyncMongoClient.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | |
append_session_event(*, session_id, player_id, direction, event_type, event_source, content, content_format, turn_index, visible_to_user)
async
Append one owned session event and advance the parent session sequence counter.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
clear_session_event_feedback(*, session_id, player_id, event_id)
async
Remove feedback from one persisted NPC message event owned by the player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
create_assignment(*, assignment_doc, allow_concurrent=False)
async
Persist a new experiment assignment row.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | |
create_player(*, player_data, player_id=None, issue_access_key=False, access_key=None)
async
Create or update a player, optionally issuing them a new access key.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
create_session(session_doc)
async
Log the start of a new game/app session.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
319 320 321 | |
delete_character(character_id)
async
Remove a character by ID.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
308 309 310 | |
delete_player(player_id)
async
Remove a player by ID, checking all variant ID types.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
312 313 314 315 316 317 | |
finalize_session(*, session_id, termination_reason, status, session_ended_at, turns_completed, last_seq)
async
Update a session record with final metrics when it ends.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
get_active_assignment(*, experiment_name, player_id)
async
Return the current active assignment for one player in one experiment.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
get_assignment(*, assignment_id)
async
Return one assignment row by assignment_id.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
651 652 653 654 655 656 | |
get_assignment_for_session_id(*, session_id)
async
Return the assignment that has this session as its active session.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
675 676 677 678 679 680 | |
get_character(*, hid)
async
Strict version of get_characters that guarantees a single record is returned.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
159 160 161 162 163 164 | |
get_characters(*, hid=None)
async
Fetch a specific character by ID, or list all of them if no ID is provided.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
146 147 148 149 150 151 152 153 154 155 156 157 | |
get_experiment(*, experiment_name)
async
Return one persisted experiment record.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
567 568 569 570 571 572 | |
get_latest_experiment_assignment_for_player(*, player_id)
async
Return the newest experiment assignment for one player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
682 683 684 685 686 687 688 689 690 691 | |
get_player(*, player_id)
async
Look up a player by their ID.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
get_player_forms(*, player_id, experiment_name)
async
Return the before-play form responses for a player in an experiment.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | |
get_players(*, access_key=None)
async
Fetch all players, or specifically authenticate and fetch one by access_key.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
get_session(*, session_id, player_id)
async
Return a single persisted session record for the player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
381 382 383 384 385 386 387 388 389 390 391 392 393 | |
get_session_reconstruction(*, session_id, player_id)
async
Return session metadata and ordered event stream for replay.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | |
list_assignments(*, experiment_name, player_id=None, statuses=None, game_name=None)
async
List assignment rows matching the requested filters.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
list_characters()
async
Fetch all character records from the database.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
166 167 168 169 170 171 | |
list_session_events(*, session_id)
async
Return all persisted session events in sequence order.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
395 396 397 398 399 400 401 402 | |
pause_session(*, session_id, paused_at)
async
Update a session record to reflect it is paused and awaiting resume.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
resume_session(*, session_id, resumed_at)
async
Update a session record to reflect it has been resumed.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
set_assignment_form_response(*, assignment_id, form_key, response)
async
Store one form response payload on an assignment row.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 | |
set_experiment_progress(*, experiment_name, progress)
async
Persist the latest experiment progress snapshot.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
set_player_form_response(*, player_id, experiment_name, form_key, response)
async
Upsert one before-play form response into the forms collection.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
set_session_event_feedback(*, session_id, player_id, event_id, feedback)
async
Store feedback on one persisted NPC message event owned by the player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
update_assignment_status(*, assignment_id, status, active_session_id=None)
async
Update assignment status and lifecycle timestamps.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
upsert_character(data, *, character_id=None)
async
Create a new character or update an existing one.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
upsert_experiment(*, experiment_name, description, config_snapshot, progress)
async
Create or update an experiment metadata row.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
MongoAdmin
Administrative operations over a specific Mongo DB handle.
Source code in dcs_simulation_engine/dal/mongo/admin.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
__init__(db)
Bind admin operations to the given database handle.
Source code in dcs_simulation_engine/dal/mongo/admin.py
24 25 26 | |
backup_collection(db, coll_name, root)
Dump a single collection to ndjson and write its index metadata.
Source code in dcs_simulation_engine/dal/mongo/admin.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
backup_db(outdir, *, append_ts=True)
Backup entire DB to a directory. Returns the path written.
Source code in dcs_simulation_engine/dal/mongo/admin.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
backup_root_dir(db_name)
Return a timestamped backup root path and create the directory.
Source code in dcs_simulation_engine/dal/mongo/admin.py
90 91 92 93 94 95 | |
create_indices(coll)
Create any configured indexes for the given collection.
Source code in dcs_simulation_engine/dal/mongo/admin.py
129 130 131 132 133 134 135 136 137 138 | |
load_seed_documents(path)
Parse a seed file (.json or .ndjson) and return a list of documents.
Source code in dcs_simulation_engine/dal/mongo/admin.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
seed_collection(coll, docs)
Drop and repopulate a collection with docs. Returns inserted count.
Source code in dcs_simulation_engine/dal/mongo/admin.py
115 116 117 118 119 120 121 122 123 124 125 126 127 | |
seed_database(seed_dir)
Seed all collections from seed_dir. Existing collections are dropped and replaced.
Source code in dcs_simulation_engine/dal/mongo/admin.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
admin
MongoDB administrative operations for CLI bootstrap and teardown.
MongoAdmin
Administrative operations over a specific Mongo DB handle.
Source code in dcs_simulation_engine/dal/mongo/admin.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
__init__(db)
Bind admin operations to the given database handle.
Source code in dcs_simulation_engine/dal/mongo/admin.py
24 25 26 | |
backup_collection(db, coll_name, root)
Dump a single collection to ndjson and write its index metadata.
Source code in dcs_simulation_engine/dal/mongo/admin.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
backup_db(outdir, *, append_ts=True)
Backup entire DB to a directory. Returns the path written.
Source code in dcs_simulation_engine/dal/mongo/admin.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
backup_root_dir(db_name)
Return a timestamped backup root path and create the directory.
Source code in dcs_simulation_engine/dal/mongo/admin.py
90 91 92 93 94 95 | |
create_indices(coll)
Create any configured indexes for the given collection.
Source code in dcs_simulation_engine/dal/mongo/admin.py
129 130 131 132 133 134 135 136 137 138 | |
load_seed_documents(path)
Parse a seed file (.json or .ndjson) and return a list of documents.
Source code in dcs_simulation_engine/dal/mongo/admin.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
seed_collection(coll, docs)
Drop and repopulate a collection with docs. Returns inserted count.
Source code in dcs_simulation_engine/dal/mongo/admin.py
115 116 117 118 119 120 121 122 123 124 125 126 127 | |
seed_database(seed_dir)
Seed all collections from seed_dir. Existing collections are dropped and replaced.
Source code in dcs_simulation_engine/dal/mongo/admin.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
async_provider
Async MongoDB implementation for runtime server paths.
AsyncMongoProvider
Async provider backed by PyMongo AsyncMongoClient.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | |
append_session_event(*, session_id, player_id, direction, event_type, event_source, content, content_format, turn_index, visible_to_user)
async
Append one owned session event and advance the parent session sequence counter.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
clear_session_event_feedback(*, session_id, player_id, event_id)
async
Remove feedback from one persisted NPC message event owned by the player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
create_assignment(*, assignment_doc, allow_concurrent=False)
async
Persist a new experiment assignment row.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | |
create_player(*, player_data, player_id=None, issue_access_key=False, access_key=None)
async
Create or update a player, optionally issuing them a new access key.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
create_session(session_doc)
async
Log the start of a new game/app session.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
319 320 321 | |
delete_character(character_id)
async
Remove a character by ID.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
308 309 310 | |
delete_player(player_id)
async
Remove a player by ID, checking all variant ID types.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
312 313 314 315 316 317 | |
finalize_session(*, session_id, termination_reason, status, session_ended_at, turns_completed, last_seq)
async
Update a session record with final metrics when it ends.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
get_active_assignment(*, experiment_name, player_id)
async
Return the current active assignment for one player in one experiment.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
get_assignment(*, assignment_id)
async
Return one assignment row by assignment_id.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
651 652 653 654 655 656 | |
get_assignment_for_session_id(*, session_id)
async
Return the assignment that has this session as its active session.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
675 676 677 678 679 680 | |
get_character(*, hid)
async
Strict version of get_characters that guarantees a single record is returned.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
159 160 161 162 163 164 | |
get_characters(*, hid=None)
async
Fetch a specific character by ID, or list all of them if no ID is provided.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
146 147 148 149 150 151 152 153 154 155 156 157 | |
get_experiment(*, experiment_name)
async
Return one persisted experiment record.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
567 568 569 570 571 572 | |
get_latest_experiment_assignment_for_player(*, player_id)
async
Return the newest experiment assignment for one player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
682 683 684 685 686 687 688 689 690 691 | |
get_player(*, player_id)
async
Look up a player by their ID.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
get_player_forms(*, player_id, experiment_name)
async
Return the before-play form responses for a player in an experiment.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | |
get_players(*, access_key=None)
async
Fetch all players, or specifically authenticate and fetch one by access_key.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
get_session(*, session_id, player_id)
async
Return a single persisted session record for the player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
381 382 383 384 385 386 387 388 389 390 391 392 393 | |
get_session_reconstruction(*, session_id, player_id)
async
Return session metadata and ordered event stream for replay.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | |
list_assignments(*, experiment_name, player_id=None, statuses=None, game_name=None)
async
List assignment rows matching the requested filters.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
list_characters()
async
Fetch all character records from the database.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
166 167 168 169 170 171 | |
list_session_events(*, session_id)
async
Return all persisted session events in sequence order.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
395 396 397 398 399 400 401 402 | |
pause_session(*, session_id, paused_at)
async
Update a session record to reflect it is paused and awaiting resume.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
resume_session(*, session_id, resumed_at)
async
Update a session record to reflect it has been resumed.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
set_assignment_form_response(*, assignment_id, form_key, response)
async
Store one form response payload on an assignment row.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 | |
set_experiment_progress(*, experiment_name, progress)
async
Persist the latest experiment progress snapshot.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
set_player_form_response(*, player_id, experiment_name, form_key, response)
async
Upsert one before-play form response into the forms collection.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
set_session_event_feedback(*, session_id, player_id, event_id, feedback)
async
Store feedback on one persisted NPC message event owned by the player.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
update_assignment_status(*, assignment_id, status, active_session_id=None)
async
Update assignment status and lifecycle timestamps.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
upsert_character(data, *, character_id=None)
async
Create a new character or update an existing one.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
upsert_experiment(*, experiment_name, description, config_snapshot, progress)
async
Create or update an experiment metadata row.
Source code in dcs_simulation_engine/dal/mongo/async_provider.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
async_writer
Generic async buffered writer for Mongo collections.
AsyncMongoWriter
Bases: Generic[TDoc]
Buffer writes and periodically flush batched inserts to Mongo.
Source code in dcs_simulation_engine/dal/mongo/async_writer.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
close()
async
Flush pending docs and stop background flushing.
Source code in dcs_simulation_engine/dal/mongo/async_writer.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
enqueue(doc)
async
Queue one document. Backpressure applies when queue is full.
This method never performs inline DB writes.
Source code in dcs_simulation_engine/dal/mongo/async_writer.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
flush()
async
Flush all currently buffered writes.
Source code in dcs_simulation_engine/dal/mongo/async_writer.py
121 122 123 124 125 126 127 128 129 130 131 | |
start()
async
Start periodic background flushing.
Source code in dcs_simulation_engine/dal/mongo/async_writer.py
82 83 84 85 86 87 88 89 90 91 | |
const
MongoDB constants: collection names, column names, and index definitions.
MongoColumns
Namespace for MongoDB collection and field name constants.
Source code in dcs_simulation_engine/dal/mongo/const.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
util
Mongo DAL utility helpers.
This module is intentionally stateless. Connection ownership is handled by bootstrap/runtime wiring and passed into DAL objects explicitly.
connect_db(*, uri, db_name=DEFAULT_DB_NAME, client_factory=None)
Create a MongoDB DB handle from an explicit URI.
Source code in dcs_simulation_engine/dal/mongo/util.py
143 144 145 146 147 148 149 150 151 152 153 154 155 | |
connect_db_async(*, uri, db_name=DEFAULT_DB_NAME, client_factory=None)
async
Create an async MongoDB DB handle from an explicit URI.
Source code in dcs_simulation_engine/dal/mongo/util.py
158 159 160 161 162 163 164 165 166 167 168 169 170 | |
dump_all_collections_to_json(db, path)
Dump every collection to JSON plus backup metadata files.
Source code in dcs_simulation_engine/dal/mongo/util.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
dump_all_collections_to_json_async(db, path)
async
Dump every collection to JSON plus backup metadata files.
Source code in dcs_simulation_engine/dal/mongo/util.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
ensure_default_indexes(db)
Create baseline indexes used by runtime and tests.
Source code in dcs_simulation_engine/dal/mongo/util.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
ensure_default_indexes_async(db)
async
Create baseline indexes used by async runtime paths.
Source code in dcs_simulation_engine/dal/mongo/util.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
player_doc_to_record(doc)
Convert a raw MongoDB player document to a PlayerRecord.
Source code in dcs_simulation_engine/dal/mongo/util.py
322 323 324 325 326 327 328 329 330 | |
player_id_variants(player_id)
Return equivalent player id values (string and ObjectId variants).
Source code in dcs_simulation_engine/dal/mongo/util.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
sanitize_player_data(player_data)
Remove access-key fields from player_data and set a default created_at.
Source code in dcs_simulation_engine/dal/mongo/util.py
273 274 275 276 277 278 279 280 281 282 283 284 | |
split_pii(player_data)
Split player_data into (non_pii, pii) dicts based on PII field definitions.
Source code in dcs_simulation_engine/dal/mongo/util.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
deployments
Deployment assets used by the DCS CLI.
templates
Jinja templates for generated deployment configuration files.
errors
Errors for DCS Simulation Engine.
APIRequestError
Bases: RuntimeError
Base class for all domain errors.
Source code in dcs_simulation_engine/errors.py
4 5 | |
GameValidationError
Bases: APIRequestError
Raised when a game config fails validation.
Source code in dcs_simulation_engine/errors.py
8 9 | |
games
Built-in game class definitions.
ai_client
Async AI client for new-style games.
Provides two client types: - UpdaterClient: stateful, maintains conversation history for multi-turn chat. - ValidatorClient: stateless, sends only the system prompt + current action each call.
Both call OpenRouter's OpenAI-compatible chat completions endpoint.
ScorerClient
One-shot stateless client that scores a player's goal inference against the NPC profile.
Source code in dcs_simulation_engine/games/ai_client.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
__init__(npc, model=DEFAULT_MODEL)
Initialise with NPC character record and model identifier.
Source code in dcs_simulation_engine/games/ai_client.py
233 234 235 236 | |
score(transcript, guess)
async
Score the player's goal inference and return parsed + raw JSON results.
Source code in dcs_simulation_engine/games/ai_client.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
ScorerResult
Bases: NamedTuple
Parsed evaluation payload plus the raw JSON text returned by the scorer.
Source code in dcs_simulation_engine/games/ai_client.py
223 224 225 226 227 | |
UpdaterClient
Stateful async client for the scene-advancing (updater) LLM.
Maintains the full conversation history so the model has context for each new turn. The system prompt is injected once at the start of each history.
Source code in dcs_simulation_engine/games/ai_client.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
history
property
Read-only copy of the conversation history.
__init__(system_prompt, model=DEFAULT_MODEL)
Initialise with a system prompt and model identifier.
Source code in dcs_simulation_engine/games/ai_client.py
164 165 166 167 168 | |
chat(user_input)
async
Send the user's action and return the NPC's response content string.
Source code in dcs_simulation_engine/games/ai_client.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
reset()
Clear conversation history (e.g. on game reset).
Source code in dcs_simulation_engine/games/ai_client.py
175 176 177 | |
ValidatorClient
Stateless async client for the input-validation LLM.
Sends a fresh context each call: just the pre-rendered system prompt (which already includes pc abilities) plus the user's proposed action. No history is maintained between calls.
Source code in dcs_simulation_engine/games/ai_client.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
__init__(system_prompt_template, model=DEFAULT_MODEL)
Initialise with the Jinja2 template string from build_validator_prompt().
Source code in dcs_simulation_engine/games/ai_client.py
205 206 207 208 209 210 211 | |
validate(user_input)
async
Validate a user action. Returns {"type": "info"|"error", "content": str}.
Source code in dcs_simulation_engine/games/ai_client.py
213 214 215 216 217 218 219 220 | |
set_fake_ai_response(value)
Set a process-local override returned by _call_openrouter when configured.
Source code in dcs_simulation_engine/games/ai_client.py
28 29 30 31 | |
validate_openrouter_configuration()
Validate runtime configuration needed for live OpenRouter requests.
Source code in dcs_simulation_engine/games/ai_client.py
34 35 36 37 38 39 40 41 42 43 | |
const
Explore
String constants for the Explore game.
Source code in dcs_simulation_engine/games/const.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
Foresight
String constants for the Foresight game.
Source code in dcs_simulation_engine/games/const.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
GoalHorizon
String constants for the Goal Horizon game.
Source code in dcs_simulation_engine/games/const.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
InferIntent
String constants for the Infer Intent game.
Source code in dcs_simulation_engine/games/const.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
Teamwork
String constants for the Teamwork game.
Source code in dcs_simulation_engine/games/const.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
explore
Explore game.
Command
Bases: StrEnum
Game-level slash commands recognised by ExploreGame.
Source code in dcs_simulation_engine/games/explore.py
21 22 23 24 25 26 | |
ExploreGame
Bases: Game
Free-form exploration game: player describes actions, NPC reacts, no predefined goals.
Source code in dcs_simulation_engine/games/explore.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
exit_reason
property
Reason the game ended, or empty string.
exited
property
True if the game has ended.
__init__(pc, npc, updater, validator, retry_budget=DEFAULT_RETRY_BUDGET, max_input_length=DEFAULT_MAX_INPUT_LENGTH)
Initialise the game. Use create_from_context() as the public entry point.
Source code in dcs_simulation_engine/games/explore.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
create_from_context(pc, npc, **kwargs)
classmethod
Factory called by SessionManager. Builds clients from character dicts.
Accepted kwargs
retry_budget (int): overrides DEFAULT_RETRY_BUDGET max_input_length (int): overrides DEFAULT_MAX_INPUT_LENGTH
Source code in dcs_simulation_engine/games/explore.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
exit(reason)
Mark the game as ended.
Source code in dcs_simulation_engine/games/explore.py
74 75 76 77 78 79 80 | |
step(user_input=None)
async
Advance the game one turn, yielding one or more GameEvents.
Source code in dcs_simulation_engine/games/explore.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
foresight
Foresight game.
Command
Bases: StrEnum
Game-level slash commands recognized by ForesightGame.
Source code in dcs_simulation_engine/games/foresight.py
23 24 25 26 27 28 | |
ForesightGame
Bases: Game
Foresight game: player interacts with NPC and makes predictions embedded in their actions.
Source code in dcs_simulation_engine/games/foresight.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
exit_reason
property
Reason the game ended, or empty string.
exited
property
True if the game has ended.
__init__(pc, npc, updater, validator, retry_budget=DEFAULT_RETRY_BUDGET, max_input_length=DEFAULT_MAX_INPUT_LENGTH)
Initialise the game. Use create_from_context() as the public entry point.
Source code in dcs_simulation_engine/games/foresight.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
create_from_context(pc, npc, **kwargs)
classmethod
Factory called by SessionManager. Builds clients from character dicts.
Accepted kwargs
retry_budget (int): overrides DEFAULT_RETRY_BUDGET max_input_length (int): overrides DEFAULT_MAX_INPUT_LENGTH
Source code in dcs_simulation_engine/games/foresight.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
exit(reason)
Mark the game as ended.
Source code in dcs_simulation_engine/games/foresight.py
76 77 78 79 80 81 82 | |
step(user_input=None)
async
Advance the game one turn, yielding one or more GameEvents.
Source code in dcs_simulation_engine/games/foresight.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
goal_horizon
Goal Horizon game.
Command
Bases: StrEnum
Game-level slash commands recognised by GoalHorizonGame.
Source code in dcs_simulation_engine/games/goal_horizon.py
23 24 25 26 27 28 | |
GoalHorizonGame
Bases: Game
Goal Horizon game: player interacts with NPC across scenes to understand their limits.
Source code in dcs_simulation_engine/games/goal_horizon.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
capability_prediction
property
Player's inferred capability limits, or empty string.
capability_prediction_confidence
property
Player's confidence in their capability prediction, or empty string.
exit_reason
property
Reason the game ended, or empty string.
exited
property
True if the game has ended.
__init__(pc, npc, updater, validator, retry_budget=DEFAULT_RETRY_BUDGET, max_input_length=DEFAULT_MAX_INPUT_LENGTH)
Initialise the game. Use create_from_context() as the public entry point.
Source code in dcs_simulation_engine/games/goal_horizon.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
create_from_context(pc, npc, **kwargs)
classmethod
Factory called by SessionManager. Builds clients from character dicts.
Accepted kwargs
retry_budget (int): overrides DEFAULT_RETRY_BUDGET max_input_length (int): overrides DEFAULT_MAX_INPUT_LENGTH
Source code in dcs_simulation_engine/games/goal_horizon.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
exit(reason)
Mark the game as ended.
Source code in dcs_simulation_engine/games/goal_horizon.py
80 81 82 83 84 85 86 | |
step(user_input=None)
async
Advance the game one turn, yielding one or more GameEvents.
Source code in dcs_simulation_engine/games/goal_horizon.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
infer_intent
Infer Intent game.
Command
Bases: StrEnum
Game-level slash commands recognised by InferIntentGame.
Source code in dcs_simulation_engine/games/infer_intent.py
23 24 25 26 27 28 | |
InferIntentGame
Bases: Game
Infer Intent game: player interacts with NPC and infers their hidden goal.
Source code in dcs_simulation_engine/games/infer_intent.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
evaluation
property
LLM scoring result, or empty dict.
exit_reason
property
Reason the game ended, or empty string.
exited
property
True if the game has ended.
goal_inference
property
Player's goal inference, or empty string.
goal_inference_confidence
property
Player's confidence in their goal inference, or empty string.
__init__(pc, npc, updater, validator, retry_budget=DEFAULT_RETRY_BUDGET, max_input_length=DEFAULT_MAX_INPUT_LENGTH)
Initialise the game. Use create_from_context() as the public entry point.
Source code in dcs_simulation_engine/games/infer_intent.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
create_from_context(pc, npc, **kwargs)
classmethod
Factory called by SessionManager. Builds clients from character dicts.
Accepted kwargs
retry_budget (int): overrides DEFAULT_RETRY_BUDGET max_input_length (int): overrides DEFAULT_MAX_INPUT_LENGTH
Source code in dcs_simulation_engine/games/infer_intent.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
exit(reason)
Mark the game as ended.
Source code in dcs_simulation_engine/games/infer_intent.py
82 83 84 85 86 87 88 | |
step(user_input=None)
async
Advance the game one turn, yielding one or more GameEvents.
Source code in dcs_simulation_engine/games/infer_intent.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
markdown_helpers
Helpers for rendering game content as markdown.
format_abilities_markdown(abilities, *, section_heading_level=3)
Render a character's ability payload as readable markdown.
Source code in dcs_simulation_engine/games/markdown_helpers.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
prompts
Shared system prompt templates and builders for new-style games.
Templates use Jinja2 (consistent with the rest of the engine). Character data containing literal braces is safe because Jinja2 only expands {{ var }} syntax, not arbitrary brace sequences.
build_updater_prompt(pc, npc, additional_rules='')
Render the updater system prompt from PC/NPC character records.
Source code in dcs_simulation_engine/games/prompts.py
101 102 103 104 105 106 107 108 109 110 111 | |
build_validator_prompt(pc, npc, additional_rules='')
Return the validator system prompt template string.
The returned string still contains a {{ user_input }} Jinja2 placeholder that ValidatorClient renders per-call. pc_abilities and additional_rules are pre-rendered here; user_input is left as a literal template variable so ValidatorClient can fill it in safely without brace-collision issues.
Source code in dcs_simulation_engine/games/prompts.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
teamwork
Teamwork game.
Command
Bases: StrEnum
Game-level slash commands recognised by TeamworkGame.
Source code in dcs_simulation_engine/games/teamwork.py
21 22 23 24 25 26 | |
TeamworkGame
Bases: Game
Teamwork game: player collaborates with NPC toward a shared goal.
Source code in dcs_simulation_engine/games/teamwork.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
challenges
property
Player's reflection on challenges, or empty string.
exit_reason
property
Reason the game ended, or empty string.
exited
property
True if the game has ended.
__init__(pc, npc, updater, validator, retry_budget=DEFAULT_RETRY_BUDGET, max_input_length=DEFAULT_MAX_INPUT_LENGTH)
Initialise the game. Use create_from_context() as the public entry point.
Source code in dcs_simulation_engine/games/teamwork.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
create_from_context(pc, npc, **kwargs)
classmethod
Factory called by SessionManager. Builds clients from character dicts.
Accepted kwargs
retry_budget (int): overrides DEFAULT_RETRY_BUDGET max_input_length (int): overrides DEFAULT_MAX_INPUT_LENGTH
Source code in dcs_simulation_engine/games/teamwork.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
exit(reason)
Mark the game as ended.
Source code in dcs_simulation_engine/games/teamwork.py
76 77 78 79 80 81 82 | |
step(user_input=None)
async
Advance the game one turn, yielding one or more GameEvents.
Source code in dcs_simulation_engine/games/teamwork.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
helpers
Helpers: domain-aware convenience.
Contents should: - Know about the app's domain or feature - Wraps multiple steps into a higher-level action - Is opinionated about data shape, formatting, or behavior - Might change if the business logic changes
experiment_helpers
Helpers for experiment config discovery.
get_experiment_config(experiment)
Return the path to an experiment YAML config by name or explicit file path.
Source code in dcs_simulation_engine/helpers/experiment_helpers.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
game_helpers
Helpers for games.
create_game_from_template(name, template=None)
Copy a game into ./games from a template game file.
Source code in dcs_simulation_engine/helpers/game_helpers.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
get_game_config(game, version='latest')
Return the path to a YAML game config.
Accepts either
- A game name (matched against built-in configs in games/)
- A filesystem path to a custom YAML config
The optional version argument controls which config is selected when
multiple configs share the same name field:
- "latest" (default): pick the latest stable release by the
versionfield in the YAML (using PEP 440 / semantic version ordering and preferring non-prerelease, non-dev versions). - Any other string: pick the config whose
versionfield exactly matches that string.
If version is not "latest" and no matching version is found, a
FileNotFoundError is raised listing available versions.
Source code in dcs_simulation_engine/helpers/game_helpers.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
list_characters()
Return available characters from seed data.
Useful for checking available characters when db is not live.
Source code in dcs_simulation_engine/helpers/game_helpers.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
list_games(directory=None)
Return available games.
Source code in dcs_simulation_engine/helpers/game_helpers.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
logging_helpers
Logging helpers for DI Simulation Engine.
configure_logger(source, quiet=False, verbose=0)
Configure Loguru logging.
Source code in dcs_simulation_engine/helpers/logging_helpers.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
infra
Operational / infrastructure helpers (Fly, Docker, etc.).
deploy
Deployment management.
deploy_app(*, game, deployment, version='latest', fly_toml=Path('fly.toml'), env_file=Path('.env'), region=None)
Deploy a game.
Source code in dcs_simulation_engine/infra/deploy.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
destroy_deployment(app_name)
Destroy a deployment.
Source code in dcs_simulation_engine/infra/deploy.py
35 36 37 | |
list_deployments()
List deployments.
Source code in dcs_simulation_engine/infra/deploy.py
9 10 11 12 | |
stop_deployment(*, deployment, logs_out=None, logs_no_tail=True, db_remote=None, db_out=None)
Stop a deployment and optionally download logs + DB.
Source code in dcs_simulation_engine/infra/deploy.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
fly
Fly.io management.
DeployResult
dataclass
Result of a deployment.
Source code in dcs_simulation_engine/infra/fly.py
20 21 22 23 24 25 26 | |
FlyError
Bases: RuntimeError
Raised for Fly-related operational failures.
Source code in dcs_simulation_engine/infra/fly.py
16 17 | |
LoadedEnv
dataclass
Merged env + captured dotenv key/values (for forwarding to flyctl --env).
Source code in dcs_simulation_engine/infra/fly.py
29 30 31 32 33 | |
build_deploy_cmd(config_path, app_name, dotenv_vars)
Build the flyctl deploy command, injecting env vars from .env.
Source code in dcs_simulation_engine/infra/fly.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
build_process_command(interface, *, game, version, tag)
Build the command string that becomes the Fly [processes].web command.
Source code in dcs_simulation_engine/infra/fly.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
check_flyctl()
Verify that flyctl is installed and accessible on PATH.
Source code in dcs_simulation_engine/infra/fly.py
136 137 138 139 | |
deploy_app(*, game, app_name, version='latest', fly_toml=Path('fly.toml'), env_file=Path('.env'), region=None)
Deploy the widget process for a game to Fly.
Source code in dcs_simulation_engine/infra/fly.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
destroy_app(app_name)
Destroy a Fly app.
Source code in dcs_simulation_engine/infra/fly.py
117 118 119 120 121 122 | |
download_db(*, app_name, remote_path, local_path)
Download a file from the Fly app via SFTP.
Source code in dcs_simulation_engine/infra/fly.py
359 360 361 362 363 364 365 366 | |
download_logs_jsonl(*, app_name, out_path, no_tail=True)
Download Fly logs in JSONL format and write to out_path.
Source code in dcs_simulation_engine/infra/fly.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
ensure_app_exists(app_name)
Ensure the Fly app exists. If not, create it.
Source code in dcs_simulation_engine/infra/fly.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
ensure_fly_auth()
Verify flyctl is authenticated (i.e. fly auth whoami works and returns an email).
Source code in dcs_simulation_engine/infra/fly.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
ensure_fly_available()
Verify flyctl is installed and usable.
Source code in dcs_simulation_engine/infra/fly.py
142 143 144 145 146 147 | |
flyctl_json(args)
Run flyctl with --json and return parsed JSON.
Source code in dcs_simulation_engine/infra/fly.py
125 126 127 128 129 130 131 132 133 | |
list_apps()
List Fly apps in the current account.
Source code in dcs_simulation_engine/infra/fly.py
319 320 321 322 323 324 325 326 | |
list_machines(app_name)
List machines for a Fly app.
Source code in dcs_simulation_engine/infra/fly.py
329 330 331 332 333 334 335 336 | |
load_env(env_file=Path('.env'))
Load env vars from .env and ensure FLY_API_TOKEN exists in environment.
Source code in dcs_simulation_engine/infra/fly.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
sftp_get(*, app_name, remote_path, local_path)
Get a file from the Fly app via SFTP.
Source code in dcs_simulation_engine/infra/fly.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
stop_all_machines(app_name)
Stop all machines for a Fly app.
Source code in dcs_simulation_engine/infra/fly.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
update_fly_toml(*, original_toml, app_name, process_cmd, region=None)
Update app/process settings in fly.toml using TOML parsing and serialization.
Source code in dcs_simulation_engine/infra/fly.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
remote
High-level remote Fly deployment lifecycle helpers.
ApiFlyTemplateContext
dataclass
Bases: BaseFlyTemplateContext
Template context for the API Fly config.
Source code in dcs_simulation_engine/infra/remote.py
89 90 91 92 93 94 | |
BaseFlyTemplateContext
dataclass
Shared context fields for generated Fly config templates.
Source code in dcs_simulation_engine/infra/remote.py
80 81 82 83 84 85 86 | |
DbFlyTemplateContext
dataclass
Bases: BaseFlyTemplateContext
Template context for the DB Fly config.
Source code in dcs_simulation_engine/infra/remote.py
104 105 106 107 108 | |
RemoteAppNames
dataclass
Concrete Fly app names for one remote experiment deployment.
Source code in dcs_simulation_engine/infra/remote.py
50 51 52 53 54 55 56 | |
RemoteDeploymentResult
dataclass
Structured output returned after a successful remote deployment.
Source code in dcs_simulation_engine/infra/remote.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
model_dump()
Return a JSON-serializable dict payload.
Source code in dcs_simulation_engine/infra/remote.py
75 76 77 | |
RemoteFlyConfigPaths
dataclass
Concrete file paths for generated Fly TOML configs.
Source code in dcs_simulation_engine/infra/remote.py
120 121 122 123 124 125 126 | |
RemoteLifecycleError
Bases: RuntimeError
Raised when a remote Fly lifecycle operation fails.
Source code in dcs_simulation_engine/infra/remote.py
46 47 | |
RemoteRenderedFlyConfigs
dataclass
Rendered Fly TOML contents for one remote experiment deployment.
Source code in dcs_simulation_engine/infra/remote.py
111 112 113 114 115 116 117 | |
RemoteStatusResult
dataclass
Authenticated experiment status returned for CLI presentation.
Source code in dcs_simulation_engine/infra/remote.py
129 130 131 132 133 134 135 136 137 138 139 140 | |
model_dump()
Return a JSON-serializable dict payload.
Source code in dcs_simulation_engine/infra/remote.py
138 139 140 | |
UiFlyTemplateContext
dataclass
Bases: BaseFlyTemplateContext
Template context for the UI Fly config.
Source code in dcs_simulation_engine/infra/remote.py
97 98 99 100 101 | |
app_url(app_name)
Return the public Fly URL for an app.
Source code in dcs_simulation_engine/infra/remote.py
184 185 186 | |
deploy_remote_experiment(*, config=None, free_play=False, openrouter_key, mongo_seed_path, admin_key=None, fly_api_token=None, region=None, api_app=None, ui_app=None, db_app=None, deploy_apps=None)
Deploy one remote-managed stack and bootstrap its remote admin key.
Source code in dcs_simulation_engine/infra/remote.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | |
derive_remote_app_names(*, experiment_name, api_app=None, ui_app=None, db_app=None)
Return explicit or derived app names for a remote experiment deployment.
Source code in dcs_simulation_engine/infra/remote.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
fetch_remote_status(*, uri, admin_key)
Return the authenticated status payload for one remote deployment.
Source code in dcs_simulation_engine/infra/remote.py
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | |
load_experiment_config(config)
Resolve and load the experiment config selected for remote deployment.
Source code in dcs_simulation_engine/infra/remote.py
560 561 562 563 | |
save_remote_database(*, uri, admin_key, save_db_path)
Download the remote database export archive to the requested local path.
Source code in dcs_simulation_engine/infra/remote.py
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | |
slugify_experiment_name(value)
Normalize an experiment name into a Fly-app-safe slug.
Source code in dcs_simulation_engine/infra/remote.py
146 147 148 149 150 151 152 | |
stop_remote_experiment(*, uri, admin_key, save_db_path, api_app, ui_app, db_app, fly_api_token=None)
Save the remote DB archive, then destroy all Fly apps for the experiment.
Source code in dcs_simulation_engine/infra/remote.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
utils
Utils: pure generic building blocks.
Contents should be: - Is pure and reusable anywhere - Has no knowledge of your app - Operates on basic data types
async_utils
Helpers for working with possibly-awaitable values.
maybe_await(value)
async
Await value when awaitable; otherwise return as-is.
Source code in dcs_simulation_engine/utils/async_utils.py
7 8 9 10 11 | |
auth
Access key generation and verification utilities.
generate_access_key(*, prefix=DEFAULT_KEY_PREFIX)
Generate a random access key string.
Source code in dcs_simulation_engine/utils/auth.py
12 13 14 15 | |
validate_access_key(raw_key)
Validate and normalize a raw access key.
Source code in dcs_simulation_engine/utils/auth.py
18 19 20 21 22 23 24 25 26 27 | |
fingerprint
Fingerprinting utilities for character evaluation QC.
compute_character_evaluation_fingerprint(character, model=DEFAULT_MODEL, updater_system_prompt_template=UPDATER_SYSTEM_TEMPLATE)
Return a SHA-256 hex fingerprint of a character + model + prompt template.
Defaults to the current UpdaterClient model and updater system prompt template, so callers typically only need to pass the character:
fingerprint = compute_character_evaluation_fingerprint(character)
The fingerprint is deterministic: same inputs always produce the same value. Any change to the character sheet, model name, or updater template changes it.
Source code in dcs_simulation_engine/utils/fingerprint.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
paths
Path utilities.
package_games_dir()
Returns the path to the package's games directory.
Source code in dcs_simulation_engine/utils/paths.py
12 13 14 | |
package_root()
Returns the root path of the dcs_simulation_engine package.
Source code in dcs_simulation_engine/utils/paths.py
7 8 9 | |
release_policy
Release policy utilities for the DCS character production pipeline.
Loads the character-release-policy.yml and uses it to compute which characters in prod/characters.json are approved for release, then writes the manifest.
compute_approved_characters(policy, evaluations, prod_chars_by_hid)
Return sorted list of character HIDs approved under policy.
Parameters
policy:
Parsed policy dict (from :func:load_policy).
evaluations:
List of evaluation dicts from character_evaluations.json.
prod_chars_by_hid:
Mapping of hid → character doc for all characters in prod.
A character is approved if it has at least one evaluation that passes
ALL policy criteria:
- scores.icf >= criteria.min_icf_score
- (if require_current_fingerprint) evaluation fingerprint matches
the fingerprint computed from the current character doc, model, and
updater prompt template.
Source code in dcs_simulation_engine/utils/release_policy.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
load_policy(path)
Load and return the character release policy from a YAML file.
Source code in dcs_simulation_engine/utils/release_policy.py
20 21 22 | |
write_manifest(path, approved_hids, policy_version)
Write the release manifest JSON to path.
Creates parent directories if they don't exist.
Source code in dcs_simulation_engine/utils/release_policy.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
serde
Serialization / deserialization (serde) mixin for Pydantic models.
Example Usage: x = X(uid="sys1", short_description="Test")
d = x.to_dict() js = x.to_json(indent=2) ys = x.to_yaml()
x1 = X.from_json(js) x2 = X.from_yaml(ys)
x.save_json("system.json", indent=2) x.save_yaml("system.yaml")
x4 = X.load_json("system.json") x5 = X.load_yaml("system.yaml")
SerdeMixin
Bases: BaseModel
Mixin adding serialization / deserialization methods to Pydantic models.
Source code in dcs_simulation_engine/utils/serde.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
from_json(source, **kw)
classmethod
Instantiate model from a JSON string or a file path with friendly errors.
Source code in dcs_simulation_engine/utils/serde.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
from_yaml(source, **validate_kwargs)
classmethod
Instantiate model from a YAML string or a file path with friendly errors.
Source code in dcs_simulation_engine/utils/serde.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
load_json(path, **validate_kwargs)
classmethod
Load model from a JSON file.
Source code in dcs_simulation_engine/utils/serde.py
124 125 126 127 | |
load_yaml(path, **validate_kwargs)
classmethod
Load model from a YAML file.
Source code in dcs_simulation_engine/utils/serde.py
129 130 131 132 | |
save_json(path, **dump_kwargs)
Save model to a JSON file. Returns the Path.
Source code in dcs_simulation_engine/utils/serde.py
112 113 114 115 116 | |
save_yaml(path, **dump_kwargs)
Save model to a YAML file. Returns the Path.
Source code in dcs_simulation_engine/utils/serde.py
118 119 120 121 122 | |
to_dict(**dump_kwargs)
Convert model to dict. Pass model_dump kwargs if desired.
Source code in dcs_simulation_engine/utils/serde.py
42 43 44 | |
to_json(**dump_kwargs)
Convert model to JSON string.
Source code in dcs_simulation_engine/utils/serde.py
46 47 48 | |
to_yaml(**dump_kwargs)
Convert model to readable YAML.
Pass yaml.safe_dump kwargs if desired (e.g., sort_keys=False).
Source code in dcs_simulation_engine/utils/serde.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
time
UTC time helpers used across runtime and persistence layers.
utc_now()
Return timezone-aware current UTC datetime.
Source code in dcs_simulation_engine/utils/time.py
6 7 8 | |