<reasoning_content>
Here's a thinking process:

1.  **Understand the User's Request:**
   - **Input:** A conceptual single-file Python implementation containing `Job`, `JobQueue`, `PriorityQueue`, and `process_with_retry`.
   - **Output:** A refactored package structure with four files: `__init__.py`, `core.py`, `retry.py`, `priority.py`.
   - **Requirements:**
     - Maintain all existing functionality
     - Proper imports between modules
     - Clean public API in `__init__.py`
     - Each module has a single responsibility
     - Provide the content of each file.

2.  **Analyze the Target Structure & Responsibilities:**
   - `queue/core.py`: `Job` dataclass, basic queue operations (FIFO queue, enqueue/dequeue, maybe a simple `Queue` class or just the base `JobQueue`).
   - `queue/priority.py`: `PriorityQueue` implementation (likely extending or wrapping `heapq` or using a custom priority mechanism).
   - `queue/retry.py`: `process_with_retry` function with exponential backoff.
   - `queue/__init__.py`: Exports `Job`, `JobQueue`, `PriorityQueue` (and maybe `process_with_retry` if it's part of the public API, but the prompt says `__init__.py` exports `JobQueue, Job`. I'll stick to that, but I'll make sure `process_with_retry` is accessible if needed, or just follow the prompt exactly).

3.  **Design Each Module (Mental Draft):**

   *`queue/core.py`*
   - Needs `Job` dataclass. What fields? Typically `id`, `payload`, `status`, `created_at`, etc. I'll define a reasonable default.
   - Needs `JobQueue` class. Basic operations: `enqueue(job)`, `dequeue()`, `is_empty()`, maybe `size()`.
   - I'll use `collections.deque` for efficiency.
   - Keep it simple but functional.

   *`queue/priority.py`*
   - Needs `PriorityQueue` class.
   - Should handle priority-based dequeue.
   - Can use `heapq` internally.
   - Should be compatible with `Job` from `core.py`.
   - I'll implement a standard priority queue with `put(item, priority)` and `get()` methods, or align with `JobQueue` interface but prioritize. Actually, the prompt says `PriorityQueue` is a separate class. I'll make it a standalone class that works with `Job` objects, or maybe a generic priority queue that can be used interchangeably. To keep it clean, I'll make `PriorityQueue` a class that manages jobs with priorities, using `heapq`.

   *`queue/retry.py`*
   - Needs `process_with_retry(func, *args, max_retries=3, base_delay=1.0, **kwargs)`.
   - Implements exponential backoff.
   - Should handle exceptions.
   - Standard retry logic: try, catch, sleep, retry.

   *`queue/__init__.py`*
   - Import and export `Job`, `JobQueue` from `core`.
   - Import and export `PriorityQueue` from `priority`.
   - Set up `__all__` for clean API.
   - Follow prompt: `# Exports: JobQueue, Job`

4.  **Refine & Write Code (Mental to Actual):**

   *`queue/core.py`*
   ```python
   from __future__ import annotations
   from dataclasses import dataclass, field
   from typing import Any, Optional
   import time
   from collections import deque

   @dataclass
   class Job:
       id: str
       payload: Any
       status: str = "pending"
       created_at: float = field(default_factory=time.time)
       result: Optional[Any] = None

   class JobQueue:
       def __init__(self):
           self._queue = deque()

       def enqueue(self, job: Job) -> None:
           self._queue.append(job)

       def dequeue(self) -> Optional[Job]:
           return self._queue.popleft() if self._queue else None

       def is_empty(self) -> bool:
           return len(self._queue) == 0

       def __len__(self) -> int:
           return len(self._queue)
   ```

   *`queue/priority.py`*
   ```python
   from __future__ import annotations
   import heapq
   from typing import Any, Optional, Tuple
   from queue.core import Job

   class PriorityQueue:
       def __init__(self):
           self._heap: list[Tuple[int, float, Job]] = []
           self._counter = 0  # Tie-breaker for same priority

       def enqueue(self, job: Job, priority: int = 0) -> None:
           # heapq is a min-heap, so lower priority number = higher priority
           self._counter += 1
           heapq.heappush(self._heap, (priority, self._counter, job))

       def dequeue(self) -> Optional[Job]:
           if self._heap:
               _, _, job = heapq.heappop(self._heap)
               return job
           return None

       def is_empty(self) -> bool:
           return len(self._heap) == 0

       def __len__(self) -> int:
           return len(self._heap)
   ```

   *`queue/retry.py`*
   ```python
   from __future__ import annotations
   import time
   import random
   from typing import Callable, Any

   def process_with_retry(
       func: Callable[..., Any],
       *args: Any,
       max_retries: int = 3,
       base_delay: float = 1.0,
       max_delay: float = 60.0,
       exponential_base: float = 2.0,
       jitter: bool = True,
       **kwargs: Any
   ) -> Any:
       last_exception = None
       for attempt in range(max_retries + 1):
           try:
               return func(*args, **kwargs)
           except Exception as e:
               last_exception = e
               if attempt == max_retries:
                   break

               delay = min(base_delay * (exponential_base ** attempt), max_delay)
               if jitter:
                   delay *= (0.5 + random.random())
               time.sleep(delay)
       raise last_exception
   ```

   *`queue/__init__.py`*
   ```python
   from queue.core import Job, JobQueue
   from queue.priority import PriorityQueue

   __all__ = ["Job", "JobQueue", "PriorityQueue"]
   ```

5.  **Check Against Requirements:**
   - *Maintain all existing functionality*: Yes, covers Job, JobQueue, PriorityQueue, process_with_retry.
   - *Proper imports between modules*: `priority.py` imports `Job` from `core.py`. `retry.py` is standalone. `__init__.py` imports from submodules. Relative imports are used in `__init__.py`. In `priority.py`, I used `from queue.core import Job`. Since it's a package, relative imports are safer: `from .core import Job`. I'll fix that.
   - *Clean public API in __init__.py*: Yes, uses `__all__` and imports exactly what's needed.
   - *Each module has a single responsibility*: 
     - `core.py`: Job dataclass + FIFO queue
     - `priority.py`: Priority queue implementation
     - `retry.py`: Retry logic with backoff
     - `__init__.py`: Package initialization & exports
   - *Provide the content of each file*: Will output exactly that.

   Let's refine the imports to use relative imports properly for a package:
   In `priority.py`: `from .core import Job`
   In `__init__.py`: `from .core import Job, JobQueue` and `from .priority import PriorityQueue`
   In `retry.py`: standalone, no internal imports needed.

   Also, I should make sure the code is robust and follows PEP 8. I'll add type hints and docstrings for professionalism.

   One thing: The prompt says `# Exports: JobQueue, Job` for `__init__.py`. I'll stick to that. I won't export `process_with_retry` unless requested, but I'll make sure it's accessible if someone does `from queue import retry` or similar. Actually, it's common to export everything in `__init__.py`, but I'll follow the prompt strictly.

   Let's double-check the `PriorityQueue` implementation. Using a counter for tie-breaking is good practice with `heapq` when items are not directly comparable. `Job` might not be comparable by default. The counter solves that.

   `process_with_retry` looks solid. Standard exponential backoff with jitter.

   I'll structure the output clearly, showing each file's content.

   One minor adjustment: In `core.py`, I'll add a simple `__repr__` or keep it as dataclass default. Dataclass default is fine.
   In `priority.py`, I'll make sure the import is relative: `from .core import Job`.
   In `__init__.py`, I'll use relative imports: `from .core import Job, JobQueue` and `from .priority import PriorityQueue`.

   Let's write it out carefully.

   Structure:
   ```
   queue/
   ├── __init__.py
   ├── core.py
   ├── priority.py
   └── retry.py
   ```

   I'll generate the content now.
   Self-Correction/Verification during thought:
   - Should `PriorityQueue` inherit from `JobQueue`? The prompt says "Priority queue implementation", implying it's a separate class. I'll keep it separate but with a similar interface (`enqueue`, `dequeue`, `is_empty`, `__len__`).
   - `process_with_retry` doesn't need to be in `__init__.py` per the prompt's comment, but I'll note it's available via `queue.retry`.
   - I'll add type hints and docstrings to make it production-ready.
   - I'll ensure relative imports are used correctly.

   All looks good. I'll produce the response. 
   Output matches the refined code.✅
   Structure check:
   queue/__init__.py
   queue/core.py
   queue/priority.py
   queue/retry.py
   Content matches requirements.
   Ready. 
   Output generation. 
   [Done] 
   *Self-Correction/Note during generation prep*: 
   I should make sure the imports in `priority.py` work correctly when the package is used. `from .core import Job` is correct for a package. 
   I'll also add a small example of how to use it in the response, but the prompt just asks for the file contents. I'll stick to the files.
   I'll format it clearly.
   All good. 
   Proceeds. 
   [Output Generation] -> *See response.* 
   *(Note: I'll make sure the code is complete, well-typed, and follows modern Python practices.)*
   `core.py`: Job dataclass, JobQueue (deque-based)
   `priority.py`: PriorityQueue (heapq-based, relative import)
   `retry.py`: process_with_retry (exponential backoff + jitter)
   `__init__.py`: relative imports, __all__
   Matches perfectly.✅
   Output matches response. 
   [Done]

</reasoning_content>

<content>
Here's the refactored package structure with clean separation of concerns, proper relative imports, and a focused public API.

### `queue/__init__.py`
```python
"""Queue package providing job management, priority queuing, and retry mechanisms."""

from .core import Job, JobQueue
from .priority import PriorityQueue

__all__ = ["Job", "JobQueue", "PriorityQueue"]
```

### `queue/core.py`
```python
"""Core job definition and standard FIFO queue implementation."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any, Optional
import time
from collections import deque


@dataclass
class Job:
    """Represents a unit of work to be processed."""
    id: str
    payload: Any
    status: str = "pending"
    created_at: float = field(default_factory=time.time)
    result: Optional[Any] = None

    def __repr__(self) -> str:
        return f"Job(id={self.id!r}, status={self.status!r})"


class JobQueue:
    """Thread-safe-ish FIFO queue for processing jobs in order of arrival."""

    def __init__(self) -> None:
        self._queue: deque[Job] = deque()

    def enqueue(self, job: Job) -> None:
        """Add a job to the end of the queue."""
        self._queue.append(job)

    def dequeue(self) -> Optional[Job]:
        """Remove and return the job at the front of the queue."""
        return self._queue.popleft() if self._queue else None

    def is_empty(self) -> bool:
        """Return True if the queue contains no jobs."""
        return len(self._queue) == 0

    def __len__(self) -> int:
        return len(self._queue)
```

### `queue/priority.py`
```python
"""Priority queue implementation using a min-heap."""

from __future__ import annotations

import heapq
from typing import Optional, Tuple
from .core import Job


class PriorityQueue:
    """Priority-based job queue. Lower priority values are processed first."""

    def __init__(self) -> None:
        self._heap: list[Tuple[int, int, Job]] = []
        self._counter = 0  # Monotonic counter for stable sorting

    def enqueue(self, job: Job, priority: int = 0) -> None:
        """Add a job with the given priority. Lower integers = higher priority."""
        self._counter += 1
        # Tuple comparison: (priority, counter, job)
        # Counter breaks ties and prevents comparison errors between Job objects
        heapq.heappush(self._heap, (priority, self._counter, job))

    def dequeue(self) -> Optional[Job]:
        """Remove and return the job with the highest priority."""
        if self._heap:
            _, _, job = heapq.heappop(self._heap)
            return job
        return None

    def is_empty(self) -> bool:
        """Return True if the queue contains no jobs."""
        return len(self._heap) == 0

    def __len__(self) -> int:
        return len(self._heap)
```

### `queue/retry.py`
```python
"""Retry logic with exponential backoff and jitter."""

from __future__ import annotations

import random
import time
from typing import Any, Callable


def process_with_retry(
    func: Callable[..., Any],
    *args: Any,
    max_retries: int = 3,
    base_delay: float = 1.0,
    max_delay: float = 60.0,
    exponential_base: float = 2.0,
    jitter: bool = True,
    **kwargs: Any,
) -> Any:
    """
    Execute a function with exponential backoff retry logic.

    Args:
        func: The function to execute.
        *args: Positional arguments for the function.
        max_retries: Maximum number of retry attempts.
        base_delay: Initial delay in seconds.
        max_delay: Maximum delay cap in seconds.
        exponential_base: Base for exponential calculation.
        jitter: Whether to add random jitter to prevent thundering herd.
        **kwargs: Keyword arguments for the function.

    Returns:
        The result of the function on success.

    Raises:
        The last exception if all retries are exhausted.
    """
    last_exception = None

    for attempt in range(max_retries + 1):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            last_exception = e
            if attempt == max_retries:
                break

            # Calculate delay: base_delay * (exponential_base ** attempt)
            delay = min(base_delay * (exponential_base ** attempt), max_delay)
            
            # Add jitter: random value between 0% and 100% of delay
            if jitter:
                delay *= (0.5 + random.random())
                
            time.sleep(delay)

    raise last_exception
```

### Key Improvements Made:
1. **Single Responsibility**: Each file handles exactly one domain (data/queue, priority logic, retry logic, package exports).
2. **Relative Imports**: Used `from .core import Job` and `from .priority import PriorityQueue` to ensure the package works correctly whether imported as `queue` or installed as a dependency.
3. **Stable Priority Queue**: Added a monotonic counter in `PriorityQueue` to break ties safely without requiring `Job` objects to be comparable.
4. **Production-Ready Retry**: Added jitter, max delay cap, and proper exception bubbling to prevent thundering herd problems.
5. **Clean Public API**: `__init__.py` explicitly defines `__all__` and only exposes the core queue components, keeping internal modules like `retry` accessible but not polluting the top-level namespace.
</content>