/** * Trigger Controller — PEAT-B2 * * Pure core module that connects triage/admission decisions to a concrete * trigger outcome. This is the ONLY module that decides whether a diagnostic * task is created. * * Input: triage result + source descriptor + minimal evidence metadata * Output: TriggerDecision with structured outcome * * Every output carries reason + nextAction (ERR-002). * No raw sensitive data in outputs (privacy boundary). * * ERR checklist: * - ERR-001: No `as` casts. Input validated with runtime guards. * - ERR-002: Every decision carries reason + nextAction. * - ERR-009: Malformed/missing state fails loud with reason. * - ERR-025: Production-path wiring, not just helper tests. * - ERR-031/034: Config source alignment — decisions from canonical descriptors. * - ERR-048: Activation/write-read disconnect prevented by recording decisions. */ import type { SourceKind, TriageDecision, TriageResult } from './types.js'; /** * The outcome of a trigger controller evaluation. * * Each variant represents a distinct state that is observable by the owner: * - evidence_only: recorded but no diagnosis created * - diagnosis_created: diagnostician task was/will be created * - diagnosis_skipped: admission was 'admit' but something prevented diagnosis * - cooldown_skipped: admitted but cooldown prevented creation * - manual_owner_admitted: owner explicit pain bypasses normal gate * - refused: malformed or invalid input rejected * - health_only: infrastructure health signal only * - owner_confirm_required: needs owner confirmation before diagnosis */ export type TriggerOutcome = 'evidence_only' | 'diagnosis_created' | 'diagnosis_skipped' | 'cooldown_skipped' | 'manual_owner_admitted' | 'refused' | 'health_only' | 'owner_confirm_required'; /** * Structured trigger decision returned by the controller. * * Every field is required to prevent silent degradation (ERR-002). */ export interface TriggerDecision { /** The trigger outcome */ readonly outcome: TriggerOutcome; /** Human-readable reason for this decision */ readonly reason: string; /** What should happen next */ readonly nextAction: string; /** Source kind that was evaluated */ readonly sourceKind: SourceKind; /** The triage decision that led to this trigger outcome */ readonly triageDecision: TriageDecision; /** Whether this decision should result in a diagnostic task */ readonly shouldCreateDiagnosticTask: boolean; /** Timestamp of the decision */ readonly decidedAt: string; /** Optional operator note for debugging */ readonly operatorNote?: string; } /** * Input to the trigger controller. * * Combines triage result with additional context that the trigger controller * needs but the triage policy does not. */ export interface TriggerControllerInput { /** Result from evidence triage (PEAT-B1) */ readonly triageResult: TriageResult; /** Whether this is an owner manual pain signal */ readonly isOwnerManual: boolean; /** Whether cooldown is currently active for this source/session */ readonly isCooldownActive: boolean; /** Whether the input was valid (malformed → refused) */ readonly isValid: boolean; /** Optional validation error message when isValid is false */ readonly validationError?: string; /** Pain score (0-100) */ readonly score: number; /** Optional session ID for cooldown scoping */ readonly sessionId?: string; /** Whether cooldown bypass is allowed (owner manual always bypasses) */ readonly cooldownBypassAllowed?: boolean; } /** * Evaluate trigger controller for incoming pain evidence. * * This is the ONLY function that decides whether a diagnostic task is created. * The production path (hooks, CLI, manual) must call this before creating tasks. * * Decision precedence: * 1. Invalid input → refused * 2. Owner manual → manual_owner_admitted (always creates task) * 3. Triage decision → evidence_only / diagnosis_created / health_only / etc. * 4. Cooldown check → cooldown_skipped (within 'admit' branch) * * @param input - Trigger controller input with triage result and context * @returns Structured trigger decision */ export declare function evaluateTriggerController(input: TriggerControllerInput): TriggerDecision; /** * Check if a trigger outcome should result in a diagnostic task being created. * * Convenience function for callers that just need the boolean. */ export declare function shouldCreateTask(decision: TriggerDecision): boolean; /** * Check if a trigger outcome represents an "admitted" state * (i.e., the signal was accepted into the pipeline, even if it didn't create a task). */ export declare function isAdmittedOutcome(outcome: TriggerOutcome): boolean; /** * Check if a trigger outcome represents a "skipped" state * (i.e., the signal was valid but something prevented task creation). */ export declare function isSkippedOutcome(outcome: TriggerOutcome): boolean; //# sourceMappingURL=trigger-controller.d.ts.map