import { TrustLevel } from '../domain/entities/trust-level.js'; import { FederationNode } from '../domain/entities/federation-node.js'; import { type SessionMetrics } from '../domain/entities/federation-session.js'; export interface TrustScoreComponents { readonly successRate: number; readonly uptime: number; readonly threatPenalty: number; readonly dataIntegrityScore: number; } export interface TrustTransitionResult { readonly previousLevel: TrustLevel; readonly newLevel: TrustLevel; readonly score: number; readonly components: TrustScoreComponents; readonly reason: string; readonly requiresHumanApproval: boolean; } export type ImmediateDowngradeReason = 'repeated-threat-detection' | 'hmac-verification-failure' | 'session-hijack-attempt'; export interface TrustEvaluatorDeps { onTrustChange?: (nodeId: string, result: TrustTransitionResult) => void; } /** * Audit record emitted by `bootstrapElevate`. Captures the bypass intent, * the operator-supplied reason, and the before/after trust levels so that * downstream audit consumers can flag bootstrap elevations distinctly from * organic trust transitions. See ADR-164 §3.5.4. */ export interface BootstrapElevationAuditEntry { readonly tag: 'bootstrap_elevation'; readonly nodeId: string; readonly previousLevel: TrustLevel; readonly newLevel: TrustLevel; readonly reason: string; readonly timestamp: string; readonly operatorBypass: true; } export interface ThreatWindow { readonly detections: Date[]; readonly windowMs: number; readonly threshold: number; } export declare class TrustEvaluator { private readonly deps; private readonly threatWindows; constructor(deps?: TrustEvaluatorDeps); computeScore(metrics: SessionMetrics, uptimeRatio: number): { score: number; components: TrustScoreComponents; }; evaluateTransition(node: FederationNode, metrics: SessionMetrics, uptimeRatio: number, hasInstitutionalAttestation?: boolean): TrustTransitionResult | null; downgrade(node: FederationNode, reason: ImmediateDowngradeReason): TrustTransitionResult; /** * Founder-bootstrap trust elevation (ADR-164 §3.5.4). * * Bypasses the organic trust-accrual thresholds (minInteractions: 500 for * 2→3, etc.) so a freshly-joined BBS peer can be hand-promoted to * TRUSTED on Day 1, before its interaction count has accrued. This is an * operator escape hatch — every invocation MUST be recorded as a special * `bootstrap_elevation` audit entry so it is distinguishable from organic * upgrades. `reason` MUST be a non-empty operator-supplied string. * * The caller is responsible for refusing to invoke this method when the * target node is not a registered federation peer; this function trusts * its inputs and only performs the elevation + audit construction. * * @returns audit entry tagged `bootstrap_elevation` ready to be persisted. */ bootstrapElevate(node: FederationNode, newLevel: TrustLevel, reason: string): BootstrapElevationAuditEntry; recordThreatDetection(nodeId: string): boolean; private checkUpgrade; private checkDowngrade; private computeThreatPenalty; } //# sourceMappingURL=trust-evaluator.d.ts.map