/** * @fileoverview Canonical TrustSignal type definitions for the Vorion Platform. * * This file provides the authoritative definition for trust signals - events * or observations that affect an agent's trust score. It resolves the field * optionality conflicts found across packages into a single consistent structure. * * Trust signals are the atomic inputs to the trust calculation system. They * capture behavioral observations, compliance events, credential verifications, * and other factors that influence trust. * * @module @vorionsys/contracts/canonical/trust-signal */ import { z } from 'zod'; /** * Types of trust signals that can be recorded. * * Each type represents a different category of trust-relevant information. * * @enum {string} */ export declare enum SignalType { /** Agent successfully completed an action */ ACTION_SUCCESS = "action_success", /** Agent failed to complete an action */ ACTION_FAILURE = "action_failure", /** Agent complied with a policy requirement */ COMPLIANCE_MET = "compliance_met", /** Agent violated a policy requirement */ COMPLIANCE_VIOLATION = "compliance_violation", /** Agent's credential was verified */ CREDENTIAL_VERIFIED = "credential_verified", /** Agent's credential expired or was revoked */ CREDENTIAL_EXPIRED = "credential_expired", /** Agent exhibited anomalous behavior */ ANOMALY_DETECTED = "anomaly_detected", /** Manual trust adjustment by administrator */ MANUAL_ADJUSTMENT = "manual_adjustment", /** Trust decay due to inactivity */ DECAY = "decay", /** Initial trust assignment for new agent */ INITIAL_TRUST = "initial_trust", /** Trust transfer from another system */ TRUST_TRANSFER = "trust_transfer", /** Agent passed a canary probe test */ CANARY_PASSED = "canary_passed", /** Agent failed a canary probe test */ CANARY_FAILED = "canary_failed", /** Third-party attestation received */ ATTESTATION = "attestation", /** Peer review or endorsement */ PEER_ENDORSEMENT = "peer_endorsement", /** Outcome reversal (provisional success became failure) */ OUTCOME_REVERSAL = "outcome_reversal" } /** * Signal polarity - whether the signal is positive or negative for trust. */ export type SignalPolarity = 'positive' | 'negative' | 'neutral'; /** * Mapping of signal types to their default polarity. */ export declare const SIGNAL_TYPE_POLARITY: Readonly>; /** * Sources from which trust signals can originate. * * Defines the system or mechanism that generated the signal. */ export type SignalSource = /** A3I authorization system */ 'a3i' /** ERA execution system */ | 'era' /** Agent Trust Scoring Framework */ | 'atsf' /** Canary probe system */ | 'canary' /** Human administrator */ | 'admin' /** External attestation service */ | 'external' /** Automated compliance checker */ | 'compliance' /** Anomaly detection system */ | 'anomaly' /** Peer agent */ | 'peer' /** System scheduler (for decay) */ | 'scheduler' /** Unknown or unspecified source */ | 'unknown'; /** * All valid signal sources as an array. */ export declare const SIGNAL_SOURCES: readonly SignalSource[]; /** * Trust dimensions that signals can affect. * * Maps to the 5-dimension trust model from ATSF. */ export type TrustDimension = /** Capability Trust - Does the agent have the skills? */ 'capability' /** Behavioral Trust - Has the agent acted reliably? */ | 'behavioral' /** Governance Trust - Is the agent properly governed? */ | 'governance' /** Contextual Trust - Is this the right context? */ | 'contextual' /** Assurance Confidence - How confident are we? */ | 'assurance'; /** * All trust dimensions as an array. */ export declare const TRUST_DIMENSIONS: readonly TrustDimension[]; /** * Configuration for how a signal impacts trust scores. */ export interface SignalImpact { /** * Base impact value. * Positive values increase trust, negative decrease. * Range: -1000 to +1000 (relative to trust score scale) */ baseImpact: number; /** * Which trust dimensions this signal affects. * If not specified, affects all dimensions equally. */ dimensions?: TrustDimension[]; /** * Optional multiplier based on magnitude. * Applied as: finalImpact = baseImpact * magnitudeMultiplier */ magnitudeMultiplier?: number; /** * Confidence in this signal's accuracy (0-1). * Lower confidence may reduce the effective impact. */ confidence?: number; } /** * Canonical TrustSignal interface. * * Represents a trust-relevant event or observation about an agent. * All fields that could be either required or optional across packages * are standardized as optional with explicit undefined handling. * * @example * ```typescript * const signal: TrustSignal = { * signalId: 'sig_abc123', * agentId: 'agt_xyz789', * tenantId: 'ten_def456', * type: SignalType.ACTION_SUCCESS, * source: 'era', * timestamp: new Date(), * impact: { * baseImpact: 5, * dimensions: ['behavioral', 'capability'], * confidence: 0.95, * }, * description: 'Successfully completed file upload task', * }; * ``` */ export interface TrustSignal { /** * Unique signal identifier. */ signalId: string; /** * Agent this signal is about. */ agentId: string; /** * Tenant/organization identifier. */ tenantId: string; /** * Type of signal. */ type: SignalType; /** * Source system that generated this signal. */ source: SignalSource; /** * When this signal was recorded. */ timestamp: Date; /** * How this signal affects trust scores. */ impact: SignalImpact; /** * Human-readable description of the signal. */ description?: string; /** * Weight/importance of this signal (0-1). * Affects how much influence this signal has relative to others. * Default: 1.0 (full weight) */ weight?: number; /** * Related intent ID (if signal resulted from intent processing). */ intentId?: string; /** * Related action/execution ID. */ actionId?: string; /** * Correlation ID for distributed tracing. */ correlationId?: string; /** * When this signal expires and should no longer affect calculations. */ expiresAt?: Date; /** * Additional contextual metadata. * Use for domain-specific data that doesn't fit standard fields. */ metadata?: Record; /** * Whether this signal has been processed into a trust delta. */ processed?: boolean; /** * When this signal was processed. */ processedAt?: Date; /** * ID of the trust delta created from this signal. */ deltaId?: string; } /** * Summary view of a trust signal for listings. */ export interface TrustSignalSummary { signalId: string; agentId: string; type: SignalType; source: SignalSource; timestamp: Date; impactValue: number; description?: string; } /** * Request to create a new trust signal. */ export interface CreateTrustSignalRequest { agentId: string; type: SignalType; source: SignalSource; impact: SignalImpact; description?: string; weight?: number; intentId?: string; actionId?: string; correlationId?: string; expiresAt?: Date; metadata?: Record; } /** * Aggregated trust signals for a time period. */ export interface SignalAggregation { /** Agent ID */ agentId: string; /** Aggregation period start */ periodStart: Date; /** Aggregation period end */ periodEnd: Date; /** Total number of signals */ signalCount: number; /** Count by signal type */ byType: Partial>; /** Count by source */ bySource: Partial>; /** Net impact (sum of all impacts) */ netImpact: number; /** Positive impact total */ positiveImpact: number; /** Negative impact total */ negativeImpact: number; } /** * Gets the default polarity for a signal type. * * @param type - Signal type * @returns Polarity of the signal type */ export declare function getSignalPolarity(type: SignalType): SignalPolarity; /** * Checks if a signal type is positive for trust. * * @param type - Signal type * @returns True if the signal type is positive */ export declare function isPositiveSignal(type: SignalType): boolean; /** * Checks if a signal type is negative for trust. * * @param type - Signal type * @returns True if the signal type is negative */ export declare function isNegativeSignal(type: SignalType): boolean; /** * Calculates the effective impact of a signal. * * For positive signals: applies weight, confidence, and magnitude multiplier. * For negative signals: magnitudeMultiplier is clamped to max 1.0 — negative * signals are never amplified here. The tier-scaled penalty formula (2-10x) * is the sole mechanism for negative amplification. * * @param signal - Trust signal * @returns Calculated effective impact value */ export declare function calculateEffectiveImpact(signal: TrustSignal): number; /** * Checks if a signal has expired. * * @param signal - Trust signal to check * @param now - Current time (defaults to now) * @returns True if signal has expired */ export declare function isSignalExpired(signal: TrustSignal, now?: Date): boolean; /** * Filters expired signals from an array. * * @param signals - Array of signals to filter * @param now - Current time (defaults to now) * @returns Array of non-expired signals */ export declare function filterExpiredSignals(signals: TrustSignal[], now?: Date): TrustSignal[]; /** * Aggregates signals for a time period. * * @param signals - Array of signals to aggregate * @param agentId - Agent ID * @param periodStart - Period start time * @param periodEnd - Period end time * @returns Aggregated signal statistics */ export declare function aggregateSignals(signals: TrustSignal[], agentId: string, periodStart: Date, periodEnd: Date): SignalAggregation; /** * Type guard to check if a value is a valid SignalType. * * @param value - Value to check * @returns True if value is a valid SignalType */ export declare function isSignalType(value: unknown): value is SignalType; /** * Type guard to check if a value is a valid SignalSource. * * @param value - Value to check * @returns True if value is a valid SignalSource */ export declare function isSignalSource(value: unknown): value is SignalSource; /** * Type guard to check if a value is a valid TrustDimension. * * @param value - Value to check * @returns True if value is a valid TrustDimension */ export declare function isTrustDimension(value: unknown): value is TrustDimension; /** * Zod schema for SignalType enum. */ export declare const signalTypeSchema: z.ZodNativeEnum; /** * Zod schema for SignalSource. */ export declare const signalSourceSchema: z.ZodEnum<["a3i", "era", "atsf", "canary", "admin", "external", "compliance", "anomaly", "peer", "scheduler", "unknown"]>; /** * Zod schema for TrustDimension. */ export declare const trustDimensionSchema: z.ZodEnum<["capability", "behavioral", "governance", "contextual", "assurance"]>; /** * Zod schema for SignalImpact. */ export declare const signalImpactSchema: z.ZodObject<{ baseImpact: z.ZodNumber; dimensions: z.ZodOptional, "many">>; magnitudeMultiplier: z.ZodOptional; confidence: z.ZodOptional; }, "strip", z.ZodTypeAny, { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }, { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }>; /** * Zod schema for TrustSignal. */ export declare const trustSignalSchema: z.ZodObject<{ signalId: z.ZodString; agentId: z.ZodString; tenantId: z.ZodString; type: z.ZodNativeEnum; source: z.ZodEnum<["a3i", "era", "atsf", "canary", "admin", "external", "compliance", "anomaly", "peer", "scheduler", "unknown"]>; timestamp: z.ZodDate; impact: z.ZodObject<{ baseImpact: z.ZodNumber; dimensions: z.ZodOptional, "many">>; magnitudeMultiplier: z.ZodOptional; confidence: z.ZodOptional; }, "strip", z.ZodTypeAny, { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }, { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }>; description: z.ZodOptional; weight: z.ZodOptional; intentId: z.ZodOptional; actionId: z.ZodOptional; correlationId: z.ZodOptional; expiresAt: z.ZodOptional; metadata: z.ZodOptional>; processed: z.ZodOptional; processedAt: z.ZodOptional; deltaId: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: SignalType; timestamp: Date; agentId: string; source: "unknown" | "external" | "admin" | "a3i" | "era" | "atsf" | "canary" | "compliance" | "anomaly" | "peer" | "scheduler"; tenantId: string; impact: { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }; signalId: string; metadata?: Record | undefined; correlationId?: string | undefined; intentId?: string | undefined; expiresAt?: Date | undefined; description?: string | undefined; weight?: number | undefined; actionId?: string | undefined; processed?: boolean | undefined; processedAt?: Date | undefined; deltaId?: string | undefined; }, { type: SignalType; timestamp: Date; agentId: string; source: "unknown" | "external" | "admin" | "a3i" | "era" | "atsf" | "canary" | "compliance" | "anomaly" | "peer" | "scheduler"; tenantId: string; impact: { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }; signalId: string; metadata?: Record | undefined; correlationId?: string | undefined; intentId?: string | undefined; expiresAt?: Date | undefined; description?: string | undefined; weight?: number | undefined; actionId?: string | undefined; processed?: boolean | undefined; processedAt?: Date | undefined; deltaId?: string | undefined; }>; /** * Zod schema for TrustSignalSummary. */ export declare const trustSignalSummarySchema: z.ZodObject<{ signalId: z.ZodString; agentId: z.ZodString; type: z.ZodNativeEnum; source: z.ZodEnum<["a3i", "era", "atsf", "canary", "admin", "external", "compliance", "anomaly", "peer", "scheduler", "unknown"]>; timestamp: z.ZodDate; impactValue: z.ZodNumber; description: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: SignalType; timestamp: Date; agentId: string; source: "unknown" | "external" | "admin" | "a3i" | "era" | "atsf" | "canary" | "compliance" | "anomaly" | "peer" | "scheduler"; signalId: string; impactValue: number; description?: string | undefined; }, { type: SignalType; timestamp: Date; agentId: string; source: "unknown" | "external" | "admin" | "a3i" | "era" | "atsf" | "canary" | "compliance" | "anomaly" | "peer" | "scheduler"; signalId: string; impactValue: number; description?: string | undefined; }>; /** * Zod schema for CreateTrustSignalRequest. */ export declare const createTrustSignalRequestSchema: z.ZodObject<{ agentId: z.ZodString; type: z.ZodNativeEnum; source: z.ZodEnum<["a3i", "era", "atsf", "canary", "admin", "external", "compliance", "anomaly", "peer", "scheduler", "unknown"]>; impact: z.ZodObject<{ baseImpact: z.ZodNumber; dimensions: z.ZodOptional, "many">>; magnitudeMultiplier: z.ZodOptional; confidence: z.ZodOptional; }, "strip", z.ZodTypeAny, { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }, { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }>; description: z.ZodOptional; weight: z.ZodOptional; intentId: z.ZodOptional; actionId: z.ZodOptional; correlationId: z.ZodOptional; expiresAt: z.ZodOptional; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: SignalType; agentId: string; source: "unknown" | "external" | "admin" | "a3i" | "era" | "atsf" | "canary" | "compliance" | "anomaly" | "peer" | "scheduler"; impact: { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }; metadata?: Record | undefined; correlationId?: string | undefined; intentId?: string | undefined; expiresAt?: Date | undefined; description?: string | undefined; weight?: number | undefined; actionId?: string | undefined; }, { type: SignalType; agentId: string; source: "unknown" | "external" | "admin" | "a3i" | "era" | "atsf" | "canary" | "compliance" | "anomaly" | "peer" | "scheduler"; impact: { baseImpact: number; magnitudeMultiplier?: number | undefined; confidence?: number | undefined; dimensions?: ("governance" | "capability" | "behavioral" | "contextual" | "assurance")[] | undefined; }; metadata?: Record | undefined; correlationId?: string | undefined; intentId?: string | undefined; expiresAt?: Date | undefined; description?: string | undefined; weight?: number | undefined; actionId?: string | undefined; }>; /** * Zod schema for SignalAggregation. */ export declare const signalAggregationSchema: z.ZodObject<{ agentId: z.ZodString; periodStart: z.ZodDate; periodEnd: z.ZodDate; signalCount: z.ZodNumber; byType: z.ZodRecord, z.ZodNumber>; bySource: z.ZodRecord, z.ZodNumber>; netImpact: z.ZodNumber; positiveImpact: z.ZodNumber; negativeImpact: z.ZodNumber; }, "strip", z.ZodTypeAny, { periodStart: Date; periodEnd: Date; agentId: string; signalCount: number; byType: Partial>; bySource: Partial>; netImpact: number; positiveImpact: number; negativeImpact: number; }, { periodStart: Date; periodEnd: Date; agentId: string; signalCount: number; byType: Partial>; bySource: Partial>; netImpact: number; positiveImpact: number; negativeImpact: number; }>; /** * Inferred TrustSignal type from Zod schema. */ export type TrustSignalInput = z.input; /** * Inferred CreateTrustSignalRequest type from Zod schema. */ export type CreateTrustSignalRequestInput = z.input;