31 lines
963 B
TypeScript
31 lines
963 B
TypeScript
import type { PhysiqueTargeting } from '../config/index.js';
|
|
|
|
export type PhysiqueTargetingDecision =
|
|
| { accepted: true }
|
|
| { accepted: false; reason: string };
|
|
|
|
/**
|
|
* Applies the operator's optional physique range to an image analysis result.
|
|
* An enabled range is fail-closed: an image that cannot be scored cannot be
|
|
* claimed to fall inside the configured range.
|
|
*/
|
|
export function evaluatePhysiqueTargeting(
|
|
score: number | null,
|
|
targeting: PhysiqueTargeting,
|
|
): PhysiqueTargetingDecision {
|
|
if (!targeting.enabled) return { accepted: true };
|
|
if (score === null) {
|
|
return {
|
|
accepted: false,
|
|
reason: 'physique score unavailable while physique targeting is enabled',
|
|
};
|
|
}
|
|
if (score < targeting.minScore || score > targeting.maxScore) {
|
|
return {
|
|
accepted: false,
|
|
reason: `physique score ${score} outside target range ${targeting.minScore}-${targeting.maxScore}`,
|
|
};
|
|
}
|
|
return { accepted: true };
|
|
}
|