1
0
Fork 0
polaris-task-force/src/lib/evaluations/levels.ts
Z8MB1E 9955c376f9 feat(evaluations): define performance levels
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-08-27 18:36:04 -04:00

51 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Pure performance level definitions for leadership evaluations.
*
* This module has no Payload imports — it is safe to use from server actions,
* integration tests, and (later) frontend components. The UI renders these as
* bar/gradient displays; `score` drives the numeric aggregation and `color`
* the per-level accent.
*/
export interface PerformanceLevel {
/** Stable identifier stored on evaluation docs. */
id: string;
/** Human-readable label, e.g. shown as "OPERATOR PERFORMANCE LEVEL: EXCELLENT". */
label: string;
/** Numeric score (0–100) used for aggregate bar/percentage display. */
score: number;
/** Hex color for UI bars/gradients. */
color: string;
}
/**
* The performance scale, best to worst. At least five levels are required by the
* leadership-evaluations feature; six are defined so the top of the scale has room
* above "EXCELLENT" without collapsing distinctions.
*/
export const PERFORMANCE_LEVELS = [
{ id: "exceptional", label: "EXCEPTIONAL", score: 100, color: "#34d399" },
{ id: "excellent", label: "EXCELLENT", score: 85, color: "#4ade80" },
{ id: "proficient", label: "PROFICIENT", score: 70, color: "#a3e635" },
{ id: "adequate", label: "ADEQUATE", score: 55, color: "#fbbf24" },
{ id: "moderate", label: "MODERATE", score: 40, color: "#94a3b8" },
{ id: "under-review", label: "UNDER REVIEW", score: 25, color: "#f87171" },
] as const satisfies readonly PerformanceLevel[];
export type PerformanceLevelId = (typeof PERFORMANCE_LEVELS)[number]["id"];
const LEVEL_IDS: ReadonlySet<string> = new Set(PERFORMANCE_LEVELS.map((l) => l.id));
/** Type guard for runtime-validated level ids (DB/API input). */
export function isPerformanceLevelId(value: unknown): value is PerformanceLevelId {
return typeof value === "string" && LEVEL_IDS.has(value);
}
/** Resolve a level definition by id, or null when unknown. */
export function getPerformanceLevel(id: string): PerformanceLevel | null {
return PERFORMANCE_LEVELS.find((l) => l.id === id) ?? null;
}
export function getLeadershipDisplayLabel(level: Pick<PerformanceLevel, "id" | "label">): string {
return level.id === "under-review" ? "NEEDS WORK" : level.label;
}