Skip to content

@codesoul-co/hypha-inference / recovery

Using this module

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

Import from the package entrypoint

ts
import {
  adviseInferenceRecovery,
  classifyInferenceCacheFailure,
  classifyInferenceFailure,
} from '@codesoul-co/hypha-inference';

import type {
  InferenceFailureContext,
  InferenceRecoveryAdvice,
  InferenceRecoveryOperation,
} from '@codesoul-co/hypha-inference';

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 3 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
adviseInferenceRecoveryfunctionadviseInferenceRecovery(failure: RecoveryFailure): InferenceRecoveryAdviceAdvise Inference Recovery function with 1 public call signature; parameters and return types are listed below.
classifyInferenceCacheFailurefunctionclassifyInferenceCacheFailure(error: unknown, context: InferenceFailureContext): RecoveryFailureClassify Inference Cache Failure function with 1 public call signature; parameters and return types are listed below.
classifyInferenceFailurefunctionclassifyInferenceFailure(error: unknown, context: InferenceFailureContext): RecoveryFailureClassify Inference Failure function with 1 public call signature; parameters and return types are listed below.
InferenceFailureContextinterfaceinterface InferenceFailureContextInference Failure Context interface with 9 public fields or methods.
InferenceRecoveryAdviceinterfaceinterface InferenceRecoveryAdviceInference Recovery Advice interface with 4 public fields or methods.
InferenceRecoveryOperationtypetype InferenceRecoveryOperation = 'infer' | 'stream' | 'prefix_cache_read' | 'kv_cache_read' | 'kv_cache_write' | 'cache_invalidate'Public type alias for Inference Recovery Operation; the declaration contains its complete type expression.

adviseInferenceRecovery

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

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

Declaration

text
export declare function adviseInferenceRecovery(failure: RecoveryFailure): InferenceRecoveryAdvice;

Call signature

text
adviseInferenceRecovery(failure: RecoveryFailure): InferenceRecoveryAdvice

Parameters

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

Returns

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

classifyInferenceCacheFailure

Classify Inference Cache Failure function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function classifyInferenceCacheFailure(error: unknown, context: InferenceFailureContext): RecoveryFailure;

Call signature

text
classifyInferenceCacheFailure(error: unknown, context: InferenceFailureContext): RecoveryFailure

Parameters

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

Returns

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

classifyInferenceFailure

Classify Inference Failure function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function classifyInferenceFailure(error: unknown, context: InferenceFailureContext): RecoveryFailure;

Call signature

text
classifyInferenceFailure(error: unknown, context: InferenceFailureContext): RecoveryFailure

Parameters

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

Returns

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

InferenceFailureContext

Inference Failure Context interface with 9 public fields or methods.

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

Declaration

text
export interface InferenceFailureContext {
    id: string;
    operation: InferenceRecoveryOperation;
    request: InferenceRequest;
    providerId: string;
    occurredAt?: string;
    providerRevision?: string;
    policyRevision?: string;
    specRevision?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
idpropertyid: stringPublic 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.
occurredAtpropertyoccurredAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
operationpropertyoperation: InferenceRecoveryOperationPublic 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.
requestpropertyrequest: InferenceRequest<unknown>Public 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.

InferenceRecoveryAdvice

Inference Recovery Advice interface with 4 public fields or methods.

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

Declaration

text
export interface InferenceRecoveryAdvice {
    strategy: RecoveryStrategy;
    reason: string;
    mayUseCompatibleProviderFallback: boolean;
    mayBypassCache: boolean;
}

Contract members

MemberKindSignatureDescription
mayBypassCachepropertymayBypassCache: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
mayUseCompatibleProviderFallbackpropertymayUseCompatibleProviderFallback: 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.
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.

InferenceRecoveryOperation

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

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

Declaration

text
export type InferenceRecoveryOperation = 'infer' | 'stream' | 'prefix_cache_read' | 'kv_cache_read' | 'kv_cache_write' | 'cache_invalidate';