{
  "sample_id": "glm-01",
  "model_name": "GLM 5.3 Flash NVIDIA",
  "configuration": "MTP3",
  "sample_type": "code-long",
  "experiment_conditions": {
    "date_jst": "2026-10-26",
    "configured_context_tokens": 262144,
    "gpu_count": 2,
    "speculation": "MTP3"
  },
  "finish_reason": "length",
  "request": {
    "ignore_eos": true,
    "max_tokens": 512,
    "messages": [
      {
        "content": "Write a complete Python 3 module implementing an in-memory event store. Include immutable events, optimistic concurrency checks, per-stream ordering, replay, snapshots and several tests. Explain the design briefly, then provide all code. Continue until the module and tests are complete.",
        "role": "user"
      }
    ],
    "model": "glm53-flash-nvidia-vllm",
    "reasoning_effort": "low",
    "stream": true,
    "stream_options": {
      "include_usage": true
    },
    "temperature": 0
  },
  "response": {
    "choices": [
      {
        "finish_reason": "length",
        "index": 0,
        "message": {
          "content": "# In-Memory Event Store — Design Overview\n\n**Core concepts:**\n\n- **Immutable events**: `Event` is a frozen dataclass. Once created, it can't be mutated.\n- **Per-stream ordering**: Each stream has its own version number starting at 0. Appends specify an `expected_version` for **optimistic concurrency control** — if another writer appended first, the append fails with `ConcurrencyError`.\n- **Global ordering**: Events also get a monotonically increasing global position, useful for projections/replay across all streams.\n- **Replay**: `read_stream` returns events for one stream; `read_all` returns everything in global order; `replay` folds events through a user-supplied handler to rebuild state.\n- **Snapshots**: A snapshot stores the state of a stream at a given version, so replay can start from the snapshot instead of version 0. Snapshots are also immutable.\n- **Thread safety**: A single `RLock` guards all mutations, making the store safe for concurrent use while keeping appends atomic.\n\n```python\n\"\"\"\ninmem_event_store.py\n\nA simple in-memory event store with:\n  * immutable events\n  * optimistic concurrency control (expected_version checks)\n  * per-stream ordering + global ordering\n  * replay (per-stream and global)\n  * snapshots\n\nPython 3.8+, standard library only.\n\"\"\"\n\nfrom __future__ import annotations\n\nimport copy\nimport itertools\nimport threading\nimport unittest\nfrom dataclasses import dataclass, field, replace\nfrom typing import Any, Callable, Dict, Iterable, List, Optional, Tuple\n\n\n# --------------------------------------------------------------------------\n# Exceptions\n# --------------------------------------------------------------------------\n\nclass EventStoreError(Exception):\n    \"\"\"Base class for event store errors.\"\"\"\n\n\nclass StreamNotFoundError(EventStoreError):\n    pass\n\n\nclass ConcurrencyError(EventStoreError):\n    def __init__(self, stream_id: str, expected: int, actual: int):\n        self.stream_id = stream_id\n        self.expected = expected\n        self.actual = actual\n        super().__init__(\n            f\"Concurrency conflict on stream '{stream_id}': \"\n            f\"expected version {expected}, actual version {actual}\"\n        )\n\n\nclass SnapshotVersionError(EventStoreError):\n    pass\n\n\n# --------------------------------------------------------------------------\n# Immutable event\n# --------------------------------------------------------------------------\n\n@dataclass(frozen=True)\nclass Event:\n    \"\"\"\n    An immutable domain event.\n\n   ",
          "role": "assistant"
        }
      }
    ],
    "model": "glm-5.3-flash-nvidia",
    "object": "chat.completion",
    "usage": {
      "completion_tokens": 512,
      "completion_tokens_details": {
        "reasoning_tokens": 27
      },
      "prompt_tokens": 64,
      "prompt_tokens_details": {
        "cached_tokens": 64,
        "created_cache_tokens": 0
      },
      "total_tokens": 576
    }
  },
  "omissions": [
    "authentication headers",
    "internal endpoints",
    "response and correlation identifiers",
    "reasoning text"
  ]
}
