@GET
    @Path("/health")
    @Operation(summary = "Health check endpoint to verify worker readiness and liveness")
    public Response healthCheck() throws Throwable {
        WorkerStatus workerStatus;
        int statusCode;
        try {
            FutureCallback<Void> cb = new FutureCallback<>();
            herder.healthCheck(cb);

            long timeoutNs = TimeUnit.MILLISECONDS.toNanos(requestTimeout.healthCheckTimeoutMs());
            long deadlineNs = timeoutNs + time.nanoseconds();
            time.waitForFuture(cb, deadlineNs);

            statusCode = Response.Status.OK.getStatusCode();
            workerStatus = WorkerStatus.healthy();
        } catch (TimeoutException e) {
            String statusDetails = e instanceof StagedTimeoutException
                    ? ((StagedTimeoutException) e).stage().summarize()
                    : null;
            if (!herder.isReady()) {
                statusCode = Response.Status.SERVICE_UNAVAILABLE.getStatusCode();
                workerStatus = WorkerStatus.starting(statusDetails);
            } else {
                statusCode = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
                workerStatus = WorkerStatus.unhealthy(statusDetails);
            }
        } catch (ExecutionException e) {
            throw e.getCause();
        }

        return Response.status(statusCode).entity(workerStatus).build();
    }
@Test
    public void testHealthCheckRunning() throws Throwable {
        expectHealthCheck(null);

        Response response = rootResource.healthCheck();
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

        WorkerStatus expectedStatus = WorkerStatus.healthy();
        WorkerStatus actualStatus = workerStatus(response);
        assertEquals(expectedStatus, actualStatus);
    }