chore(extraction): document sidecar dev alerts

What changed:
- Added a scoped no-console justification for development-only sidecar health alerts.

Warning impact:
- extraction-service sidecar-monitor no-console warnings: 3 -> 0.
- Workspace lint: 93 -> 90 warnings.

Verification:
- pnpm --filter @lysnrai/extraction-service build
- pnpm --filter @lysnrai/extraction-service test
- pnpm --filter @lysnrai/extraction-service exec eslint . --ext .ts,.tsx
- pnpm lint
This commit is contained in:
Saravana Achu Mac 2026-05-04 16:42:25 -07:00
parent e940d067c3
commit 9cd7089f97

View File

@ -130,7 +130,8 @@ function updateState(check: HealthCheck): void {
// Determine status
if (state.consecutiveFailures >= ALERT_THRESHOLD) {
const newStatus: SidecarHealthStatus = state.consecutiveFailures >= ALERT_THRESHOLD * 2 ? 'unhealthy' : 'degraded';
const newStatus: SidecarHealthStatus =
state.consecutiveFailures >= ALERT_THRESHOLD * 2 ? 'unhealthy' : 'degraded';
if (state.current !== newStatus) {
state.current = newStatus;
@ -236,13 +237,15 @@ export function getHealthSummary(): {
} {
const recent = state.history.slice(0, 20);
const responseTimes = recent.filter(h => h.status === 'healthy').map(h => h.responseTimeMs);
const avgResponseTimeMs = responseTimes.length > 0
? Math.round(responseTimes.reduce((a, b) => a + b, 0) / responseTimes.length)
: 0;
const avgResponseTimeMs =
responseTimes.length > 0
? Math.round(responseTimes.reduce((a, b) => a + b, 0) / responseTimes.length)
: 0;
const availability = state.totalChecks > 0
? Math.round(((state.totalChecks - state.totalFailures) / state.totalChecks) * 1000) / 10
: 100;
const availability =
state.totalChecks > 0
? Math.round(((state.totalChecks - state.totalFailures) / state.totalChecks) * 1000) / 10
: 100;
// Calculate uptime percentage based on consecutive successes/failures
const uptime = state.current === 'healthy' ? 100 : state.current === 'degraded' ? 50 : 0;
@ -277,23 +280,34 @@ export function resetHealthState(): void {
// ── Default console alerting (development) ──────────────────────
if (process.env.NODE_ENV === 'development') {
/* eslint-disable no-console -- Development-only sidecar health alerts are intentionally surfaced in the local service console. */
alertConfig = {
onUnhealthy: (state, check) => {
console.error(`[sidecar-health] ALERT: Sidecar unhealthy after ${state.consecutiveFailures} consecutive failures`, {
error: check.error,
responseTime: check.responseTimeMs,
});
console.error(
`[sidecar-health] ALERT: Sidecar unhealthy after ${state.consecutiveFailures} consecutive failures`,
{
error: check.error,
responseTime: check.responseTimeMs,
}
);
},
onRecovered: (state, check) => {
console.log(`[sidecar-health] RECOVERED: Sidecar is healthy after ${state.consecutiveSuccesses} consecutive successes`, {
responseTime: check.responseTimeMs,
});
console.log(
`[sidecar-health] RECOVERED: Sidecar is healthy after ${state.consecutiveSuccesses} consecutive successes`,
{
responseTime: check.responseTimeMs,
}
);
},
onDegraded: (state, check) => {
console.warn(`[sidecar-health] WARNING: Sidecar degraded after ${state.consecutiveFailures} failures`, {
error: check.error,
responseTime: check.responseTimeMs,
});
console.warn(
`[sidecar-health] WARNING: Sidecar degraded after ${state.consecutiveFailures} failures`,
{
error: check.error,
responseTime: check.responseTimeMs,
}
);
},
};
/* eslint-enable no-console */
}