generated from john/python-template
claude-sonnet-5 review: Phase 5 (final) implemented by gpt-5.3-codex
Quality Gate / gate (push) Failing after 37s
Quality Gate / gate (push) Failing after 37s
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
"""Health endpoint routes."""
|
||||
|
||||
from typing import NotRequired
|
||||
from typing import TypedDict
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import Request
|
||||
|
||||
@@ -8,10 +11,21 @@ from transcription.worker import resolve_worker_health
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
def healthz(request: Request) -> dict[str, object]:
|
||||
class WorkerHealthPayload(TypedDict):
|
||||
state: str
|
||||
error_id: NotRequired[str]
|
||||
error_category: NotRequired[str]
|
||||
|
||||
|
||||
class HealthPayload(TypedDict):
|
||||
status: str
|
||||
worker: WorkerHealthPayload
|
||||
|
||||
|
||||
def healthz(request: Request) -> HealthPayload:
|
||||
"""Return health status with worker-liveness signal."""
|
||||
worker = resolve_worker_health(request.app.state)
|
||||
payload: dict[str, object] = {
|
||||
payload: HealthPayload = {
|
||||
"status": "ok",
|
||||
"worker": {
|
||||
"state": worker.state,
|
||||
@@ -25,6 +39,6 @@ def healthz(request: Request) -> dict[str, object]:
|
||||
|
||||
|
||||
@router.get("/healthz")
|
||||
def healthz_route(request: Request) -> dict[str, object]:
|
||||
def healthz_route(request: Request) -> HealthPayload:
|
||||
"""Route wrapper for health status payload."""
|
||||
return healthz(request)
|
||||
|
||||
@@ -97,6 +97,7 @@ class Settings(BaseSettings):
|
||||
|
||||
# --- runtime environment ---
|
||||
environment: Literal["development", "test", "production"] = "development"
|
||||
transcription_commit: NonEmptyStr | None = None
|
||||
|
||||
# --- persistence ---
|
||||
database: DatabaseSettings = Field(default_factory=SqliteSettings)
|
||||
@@ -203,7 +204,7 @@ LOGGING_CONFIG: dict[str, Any] = {
|
||||
"file": {
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"formatter": "standard",
|
||||
"filename": str((Path("./data/logs") / "transcription.log")),
|
||||
"filename": str(Path("./data/logs") / "transcription.log"),
|
||||
"maxBytes": 10 * 1024 * 1024,
|
||||
"backupCount": 5,
|
||||
"encoding": "utf-8",
|
||||
|
||||
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
from importlib.metadata import PackageNotFoundError
|
||||
from importlib.metadata import version
|
||||
@@ -17,6 +16,8 @@ from pydantic import ConfigDict
|
||||
from pydantic import Field
|
||||
from pydantic import JsonValue
|
||||
|
||||
from transcription.config import Settings
|
||||
|
||||
REQUEST_MANIFEST_SCHEMA = "transcription.request-manifest"
|
||||
REQUEST_MANIFEST_VERSION = "1"
|
||||
SOFTWARE_CONTEXT_SCHEMA = "transcription.software-context"
|
||||
@@ -141,11 +142,17 @@ def package_version(package: str) -> str:
|
||||
return "unknown"
|
||||
|
||||
|
||||
def build_software_context(*, adapter_name: str, adapter_version: str, client_library: str) -> SoftwareContext:
|
||||
def build_software_context(
|
||||
*,
|
||||
adapter_name: str,
|
||||
adapter_version: str,
|
||||
client_library: str,
|
||||
settings: Settings,
|
||||
) -> SoftwareContext:
|
||||
"""Build the runtime software identity for an execution."""
|
||||
return SoftwareContext(
|
||||
application_version=package_version("transcription"),
|
||||
application_commit=os.environ.get("TRANSCRIPTION_COMMIT") or None,
|
||||
application_commit=settings.transcription_commit,
|
||||
adapter_name=adapter_name,
|
||||
adapter_version=adapter_version,
|
||||
client_library=client_library,
|
||||
|
||||
@@ -369,6 +369,7 @@ class OpenRouterTranscriptionProvider:
|
||||
adapter_name="openrouter",
|
||||
adapter_version=OPENROUTER_ADAPTER_VERSION,
|
||||
client_library="openrouter",
|
||||
settings=self._settings,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user