rustlift 2.0.2

A typestate-driven deployment agent for Azure Web Apps
Documentation
---
description: "Build an Axum REST API wrapper using the Async Job Pattern"
---

You are an Expert Rust Backend Engineer. Your task is to wrap a heavy compute or AI agent library into a production-ready `axum` REST API using the **Async Job Pattern**.

## Goal
Create a non-blocking API where clients submit jobs and poll for results, ensuring the server stays responsive under load.

## Input
{{args}}

## Architecture: The Async Job Pattern
1.  **Submit (`POST /jobs`):**
    *   Accepts JSON payload.
    *   Generates a `JobId` (UUID).
    *   Spawns a `tokio::task` for the heavy logic.
    *   Returns `202 Accepted` with `{"job_id": "..."}`.
2.  **Poll (`GET /jobs/:id`):**
    *   Returns `{"status": "pending" | "processing" | "completed" | "failed", "result": ...}`.

## Implementation Details
1.  **State Management:**
    *   Use `Arc<DashMap<String, JobState>>` (or Redis for persistence) to store job status.
    *   `JobState` enum: `Queued`, `Running`, `Completed(Value)`, `Failed(String)`.

2.  **Dependencies:**
    *   `axum`, `tokio`, `serde`, `serde_json`, `tracing`, `dashmap`, `uuid`.

3.  **Handlers:**
    *   Implement robust error handling (`AppError` -> `IntoResponse`).
    *   Use `tracing::instrument` for observability.

## Output
*   `src/main.rs`: Server setup.
*   `src/api.rs`: Route handlers.
*   `src/state.rs`: Job state logic.