/** * Revision Recovery: Audited Recovery from Invalid Historical Revisions * * Provides mechanisms to safely recover from corrupt/invalid historical revisions * under strict safety constraints and comprehensive audit trail requirements. */ /** * Authorization level required for revision recovery operations */ export type RecoveryAuthorization = 'ELEVATED' | 'ADMIN' | 'EMERGENCY'; /** * Compatibility classification for manifest changes */ export type CompatibilityClassification = 'COMPATIBLE' | 'WARNING' | 'INCOMPATIBLE'; /** * Recovery mode indicating what was approved */ export type RecoveryMode = 'SAFE_COMPATIBLE' | 'WARNING_APPROVED' | 'DESTRUCTIVE_APPROVED'; /** * Input for recovering an application revision */ export interface RevisionRecoveryInput { /** Application ID being recovered */ applicationId: string; /** Current revision that is invalid/corrupt (must match actual current) */ expectedCurrentRevision: string; /** Target revision to promote to (must be valid and integrity-checked) */ targetRevision: string; /** Elevated authorization level required */ authorization: RecoveryAuthorization; /** Actor (user/service) approving recovery */ actor: string; /** Explicit reason for recovery */ reason: string; /** Environment being recovered */ environment?: string; /** Allow destructive schema changes if compatibility check requires it */ allowDestructiveChange?: boolean; /** Explicit reason for approving destructive changes (required if allowDestructiveChange=true) */ destructiveChangeReason?: string; /** Idempotency key for recovery operation */ recoveryId?: string; } /** * Audit record for a completed revision recovery */ export interface RevisionRecoveryAudit { /** Unique audit record ID */ auditId: string; /** Application being recovered */ applicationId: string; /** Source (corrupt) revision being abandoned */ sourceRevision: string; /** Recomputed hash of source revision (for verification) */ sourceRevisionHash: string; /** Target revision being promoted to */ targetRevision: string; /** Hash of target revision */ targetRevisionHash: string; /** Hash of previous audit record in chain (for immutability) */ previousAuditHash?: string; /** Hash of this audit record */ auditHash: string; /** Actor who approved recovery */ approvedBy: string; /** Recovery reason provided */ reason: string; /** Authorization level that was required */ authorizationLevel: RecoveryAuthorization; /** Mode of recovery (what was approved) */ recoveryMode: RecoveryMode; /** Compatibility classification from diff analysis */ compatibilityClassification: CompatibilityClassification; /** Detailed compatibility issues found (if any) */ compatibilityIssues?: string[]; /** Destructive change approval reason (if applicable) */ destructiveChangeReason?: string; /** Timestamp of recovery */ recoveredAt: number; /** Idempotency key for the recovery operation */ recoveryId: string; /** Status of recovery operation */ status: 'COMPLETED' | 'PARTIAL' | 'ROLLED_BACK'; /** Marker indicating source revision must never be moved back to */ markedUntrustedUntilRevision: string; } /** * Result of a revision recovery attempt */ export interface RevisionRecoveryResult { /** Whether recovery succeeded */ success: boolean; /** Error code if recovery failed */ errorCode?: 'PERMISSION_DENIED' | 'CONFLICT' | 'INCOMPATIBLE_SCHEMA' | 'CORRUPT_REVISION_UNMOVABLE' | 'STORAGE_FAILURE' | 'VALIDATION_FAILED'; /** Human-readable error message */ errorMessage?: string; /** Audit record created (present if recovery succeeds or partially completes) */ audit?: RevisionRecoveryAudit; /** Current revision pointer after recovery attempt */ currentRevision: string; /** Whether audit record was durable persisted */ auditDurable: boolean; /** Pointer was successfully moved to target */ pointerMoved: boolean; /** Source revision was marked untrusted */ sourceMarkedUntrusted: boolean; } /** * Revision state tracking for corrupt/untrusted revisions */ export interface RevisionState { /** Revision ID */ revisionId: string; /** Whether revision is valid/trusted */ trusted: boolean; /** Marker: any revision equal to or before this cannot be promoted to */ untrustedUntilRevision?: string; /** Reason revision was marked untrusted (if applicable) */ untrustedReason?: string; /** Timestamp when marked untrusted */ markedUntrustedAt?: number; /** Reference to recovery audit that marked it untrusted */ recoveryAuditId?: string; } /** * Compatibility check result */ export interface CompatibilityCheckResult { /** Overall compatibility classification */ classification: CompatibilityClassification; /** List of specific issues or warnings found */ issues: Array<{ category: 'SCHEMA_CHANGE' | 'DATA_LOSS' | 'REFERENCE_BREAKING' | 'INDEX_REMOVAL'; severity: 'WARNING' | 'INCOMPATIBLE'; detail: string; }>; /** Whether any data loss would occur */ causesDataLoss: boolean; /** Whether this is a breaking change */ isBreakingChange: boolean; /** Recommended action */ recommendation: string; } /** * Validates revision recovery input */ export declare function validateRevisionRecoveryInput(input: RevisionRecoveryInput): { valid: boolean; error?: string; }; /** * Generates cryptographic hash for audit record chain */ export declare function generateAuditHash(data: Record, previousHash?: string): string; /** * Checks if a revision pointer transition would violate untrust markers */ export declare function wouldViolateUntrustworthiness(fromRevision: string, toRevision: string, revisionStates: Map): { violates: boolean; reason?: string; }; //# sourceMappingURL=revision-recovery.d.ts.map