Repository: confident-ai/deepeval
Issue: synthesizer: `source_files` misattributed across contexts due to index shadowing in `a_generate_goldens_from_contexts`
Root cause: Algorithmic Error

**Describe the bug**
When calling `Synthesizer.a_generate_goldens_from_contexts(...)` with `source_files` aligned one-to-one with `contexts`, generated goldens incorrectly reuse only the first `max_goldens_per_context` `source_files` across all contexts. Root cause: in the async path, the per-input index shadows the per-context index and is used to index `source_files`.

**To Reproduce**
1. Prepare `contexts: List[List[str]]` and `source_files: List[str]` with equal length, each `source_files[i]` matching `contexts[i]`.
2. Call:
```python
goldens = await synthesizer.a_generate_goldens_from_contexts(
  contexts=contexts,
  include_expected_output=True,
  max_goldens_per_context=2,
  source_files=source_files
)
```
3. Save/inspect the goldens and observe that `source_file` values only come from `source_files[0]` and `source_files[1]`.

**Expected behavior**
Each golden generated for context `i` should have `source_file == source_files[i]`.

**Screenshots**
N/A

**Desktop (please complete the following information):**
- OS: macOS (Darwin 24.6.0)
- Version: deepeval==3.3.2, Python 3.12

**Smartphone (please complete the following information):**
- Device: N/A

**Additional context**
- The sync implementation correctly uses the context index. The async implementation shadows the index and uses the input index when selecting `source_file`.

**Fix proposal (before/after):**

- Before (async path uses input index “index” to read from `source_files`):
```
golden = Golden(
    input=evolved_input,
    context=context,
    expected_output=expected_output,
    source_file=(
        source_files[index]
        if source_files is not None and index < len(source_files)
        else None
    ),
    additional_metadata={
```

- After (rename outer context index and inner input index; use the context index for `source_files`):
```python
async def _a_generate_from_context(
    semaphore: asyncio.Semaphore,
    context: List[str],
    goldens: List[Golden],
    include_expected_output: bool,
    max_goldens_per_context: int,
    source_files: Optional[List[str]],
    context_index: int,  # renamed from index
    progress: Optional[Progress] = None,
    pbar_id: Optional[int] = None,
    context_scores: Optional[List[float]] = None,
):
    ...
    async def process_input(
        input_index: int,  # renamed from index
        data: SyntheticData,
        progress: Optional[Progress] = None,
    ):
        ...
        golden = Golden(
            input=evolved_input,
            context=context,
            expected_output=expected_output,
            source_file=(
                source_files[context_index]
                if source_files is not None and context_index < len(source_files)
                else None
            ),
            additional_metadata={
                "evolutions": evolutions_used,
                "synthetic_input_quality": scores[input_index],
            },
        )
```

Notes:
- Update all usages of the inner variable accordingly: `pbar_evolve_input_ids[input_index]`, `scores[input_index]`.
- Ensure the call site passes the context index as `context_index` (currently `index` from `enumerate(contexts)`).

Workarounds until patched:
- Use the sync `generate_goldens_from_contexts` (correct indexing).
- Or call the async API per context in a loop with sliced `contexts[i:i+1]` and `source_files[i:i+1]`.

Fix this here: https://github.com/confident-ai/deepeval/pull/2022