Skip to content

@codesoul-co/hypha-storage / recovery

Using this module

Use the Recovery module for handling bounded recovery, retry, or degradation. It exports 2 functions, 2 interfaces, 1 type.

Import from the package entrypoint

ts
import {
  adviseStorageRecovery,
  classifyStorageFailure,
} from '@codesoul-co/hypha-storage';

import type {
  StorageFailureContext,
  StorageRecoveryAdvice,
  StorageRecoveryOperation,
} from '@codesoul-co/hypha-storage';

Usage patterns

  • Use the 3 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 2 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
adviseStorageRecoveryfunctionadviseStorageRecovery(failure: RecoveryFailure): StorageRecoveryAdviceAdvise Storage Recovery function with 1 public call signature; parameters and return types are listed below.
classifyStorageFailurefunctionclassifyStorageFailure(error: unknown, context: StorageFailureContext): RecoveryFailureConverts provider-specific storage errors into the shared recovery contract. Mutations default to an unknown commit state unless a receipt or the caller proves otherwise; this prevents blind replay after an ambiguous disconnect.
StorageFailureContextinterfaceinterface StorageFailureContextStorage Failure Context interface with 17 public fields or methods.
StorageRecoveryAdviceinterfaceinterface StorageRecoveryAdviceStorage Recovery Advice interface with 6 public fields or methods.
StorageRecoveryOperationtypetype StorageRecoveryOperation = 'read' | 'query' | 'list' | 'write' | 'update' | 'delete' | 'transaction_begin' | 'transaction_commit' | 'transaction_rollback' | 'event_append' | 'artifact_write' | 'artifact_delete' | 'lease_acquire' | 'lease_renew' | 'lease_release' | 'snapshot' | 'restore'Public type alias for Storage Recovery Operation; the declaration contains its complete type expression.

adviseStorageRecovery

Advise Storage Recovery function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { adviseStorageRecovery } from '@codesoul-co/hypha-storage';
  • Source module: recovery

Declaration

text
export declare function adviseStorageRecovery(failure: RecoveryFailure): StorageRecoveryAdvice;

Call signature

text
adviseStorageRecovery(failure: RecoveryFailure): StorageRecoveryAdvice

Parameters

ParameterTypeRequiredDescription
failureRecoveryFailureYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: StorageRecoveryAdvice
  • Description: The return contract is defined by the type shown above.

classifyStorageFailure

Converts provider-specific storage errors into the shared recovery contract. Mutations default to an unknown commit state unless a receipt or the caller proves otherwise; this prevents blind replay after an ambiguous disconnect.

  • Kind: function
  • Import: import { classifyStorageFailure } from '@codesoul-co/hypha-storage';
  • Source module: recovery

Declaration

text
export declare function classifyStorageFailure(error: unknown, context: StorageFailureContext): RecoveryFailure;

Call signature

text
classifyStorageFailure(error: unknown, context: StorageFailureContext): RecoveryFailure

Converts provider-specific storage errors into the shared recovery contract. Mutations default to an unknown commit state unless a receipt or the caller proves otherwise; this prevents blind replay after an ambiguous disconnect.

Parameters

ParameterTypeRequiredDescription
errorunknownYesRequired parameter; accepted values are defined by the type column.
contextStorageFailureContextYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: RecoveryFailure
  • Description: The return contract is defined by the type shown above.

StorageFailureContext

Storage Failure Context interface with 17 public fields or methods.

  • Kind: interface
  • Import: import type { StorageFailureContext } from '@codesoul-co/hypha-storage';
  • Source module: recovery

Declaration

text
export interface StorageFailureContext {
    id: string;
    operation: StorageRecoveryOperation;
    providerId: string;
    role: StorageRole;
    engine?: StorageEngine;
    resourceKey?: string;
    occurredAt?: string;
    providerRevision?: string;
    specRevision?: string;
    policyRevision?: string;
    expectedRevision?: string | number;
    observedRevision?: string | number;
    idempotencyKey?: string;
    input?: unknown;
    sideEffectState?: RecoverySideEffectState;
    compensationAvailable?: boolean;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
compensationAvailablepropertycompensationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
enginepropertyengine?: StorageEnginePublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRevisionpropertyexpectedRevision?: string | numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
inputpropertyinput?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
observedRevisionpropertyobservedRevision?: string | numberPublic property; its type, readonly modifier and optionality are shown in the signature.
occurredAtpropertyoccurredAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
operationpropertyoperation: StorageRecoveryOperationPublic property; its type, readonly modifier and optionality are shown in the signature.
policyRevisionpropertypolicyRevision?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerRevisionpropertyproviderRevision?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
resourceKeypropertyresourceKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
rolepropertyrole: StorageRolePublic property; its type, readonly modifier and optionality are shown in the signature.
sideEffectStatepropertysideEffectState?: RecoverySideEffectStatePublic property; its type, readonly modifier and optionality are shown in the signature.
specRevisionpropertyspecRevision?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

StorageRecoveryAdvice

Storage Recovery Advice interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { StorageRecoveryAdvice } from '@codesoul-co/hypha-storage';
  • Source module: recovery

Declaration

text
export interface StorageRecoveryAdvice {
    strategy: RecoveryStrategy;
    reason: string;
    requireReconciliation: boolean;
    refreshRevisionBeforeRetry: boolean;
    mayUseCompatibleReplica: boolean;
    invalidateDerivedCaches: boolean;
}

Contract members

MemberKindSignatureDescription
invalidateDerivedCachespropertyinvalidateDerivedCaches: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
mayUseCompatibleReplicapropertymayUseCompatibleReplica: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
refreshRevisionBeforeRetrypropertyrefreshRevisionBeforeRetry: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
requireReconciliationpropertyrequireReconciliation: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
strategypropertystrategy: "fail" | "retry" | "human_review" | "reconcile" | "fallback" | "degrade" | "compensate" | "wait" | "quarantine" | "cancel"Public property; its type, readonly modifier and optionality are shown in the signature.

StorageRecoveryOperation

Public type alias for Storage Recovery Operation; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { StorageRecoveryOperation } from '@codesoul-co/hypha-storage';
  • Source module: recovery

Declaration

text
export type StorageRecoveryOperation = 'read' | 'query' | 'list' | 'write' | 'update' | 'delete' | 'transaction_begin' | 'transaction_commit' | 'transaction_rollback' | 'event_append' | 'artifact_write' | 'artifact_delete' | 'lease_acquire' | 'lease_renew' | 'lease_release' | 'snapshot' | 'restore';