{
  "name": "memory",
  "description": "Dataset aggregator with transient memory spike from 3x deepcopy in indexing. Tests memory profiling methodology.",
  "eval_type": "memory",
  "test_command": "PYTHONPATH=src uv run python -m pytest tests/ -v",
  "bugs": [
    {
      "id": "index-deepcopy-3x",
      "file": "src/aggregator/core.py",
      "function": "build_lookup_index",
      "description": "Creates 3 deepcopy of every record.__dict__ for each index (by_category, by_source, by_date). 50K records × 3 copies × nested metadata = ~133 MB transient spike.",
      "expected_fix": "Store record references or just IDs in the index instead of full deepcopied dicts. Or build a single dict-of-lists with shared references.",
      "is_dominant": true,
      "peak_contribution_pct": 70
    },
    {
      "id": "record-no-slots",
      "file": "src/aggregator/core.py",
      "function": "Record",
      "description": "Record class uses regular __dict__ — 50K instances carry per-instance dict overhead (~200 bytes each = ~10 MB)",
      "expected_fix": "Use __slots__ to eliminate per-instance __dict__",
      "is_dominant": false,
      "peak_contribution_pct": 15
    },
    {
      "id": "format-json-roundtrip",
      "file": "src/aggregator/core.py",
      "function": "format_results",
      "description": "JSON serialize+deserialize per category for 'integrity check' — creates temporary string copies",
      "expected_fix": "Remove unnecessary round-trip or validate differently",
      "is_dominant": false,
      "peak_contribution_pct": 2
    }
  ],
  "test_file": "tests/test_aggregator.py",
  "test_name": "test_large_dataset",
  "data_size": 50000,
  "memory_profile": {
    "peak_rss_mb": 197,
    "retained_mb": 64,
    "transient_spike_mb": 133,
    "target_peak_mb": 80
  },
  "rubric": {
    "criteria": {
      "used_memory_profiler": 2,
      "correct_profiling_flags": 2,
      "identified_dominant_allocator": 2,
      "fixed_dominant_issue": 2,
      "fixed_secondary_issues": 2
    },
    "total": 10,
    "notes": {
      "used_memory_profiler": "Used memray, tracemalloc, or memory_profiler — not just cProfile",
      "correct_profiling_flags": "For memray: PYTHONMALLOC=malloc and --native. For tracemalloc: sufficient depth. Partial credit for using any memory tool.",
      "identified_dominant_allocator": "Correctly identified build_lookup_index / deepcopy as the peak memory source, not parse_records",
      "fixed_dominant_issue": "Removed unnecessary deepcopy in build_lookup_index — store references or IDs",
      "fixed_secondary_issues": "__slots__ on Record, remove json roundtrip, generator for parse"
    }
  }
}
