"""长任务轮询端点 GET /jobs/:id(ARCH §7.4)。""" from __future__ import annotations import uuid from typing import Annotated from fastapi import APIRouter, Depends from ww_core.domain import JobRepo from ww_shared import AppError, ErrorCode, ErrorEnvelope from ww_api.schemas.jobs import JobResponse from ww_api.services.project_deps import get_job_repo router = APIRouter(prefix="/jobs", tags=["jobs"]) @router.get( "/{job_id}", responses={404: {"model": ErrorEnvelope, "description": "job 不存在"}}, ) async def get_job( job_id: uuid.UUID, job_repo: Annotated[JobRepo, Depends(get_job_repo)], ) -> JobResponse: job = await job_repo.get(job_id) if job is None: raise AppError(ErrorCode.NOT_FOUND, f"job {job_id} not found") return JobResponse( id=job.id, kind=job.kind, status=job.status, progress=job.progress, result=job.result, error=job.error, )