/** * Common types used throughout Vorion * * @packageDocumentation */ import type { Timestamp } from './primitives.js'; /** * Unique identifier type */ export type ID = string; /** * Trust level (T0-T7) * * Updated to 8 levels per Vorion trust tier specification: * - 0 (T0_SANDBOX): Isolated sandbox, no external access * - 1 (T1_OBSERVED): Observation period, human oversight required * - 2 (T2_PROVISIONAL): Limited autonomy with strict constraints * - 3 (T3_MONITORED): Continuous monitoring, expanding autonomy * - 4 (T4_STANDARD): Standard operations without individual approval * - 5 (T5_TRUSTED): Expanded capabilities with minimal oversight * - 6 (T6_CERTIFIED): Independent operation with audit trail * - 7 (T7_AUTONOMOUS): Full autonomy for mission-critical operations * * @deprecated Prefer importing RuntimeTier from @vorionsys/contracts for new code. * This type is maintained for backwards compatibility. */ export type TrustLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; /** * Trust score (0-1000) * * Canonical trust scores use 0-1000 scale for precision: * - 0-199: T0_SANDBOX * - 200-349: T1_OBSERVED * - 350-499: T2_PROVISIONAL * - 500-649: T3_MONITORED * - 650-799: T4_STANDARD * - 800-875: T5_TRUSTED * - 876-950: T6_CERTIFIED * - 951-1000: T7_AUTONOMOUS * * All trust dimensions and composite scores use this unified 0-1000 scale. */ export type TrustScore = number; /** * Entity types that can be governed */ export type EntityType = 'agent' | 'user' | 'service' | 'system'; /** * Allowed intent statuses. */ export declare const INTENT_STATUSES: readonly ["pending", "evaluating", "approved", "denied", "escalated", "executing", "completed", "failed", "cancelled"]; /** * Intent status */ export type IntentStatus = (typeof INTENT_STATUSES)[number]; /** * Control action types for enforcement decisions. * * @deprecated For governance/authorization actions, use `ControlAction` from * `@vorionsys/contracts/canonical/governance`. This type is maintained * for backwards compatibility with existing enforcement logic. * Note: The canonical type has different values: * ['allow', 'deny', 'constrain', 'clarify', 'escalate', 'log', 'audit'] */ export type ControlAction = 'allow' | 'deny' | 'escalate' | 'limit' | 'constrain' | 'monitor' | 'terminate'; /** * Entity identity * * @deprecated Prefer using Component from @vorionsys/contracts for agent registry. * This interface is maintained for backwards compatibility. */ export interface Entity { id: ID; type: EntityType; name: string; /** Trust score (0-1000 scale) */ trustScore: TrustScore; /** Trust level (0-7, maps to RuntimeTier T0-T7) */ trustLevel: TrustLevel; metadata: Record; createdAt: Timestamp; updatedAt: Timestamp; } /** * Intent representing a goal to be governed * * Note: This is the legacy internal Intent type. For canonical intent structure, * see packages/contracts/src/v2/intent.ts which uses: * - intentId (instead of id) * - agentId (instead of entityId) * - action (instead of goal) * * @deprecated Prefer using Intent from @vorionsys/contracts for new integrations. * This interface is maintained for internal backwards compatibility. */ export interface Intent { /** Unique intent identifier */ id: ID; /** Tenant this intent belongs to */ tenantId: ID; /** Entity (agent) making the request - maps to canonical agentId */ entityId: ID; /** Goal/action to be performed - maps to canonical action */ goal: string; /** Optional intent type categorization */ intentType?: string | null; /** Additional context for evaluation */ context: Record; /** Additional metadata */ metadata: Record; /** Priority level (0-10) */ priority?: number; /** Trust state snapshot at intent creation */ trustSnapshot?: Record | null; /** Trust level at evaluation (0-7) */ trustLevel?: TrustLevel | null; /** Trust score at evaluation (0-1000) */ trustScore?: TrustScore | null; /** Current status */ status: IntentStatus; /** Creation timestamp */ createdAt: Timestamp; /** Last update timestamp */ updatedAt: Timestamp; /** Soft delete timestamp for GDPR compliance */ deletedAt?: Timestamp | null; /** Reason for cancellation if status is 'cancelled' */ cancellationReason?: string | null; } /** * Evaluation stages in the intent lifecycle */ export type EvaluationStage = 'trust-snapshot' | 'trust-gate' | 'basis' | 'decision' | 'error' | 'cancelled'; /** * Strongly typed evaluation result by stage * Note: basis.evaluation and decision.decision use unknown to accept * external types (EvaluationResult from BASIS, Decision from ENFORCE) */ export type EvaluationPayload = { stage: 'trust-snapshot'; result: Record | null; } | { stage: 'trust-gate'; passed: boolean; requiredLevel: number; actualLevel: number; } | { stage: 'basis'; evaluation: unknown; namespace: string; } | { stage: 'decision'; decision: unknown; } | { stage: 'semantic-governance'; result: Record; } | { stage: 'error'; error: { message: string; timestamp: string; }; } | { stage: 'cancelled'; reason: string; cancelledBy?: string; }; export interface IntentEvaluationRecord { id: ID; intentId: ID; tenantId: ID; /** Strongly typed result payload */ result: EvaluationPayload; createdAt: Timestamp; } /** * Constraint definition */ export interface Constraint { id: ID; namespace: string; name: string; description: string; version: string; rule: ConstraintRule; enabled: boolean; createdAt: Timestamp; updatedAt: Timestamp; } /** * Constraint rule definition */ export interface ConstraintRule { when: ConstraintCondition; evaluate: ConstraintEvaluation[]; } /** * Constraint condition */ export interface ConstraintCondition { intentType?: string; entityType?: EntityType; conditions?: Record; } /** * Constraint evaluation step */ export interface ConstraintEvaluation { condition: string; result: ControlAction; reason?: string; } /** * Result of evaluating a single constraint/rule */ export interface ConstraintEvaluationResult { constraintId: ID; passed: boolean; action: ControlAction; reason: string; details: Record; durationMs: number; evaluatedAt: Timestamp; } /** * Decision from ENFORCE * * Note: The canonical Decision type in @vorionsys/contracts uses: * - decisionId, intentId, agentId, correlationId * - permitted: boolean (instead of action) * - constraints: DecisionConstraints * - trustBand: TrustBand (instead of trustLevel) * * @deprecated Prefer using Decision from @vorionsys/contracts for new integrations. * This interface is maintained for backwards compatibility. */ export interface Decision { intentId: ID; action: ControlAction; constraintsEvaluated: ConstraintEvaluationResult[]; /** Trust score (0-1000 scale) */ trustScore: TrustScore; /** Trust level (0-5, maps to canonical TrustBand) */ trustLevel: TrustLevel; escalation?: EscalationRequest; decidedAt: Timestamp; } /** * Escalation request */ export interface EscalationRequest { id: ID; intentId: ID; reason: string; escalatedTo: string; timeout: string; status: 'pending' | 'approved' | 'rejected' | 'timeout'; createdAt: Timestamp; } /** * Proof record for audit trail */ export interface Proof { id: ID; chainPosition: number; intentId: ID; entityId: ID; decision: Decision; inputs: Record; outputs: Record; hash: string; previousHash: string; signature: string; createdAt: Timestamp; } /** * Trust signal for scoring * * @deprecated Prefer using TrustEvidence from @vorionsys/contracts for new code. * This interface is maintained for backwards compatibility. */ export interface TrustSignal { /** Unique signal identifier */ id: ID; /** Entity this signal is for */ entityId: ID; /** Type/category of signal */ type: string; /** Signal value (impact on trust) */ value: number; /** Weight multiplier for this signal (default: 1.0) */ weight: number; /** Source system that generated this signal */ source: string; /** When this signal was recorded */ timestamp: Timestamp; /** Additional context */ metadata?: Record; } /** * Trust score breakdown */ export interface TrustComponents { behavioral: number; compliance: number; identity: number; context: number; } /** * Error types */ export declare class VorionError extends Error { code: string; details?: Record | undefined; constructor(message: string, code: string, details?: Record | undefined); } export declare class ConstraintViolationError extends VorionError { constraintId: ID; constraintName: string; suggestion?: string | undefined; constructor(constraintId: ID, constraintName: string, message: string, suggestion?: string | undefined); } export declare class TrustInsufficientError extends VorionError { required: TrustLevel; actual: TrustLevel; constructor(required: TrustLevel, actual: TrustLevel); }