{
  "sample_id": "nemotron-01",
  "model_name": "Nemotron 3.5 Super VL",
  "configuration": "MTP5",
  "sample_type": "code-long",
  "experiment_conditions": {
    "date_jst": "2026-10-26",
    "configured_context_tokens": 131072,
    "gpu_count": 1,
    "speculation": "MTP5"
  },
  "finish_reason": "length",
  "request": {
    "chat_template_kwargs": {
      "enable_thinking": false
    },
    "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": "nemotron35-super-vl-nvfp4-vllm",
    "stream": true,
    "stream_options": {
      "include_usage": true
    },
    "temperature": 0
  },
  "response": {
    "choices": [
      {
        "finish_reason": "length",
        "index": 0,
        "message": {
          "content": "### Design Overview\n\nThis module implements an **in-memory event store** using the Event Sourcing pattern. The core concepts are:\n\n1.  **Immutable Events**: Once an event is appended to a stream, it cannot be modified. It is represented as a frozen dataclass.\n2.  **Streams**: A stream is a logical sequence of events identified by a `stream_id`. Events within a stream are strictly ordered by a `version` number.\n3.  **Optimistic Concurrency Control (OCC)**: To prevent race conditions where two processes modify the same stream simultaneously, the store uses an `expected_version`. If the current version of the stream does not match the expected version, a `ConcurrencyError` is raised.\n4.  **Snapshots**: To avoid replaying thousands of events to reconstruct an aggregate's state, the store supports snapshots. A snapshot captures the state at a specific version. When loading a stream, the store loads the latest snapshot and only replays events occurring after that version.\n5.  **Replay**: The ability to iterate through all events in a stream from a specific starting version to the end.\n\n---\n\n### The Module: `event_store.py`\n\n```python\nimport threading\nfrom dataclasses import dataclass, field\nfrom typing import Any, Callable, Dict, List, Optional, TypeVar, Generic\nfrom uuid import UUID, uuid4\n\nT = TypeVar('T')\n\nclass EventStoreError(Exception):\n    \"\"\"Base exception for event store errors.\"\"\"\n    pass\n\nclass ConcurrencyError(EventStoreError):\n    \"\"\"Raised when optimistic concurrency check fails.\"\"\"\n    pass\n\nclass StreamNotFoundError(EventStoreError):\n    \"\"\"Raised when a stream does not exist.\"\"\"\n    pass\n\n@dataclass(frozen=True)\nclass Event(Generic[T]):\n    \"\"\"\n    An immutable event.\n    :param stream_id: The ID of the stream this event belongs to.\n    :param version: The sequential version of this event within the stream.\n    :param event_type: A string describing the type of event (e.g., 'ItemAdded').\n    :param data: The payload of the event.\n    :param timestamp: Optional timestamp of occurrence.\n    \"\"\"\n    stream_id: str\n    version: int\n    event_type: str\n    data: T\n    timestamp: float = field(default_factory=lambda: __import__('time').time())\n\n@dataclass\nclass Snapshot(Generic[T]):\n    \"\"\"\n",
          "role": "assistant"
        }
      }
    ],
    "model": "nemotron-3.5-super-vl",
    "object": "chat.completion",
    "usage": {
      "completion_tokens": 512,
      "completion_tokens_details": {
        "reasoning_tokens": 0
      },
      "prompt_tokens": 70,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "created_cache_tokens": 0
      },
      "total_tokens": 582
    }
  },
  "omissions": [
    "authentication headers",
    "internal endpoints",
    "response and correlation identifiers",
    "reasoning text"
  ]
}
