Files
de-praxis/docs/architecture.md
T

4.9 KiB
Raw Permalink Blame History

Architecture and implementation boundaries

One source of truth

The server owns rolls, preparation, objective flags, pending actions, pressure and endings. Android submits an intent and a description; it cannot supply a roll or write world state. The model receives a recent resolved transcript and objective flags, and can only return an atmospheric paragraph.

flowchart LR
    A[Android operator A] <-->|HTTP + polling| S[Kotlin relay server]
    B[Android operator B] <-->|HTTP + polling| S
    S --> C[Campaign rules]
    C --> D[Atomic room snapshots]
    S --> N[Optional local LLM narrator]

The first server uses the JDK HTTP server to keep the runtime small. It has a bounded pool of eight request threads. A room lock serializes joining, starting and acting; polling reads atomic snapshots without waiting on optional narration. Separate rooms can progress concurrently. Room files are private server state; API snapshots exclude bearer tokens and unrevealed pending text. Atomic file replacement prevents partial snapshots. This is not a multi-process or distributed store.

HTTP contract

All requests/responses use JSON. Private endpoints use Authorization: Bearer <operator token>. A room code alone permits joining a lobby, not reading its contents. Responses use Cache-Control: no-store.

Method Path Body Response
GET /health — status
POST /rooms { "name": "Juli", "role": "ENGINEER" } token, playerId, snapshot
POST /rooms/{code}/join { "name": "Jegor", "role": "ANALYST" } token, playerId, snapshot
GET /rooms/{code} — snapshot
POST /rooms/{code}/start {} snapshot; host only
POST /rooms/{code}/actions request below snapshot
{
  "requestId": "unique-per-operator-action",
  "round": 1,
  "intent": "RESTORE",
  "text": "I bridge the corroded emergency contacts with my probe."
}

Action IDs are persisted and scoped to the operator. Retrying an accepted ID returns the current snapshot without repeating the action, including after server restart. Stale rounds and a second distinct action in the same round return 409. The Android client uses player ID + round as its action ID. All operators' pending actions resolve together: observation first, then crew order, with escape last. Duplicate simultaneous tasks provide preparation if an earlier action completed that task. New operators cannot join an active campaign.

Errors use { "error": "message" } with 400 (invalid input), 401 (invalid token), 403 (host-only operation), 404 (unknown resource), 409 (invalid state), or 413 (oversized body). Names allow 1–24 printable characters; action descriptions allow 1–500 characters; request bodies are limited to 8 KiB.

Narrative contract

The authored scenario guarantees that required information is available: the introduction names the two escape objectives and optional containment, and successful Decode reveals the isolation procedure. There are no random mandatory clues. Failed checks cost time and reveal a persistent shared +2 approach bonus for that task, capped at +4; they cannot erase an objective or introduce an impossible dependency. The countdown guarantees an ending after at most twelve fully submitted rounds; it does not advance in real time while a player is disconnected.

Scenes, investigation clues, failure recovery and the Android reading flow are described in experience.md.

The optional LLM is a presentation layer in v0.1. Its prose is not mechanically parsed. A model could still describe an inconsistent detail, so the structured objective panel, roll events and authored outcomes remain authoritative. A future DM implementation should return typed proposals for validation rather than mutating state directly.

Next vertical slices

  1. Flexible adjudication: translate a player's free-text action into a typed proposed intent, target and check. Validate against scene affordances, and ask the player to clarify ambiguous or consequential interpretations. Add a recorded DM exception event with a reason and bounded effect.
  2. Campaign content: move scene definitions, objective dependencies, clues, escalation thresholds and ending predicates out of Kotlin into validated content files. Preserve multiple routes to mandatory discoveries.
  3. Tactical encounters: enemy profiles, player resources, damage, powers and combat turn order. Keep rolls and combat resolution deterministic under injected randomness for testing.
  4. Co-op resilience: recoverable invite/account identities, AFK policy, host tools, and push updates. Retain action IDs and authoritative sequencing.
  5. Lore and skins: separate scenario structure from setting vocabulary, then support curated lore retrieval and consistent affordances per setting.

Keep scope focused until two people can finish the same short campaign reliably and want to replay it.