Pure functions to determine when to fire budget and watcher lag notifications. Includes threshold checks and deduplication logic for deterministic alerting.
// Source: https://github.com/superbasedapp/observer | License: Apache-2.0 | Copyright 2026 Gaja AI
// Provided via justclaw.it.com; keep this notice with the code.
// Pure decision helpers for the M5 notifications. Lives in its own
// module so the unit suite can pin the threshold + dedup logic
// without spinning up a vscode runtime.
import type { HeadlineResponse, WatcherHealthResponse } from '../api/types';
export const BUDGET_PCT_THRESHOLD = 80;
export const WATCHER_BEHIND_BYTES_THRESHOLD = 10 * 1024;
export const WATCHER_DEDUP_MS = 5 * 60 * 1000;
export interface BudgetDecision {
fire: boolean;
pct?: number;
toDateUsd?: number;
budgetUsd?: number;
}
/**
* decideBudget returns whether to surface the breach notification
* for this headline payload. Fires only when:
*
*
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key