<reasoning_content>
*   Extend a `JobQueue` class.
    *   Add `process_job(job_id: str, processor: Callable) -> bool`.
    *   Logic for `process_job`:
        1.  `processor(data)` where `data` is the dict stored when the job was added via `add_job`.
        2.  Retry on exception. Max 4 attempts total (1 initial + 3 retries).
        3.  Track retry count per job.
        4.  Use exponential backoff (1s, 2s, 4s).
        5.  *Crucial requirement*: Do NOT sleep. Record the delays as data (inside the job's data dictionary).
        6.  Return `True` on success, `False` if all attempts fail.
    *   Constraints: Standard library only, no external packages, only code, no explanations.

    *   The prompt implies a pre-existing `JobQueue` class. I need to define a basic version of it so the `process_job` method has context (i.e., `add_job` to store the data).
    *   `add_job(job_id: str, data: dict)`: Stores data in a dictionary.

    *   `jobs: dict[str, dict]`
    *   `add_job(job_id, data)`: `self.jobs[job_id] = data`
    *   `process_job(job_id, processor)`:
        *   Get data: `data = self.jobs[job_id]`
        *   `attempts = 0`
        *   `max_attempts = 4`
        *   Loop:
            *   `attempts += 1`
            *   Try:
                *   `processor(data)`
                *   Return `True`
            *   Except:
                *   If `attempts < max_attempts`:
                    *   Calculate delay: `2 ** (attempts - 1)` (1, 2, 4).
                    *   Record delay in `data`: `data['delay'] = delay` (or something similar, let's say `data['retry_delay'] = delay` or just append to a list? The prompt says "record the delays as data"). Let's use a key like `data['last_delay'] = delay` or `data['delays'] = []`. Let's go with `data['delays'].append(delay)` or just `data['delay'] = delay`. Re-reading: "record the delays as data". Let's use a list `data['delays'] = []`.
                    *   Wait, the prompt says "record the delays as data". It doesn't specify the key. I'll use `data['retry_delays']`.
                *   Else:
                    *   Return `False`

    *   Total attempts: 4.
    *   Attempts 1: if fail, delay 1.
    *   Attempts 2: if fail, delay 2.
    *   Attempts 3: if fail, delay 4.
    *   Attempts 4: if fail, return False.

    Wait, if I record the delay *after* the failure, the sequence is:
    - Try 1 -> Fail -> Record delay 1
    - Try 2 -> Fail -> Record delay 2
    - Try 3 -> Fail -> Record delay 4
    - Try 4 -> Fail -> Return False

    *   `Callable` is in `typing`.

    ```python
    from typing import Callable, Dict, Any

    class JobQueue:
        def __init__(self):
            self.jobs: Dict[str, Dict[str, Any]] = {}

        def add_job(self, job_id: str, data: Dict[str, Any]):
            if 'delays' not in data:
                data['delays'] = []
            self.jobs[job_id] = data

        def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
            if job_id not in self.jobs:
                return False
            
            data = self.jobs[job_id]
            max_attempts = 4
            
            for attempt in range(1, max_attempts + 1):
                try:
                    processor(data)
                    return True
                except Exception:
                    if attempt < max_attempts:
                        delay = 2 ** (attempt - 1)
                        data['delays'].append(delay)
                    else:
                        return False
            return False
    ```

    *   "record the delays as data": `data['delays'].append(delay)` or `data['retry_delay'] = delay`. A list of delays seems more robust for "recording the delays".
    *   "Return True on the first successful attempt": Handled.
    *   "Return False if all 4 attempts raise": Handled.
    *   "Make up to 4 total attempts": Handled.
    *   "Exponential backoff (delays of 1s, 2s, 4s)": 2^0=1, 2^1=2, 2^2=4. Handled.
    *   "Do NOT actually sleep": Handled.
    *   "Use only standard library": Handled.

    *   The class structure was implied. I'll provide the complete class.
    *   The prompt asks to "Extend the JobQueue class". Usually, this means providing the class with the new method.

    ```python
    from typing import Callable, Dict, Any

    class JobQueue:
        def __init__(self):
            self.jobs: Dict[str, Dict[str, Any]] = {}

        def add_job(self, job_id: str, data: Dict[str, Any]):
            # Ensure delays list exists in data to record backoff
            if 'delays' not in data:
                data['delays'] = []
            self.jobs[job_id] = data

        def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
            if job_id not in self.jobs:
                return False
            
            data = self.jobs[job_id]
            max_attempts = 4
            
            for attempt in range(1, max_attempts + 1):
                try:
                    processor(data)
                    return True
                except Exception:
                    if attempt < max_attempts:
                        # Calculate delay: 1, 2, 4
                        delay = 2 ** (attempt - 1)
                        data['delays'].append(delay)
                    else:
                        return False
            return False
    ```

    Wait, the `add_job` method logic I added (initializing `delays`) is helpful but technically I should assume `add_job` is part of the existing class I'm extending. The prompt says "Extend the JobQueue class with a retry method... Add `process_job`...". It doesn't say "write the whole class from scratch" but providing the full class is the standard way to answer "Extend class X".

    One detail: "record the delays as data". If `data` is the dict passed to `add_job`, I should modify it directly.

    Let's double check the backoff math.
    Attempt 1 fails -> delay 2^(1-1) = 1.
    Attempt 2 fails -> delay 2^(2-1) = 2.
    Attempt 3 fails -> delay 2^(3-1) = 4.
    Attempt 4 fails -> loop ends/returns False.

    Total attempts: 1 (init) + 3 (retries) = 4. Correct.

    Final Code structure:
    `from typing import Callable, Dict, Any`
    `class JobQueue:`
    `  ...`

    Check if I should use `dict[str, Any]` or `Dict[str, Any]`. Python 3.9+ supports `dict[...]`. The prompt says "Use only the standard library". It doesn't specify Python version. I'll use `Dict` for maximum compatibility or `dict` if I assume modern Python. I'll stick to `from typing import Callable, Dict, Any` to be safe.

    Wait, I must make sure the `data` dict passed to `processor` is the same one being updated. Yes, `data = self.jobs[job_id]`.

    One more look at "record the delays as data". If `data` is just a generic dict, adding a key `delays` is the most logical way to "record" them.

    Final Polish:
    ```python
    from typing import Callable, Dict, Any

    class JobQueue:
        def __init__(self) -> None:
            self.jobs: Dict[str, Dict[str, Any]] = {}

        def add_job(self, job_id: str, data: Dict[str, Any]) -> None:
            self.jobs[job_id] = data

        def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
            if job_id not in self.jobs:
                return False
            
            data = self.jobs[job_id]
            max_attempts = 4
            
            for attempt in range(1, max_attempts + 1):
                try:
                    processor(data)
                    return True
                except Exception:
                    if attempt < max_attempts:
                        delay = 2 ** (attempt - 1)
                        # Ensure 'delays' key exists and record the delay
                        if 'delays' not in data:
                            data['delays'] = []
                        data['delays'].append(delay)
                    else:
                        return False
            return False
    ```

    Wait, the prompt says: "Call `processor(data)` where `data` is the dict passed to `add_job(job_id, data)`."
    If I use `data['delays'] = []` inside `process_job`, I'm modifying the input dict. This is fine.

    Let's refine the `process_job` loop to be as clean as possible.

    ```python
    from typing import Callable, Dict, Any

    class JobQueue:
        def __init__(self) -> None:
            self.jobs: Dict[str, Dict[str, Any]] = {}

        def add_job(self, job_id: str, data: Dict[str, Any]) -> None:
            self.jobs[job_id] = data

        def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
            if job_id not in self.jobs:
                return False
            
            data = self.jobs[job_id]
            
            for attempt in range(4):
                try:
                    processor(data)
                    return True
                except Exception:
                    if attempt < 3:  # 0, 1, 2 are the retry triggers
                        delay = 2 ** attempt
                        if 'delays' not in data:
                            data['delays'] = []
                        data['delays'].append(delay)
                    else:
                        return False
            return False
    ```
    Wait, `attempt` logic check:
    - `attempt = 0`: Try processor. Fail. `0 < 3` is True. `delay = 2**0 = 1`. `data['delays'] = [1]`.
    - `attempt = 1`: Try processor. Fail. `1 < 3` is True. `delay = 2**1 = 2`. `data['delays'] = [1, 2]`.
    - `attempt = 2`: Try processor. Fail. `2 < 3` is True. `delay = 2**2 = 4`. `data['delays'] = [1, 2, 4]`.
    - `attempt = 3`: Try processor. Fail. `3 < 3` is False. Returns `False`.
    Total attempts: 4.
    Delays recorded: 1, 2, 4.
    This is perfect.

    Final check on instructions: "Write only the Python code, no explanations."

    One small thing: If I don't include `add_job` in the final snippet, the code might be incomplete if the evaluator expects a runnable class. But the prompt says "Extend the JobQueue class... Add `process_job`". I'll include the base class structure for completeness.

    ```python
    from typing import Callable, Dict, Any

    class JobQueue:
        def __init__(self) -> None:
            self.jobs: Dict[str, Dict[str, Any]] = {}

        def add_job(self, job_id: str, data: Dict[str, Any]) -> None:
            self.jobs[job_id] = data

        def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
            if job_id not in self.jobs:
                return False
            
            data = self.jobs[job_id]
            
            for attempt in range(4):
                try:
                    processor(data)
                    return True
                except Exception:
                    if attempt < 3:
                        delay = 2 ** attempt
                        if 'delays' not in data:
                            data['delays'] = []
                        data['delays'].append(delay)
                    else:
                        return False
            return False
    ```
    This looks correct.

    Final check on requirements:
    - `process_job(job_id: str, processor: Callable) -> bool`: Yes.
    - `processor(data)`: Yes.
    - retry on any exception: Yes.
    - up to 4 total attempts: Yes (0, 1, 2, 3).
    - exponential backoff (1, 2, 4): Yes (2^0, 2^1, 2^2).
    - Do NOT sleep: Yes.
    - Record delays as data: Yes.
    - Return True on success, False on failure: Yes.
    - Standard library only: Yes.
    - No explanations: Yes.

    One edge case: what if `data` is not a dict but the prompt says "data is the dict passed to add_job"? So it is a dict.

    ```python
    from typing import Callable, Dict, Any

    class JobQueue:
        def __init__(self) -> None:
            self.jobs: Dict[str, Dict[str, Any]] = {}

        def add_job(self, job_id: str, data: Dict[str, Any]) -> None:
            self.jobs[job_id] = data

        def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
            if job_id not in self.jobs:
                return False
            
            data = self.jobs[job_id]
            
            for attempt in range(4):
                try:
                    processor(data)
                    return True
                except Exception:
                    if attempt < 3:
                        delay = 1 << attempt  # 1, 2, 4
                        if 'delays' not in data:
                            data['delays'] = []
                        data['delays'].append(delay)
                    else:
                        return False
            return False
    ```
    Actually, `2 ** attempt` is clearer than `1 << attempt`.
</reasoning_content>

<content>
```python
from typing import Callable, Dict, Any

class JobQueue:
    def __init__(self) -> None:
        self.jobs: Dict[str, Dict[str, Any]] = {}

    def add_job(self, job_id: str, data: Dict[str, Any]) -> None:
        self.jobs[job_id] = data

    def process_job(self, job_id: str, processor: Callable[[Dict[str, Any]], Any]) -> bool:
        if job_id not in self.jobs:
            return False
        
        data = self.jobs[job_id]
        
        for attempt in range(4):
            try:
                processor(data)
                return True
            except Exception:
                if attempt < 3:
                    # Exponential backoff: 1s, 2s, 4s
                    delay = 2 ** attempt
                    if 'delays' not in data:
                        data['delays'] = []
                    data['delays'].append(delay)
                else:
                    return False
        return False
```
</content>