Loading src/srm/api/health.py +2 −2 Original line number Diff line number Diff line Loading @@ -6,12 +6,12 @@ from srm.api.dependencies import get_app_state health_router = APIRouter(tags=["Platform Health"]) @health_router.get("/health/livez") @health_router.get("/healthz") async def liveness() -> bool: return True @health_router.get("/health/readyz") @health_router.get("/readyz") async def readiness(request: Request) -> bool: app_state = get_app_state(request) Loading src/srm/domain/__init__.py +0 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ __all__ = [ "CapabilityTarget", "ComputeRequirements", "ComputeResources", "ComputeTransportProtocol", "ControlPathBinding", "ControlPathBindingState", "DeviceTarget", Loading @@ -79,7 +78,6 @@ __all__ = [ "IdentifiedModel", "InterfaceVisibility", "NetworkInterface", "ParameterTransportProtocol", "Parameters", "Result", "RuntimeKind", Loading src/srm/domain/models/canonical_parameters/result.py +7 −1 Original line number Diff line number Diff line from enum import StrEnum from typing import Any from pydantic import Field Loading @@ -5,6 +6,11 @@ from pydantic import Field from srm.domain.models.common import DomainModel class ResultStatus(StrEnum): ACTIVE = "active" FAILED = "failed" class ServiceEndpoint(DomainModel): interface_id: str Loading @@ -25,7 +31,7 @@ class Result(DomainModel): frozen=True, ) status: str status: ResultStatus endpoints: list[ServiceEndpoint] = Field(default_factory=list) Loading tests/api/middlewares/test_logging.py +6 −6 Original line number Diff line number Diff line Loading @@ -15,13 +15,13 @@ def _capture_logs() -> AbstractContextManager[list[EventDict]]: async def test_logs_request_received(client: AsyncClient) -> None: with _capture_logs() as logs: await client.get("/health/livez") await client.get("/healthz") assert any(entry["event"] == "Request Received" for entry in logs) async def test_logs_request_processed(client: AsyncClient) -> None: with _capture_logs() as logs: await client.get("/health/livez") await client.get("/healthz") processed = next((entry for entry in logs if entry["event"] == "Request Processed"), None) assert processed is not None, "'Request Processed' log entry was not emitted" assert isinstance(processed["duration"], float) Loading @@ -30,17 +30,17 @@ async def test_logs_request_processed(client: AsyncClient) -> None: async def test_request_received_contains_metadata(client: AsyncClient) -> None: with _capture_logs() as logs: await client.get("/health/livez") await client.get("/healthz") received = next((entry for entry in logs if entry["event"] == "Request Received"), None) assert received is not None, "'Request Received' log entry was not emitted" assert received["http_method"] == "GET" assert received["path"] == "/health/livez" assert received["path"] == "/healthz" assert "request_id" in received async def test_generated_request_id_matches_log(client: AsyncClient) -> None: with _capture_logs() as logs: response = await client.get("/health/livez") response = await client.get("/healthz") received = next((entry for entry in logs if entry["event"] == "Request Received"), None) assert received is not None, "'Request Received' log entry was not emitted" assert received["request_id"] == response.headers["X-Request-ID"] Loading @@ -54,7 +54,7 @@ async def test_log_context_does_not_bleed_between_requests(app: FastAPI) -> None async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as c: with _capture_logs() as logs: await c.get("/test/leaky") await c.get("/health/livez") await c.get("/healthz") received = [entry for entry in logs if entry["event"] == "Request Received"] assert len(received) == 2 Loading tests/api/middlewares/test_request_id.py +8 −8 Original line number Diff line number Diff line Loading @@ -8,18 +8,18 @@ from srm.api.context import originating_request_id async def test_generates_uuid4_when_header_absent(client: AsyncClient) -> None: response = await client.get("/health/livez") response = await client.get("/healthz") assert UUID(response.headers["X-Request-ID"]).version == 4 async def test_passes_through_valid_uuid4(client: AsyncClient) -> None: original = str(uuid4()) response = await client.get("/health/livez", headers={"X-Request-ID": original}) response = await client.get("/healthz", headers={"X-Request-ID": original}) assert response.headers["X-Request-ID"] == original async def test_regenerates_for_invalid_string(client: AsyncClient) -> None: response = await client.get("/health/livez", headers={"X-Request-ID": "not-a-uuid"}) response = await client.get("/healthz", headers={"X-Request-ID": "not-a-uuid"}) new_id = response.headers["X-Request-ID"] assert new_id != "not-a-uuid" assert UUID(new_id).version == 4 Loading @@ -27,25 +27,25 @@ async def test_regenerates_for_invalid_string(client: AsyncClient) -> None: async def test_regenerates_for_non_v4_uuid(client: AsyncClient) -> None: uuid1_val = str(uuid.uuid1()) response = await client.get("/health/livez", headers={"X-Request-ID": uuid1_val}) response = await client.get("/healthz", headers={"X-Request-ID": uuid1_val}) new_id = response.headers["X-Request-ID"] assert new_id != uuid1_val assert UUID(new_id).version == 4 async def test_each_request_gets_unique_id(client: AsyncClient) -> None: r1 = await client.get("/health/livez") r2 = await client.get("/health/livez") r1 = await client.get("/healthz") r2 = await client.get("/healthz") assert r1.headers["X-Request-ID"] != r2.headers["X-Request-ID"] async def test_context_var_is_reset_to_default_after_request(client: AsyncClient) -> None: await client.get("/health/livez") await client.get("/healthz") assert originating_request_id.get() == "" async def test_regenerates_for_empty_string(client: AsyncClient) -> None: response = await client.get("/health/livez", headers={"X-Request-ID": ""}) response = await client.get("/healthz", headers={"X-Request-ID": ""}) assert UUID(response.headers["X-Request-ID"]).version == 4 Loading Loading
src/srm/api/health.py +2 −2 Original line number Diff line number Diff line Loading @@ -6,12 +6,12 @@ from srm.api.dependencies import get_app_state health_router = APIRouter(tags=["Platform Health"]) @health_router.get("/health/livez") @health_router.get("/healthz") async def liveness() -> bool: return True @health_router.get("/health/readyz") @health_router.get("/readyz") async def readiness(request: Request) -> bool: app_state = get_app_state(request) Loading
src/srm/domain/__init__.py +0 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ __all__ = [ "CapabilityTarget", "ComputeRequirements", "ComputeResources", "ComputeTransportProtocol", "ControlPathBinding", "ControlPathBindingState", "DeviceTarget", Loading @@ -79,7 +78,6 @@ __all__ = [ "IdentifiedModel", "InterfaceVisibility", "NetworkInterface", "ParameterTransportProtocol", "Parameters", "Result", "RuntimeKind", Loading
src/srm/domain/models/canonical_parameters/result.py +7 −1 Original line number Diff line number Diff line from enum import StrEnum from typing import Any from pydantic import Field Loading @@ -5,6 +6,11 @@ from pydantic import Field from srm.domain.models.common import DomainModel class ResultStatus(StrEnum): ACTIVE = "active" FAILED = "failed" class ServiceEndpoint(DomainModel): interface_id: str Loading @@ -25,7 +31,7 @@ class Result(DomainModel): frozen=True, ) status: str status: ResultStatus endpoints: list[ServiceEndpoint] = Field(default_factory=list) Loading
tests/api/middlewares/test_logging.py +6 −6 Original line number Diff line number Diff line Loading @@ -15,13 +15,13 @@ def _capture_logs() -> AbstractContextManager[list[EventDict]]: async def test_logs_request_received(client: AsyncClient) -> None: with _capture_logs() as logs: await client.get("/health/livez") await client.get("/healthz") assert any(entry["event"] == "Request Received" for entry in logs) async def test_logs_request_processed(client: AsyncClient) -> None: with _capture_logs() as logs: await client.get("/health/livez") await client.get("/healthz") processed = next((entry for entry in logs if entry["event"] == "Request Processed"), None) assert processed is not None, "'Request Processed' log entry was not emitted" assert isinstance(processed["duration"], float) Loading @@ -30,17 +30,17 @@ async def test_logs_request_processed(client: AsyncClient) -> None: async def test_request_received_contains_metadata(client: AsyncClient) -> None: with _capture_logs() as logs: await client.get("/health/livez") await client.get("/healthz") received = next((entry for entry in logs if entry["event"] == "Request Received"), None) assert received is not None, "'Request Received' log entry was not emitted" assert received["http_method"] == "GET" assert received["path"] == "/health/livez" assert received["path"] == "/healthz" assert "request_id" in received async def test_generated_request_id_matches_log(client: AsyncClient) -> None: with _capture_logs() as logs: response = await client.get("/health/livez") response = await client.get("/healthz") received = next((entry for entry in logs if entry["event"] == "Request Received"), None) assert received is not None, "'Request Received' log entry was not emitted" assert received["request_id"] == response.headers["X-Request-ID"] Loading @@ -54,7 +54,7 @@ async def test_log_context_does_not_bleed_between_requests(app: FastAPI) -> None async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as c: with _capture_logs() as logs: await c.get("/test/leaky") await c.get("/health/livez") await c.get("/healthz") received = [entry for entry in logs if entry["event"] == "Request Received"] assert len(received) == 2 Loading
tests/api/middlewares/test_request_id.py +8 −8 Original line number Diff line number Diff line Loading @@ -8,18 +8,18 @@ from srm.api.context import originating_request_id async def test_generates_uuid4_when_header_absent(client: AsyncClient) -> None: response = await client.get("/health/livez") response = await client.get("/healthz") assert UUID(response.headers["X-Request-ID"]).version == 4 async def test_passes_through_valid_uuid4(client: AsyncClient) -> None: original = str(uuid4()) response = await client.get("/health/livez", headers={"X-Request-ID": original}) response = await client.get("/healthz", headers={"X-Request-ID": original}) assert response.headers["X-Request-ID"] == original async def test_regenerates_for_invalid_string(client: AsyncClient) -> None: response = await client.get("/health/livez", headers={"X-Request-ID": "not-a-uuid"}) response = await client.get("/healthz", headers={"X-Request-ID": "not-a-uuid"}) new_id = response.headers["X-Request-ID"] assert new_id != "not-a-uuid" assert UUID(new_id).version == 4 Loading @@ -27,25 +27,25 @@ async def test_regenerates_for_invalid_string(client: AsyncClient) -> None: async def test_regenerates_for_non_v4_uuid(client: AsyncClient) -> None: uuid1_val = str(uuid.uuid1()) response = await client.get("/health/livez", headers={"X-Request-ID": uuid1_val}) response = await client.get("/healthz", headers={"X-Request-ID": uuid1_val}) new_id = response.headers["X-Request-ID"] assert new_id != uuid1_val assert UUID(new_id).version == 4 async def test_each_request_gets_unique_id(client: AsyncClient) -> None: r1 = await client.get("/health/livez") r2 = await client.get("/health/livez") r1 = await client.get("/healthz") r2 = await client.get("/healthz") assert r1.headers["X-Request-ID"] != r2.headers["X-Request-ID"] async def test_context_var_is_reset_to_default_after_request(client: AsyncClient) -> None: await client.get("/health/livez") await client.get("/healthz") assert originating_request_id.get() == "" async def test_regenerates_for_empty_string(client: AsyncClient) -> None: response = await client.get("/health/livez", headers={"X-Request-ID": ""}) response = await client.get("/healthz", headers={"X-Request-ID": ""}) assert UUID(response.headers["X-Request-ID"]).version == 4 Loading