@codesoul-co/hypha-inference / recovery
- Package index:
@codesoul-co/hypha-inference - Source:
packages/inference/src/recovery.ts - Exports: 6
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
| Symbol | Kind | Signature | Description |
|---|---|---|---|
adviseInferenceRecovery | function | adviseInferenceRecovery(failure: RecoveryFailure): InferenceRecoveryAdvice | Advise Inference Recovery function with 1 public call signature; parameters and return types are listed below. |
classifyInferenceCacheFailure | function | classifyInferenceCacheFailure(error: unknown, context: InferenceFailureContext): RecoveryFailure | Classify Inference Cache Failure function with 1 public call signature; parameters and return types are listed below. |
classifyInferenceFailure | function | classifyInferenceFailure(error: unknown, context: InferenceFailureContext): RecoveryFailure | Classify Inference Failure function with 1 public call signature; parameters and return types are listed below. |
InferenceFailureContext | interface | interface InferenceFailureContext | Inference Failure Context interface with 9 public fields or methods. |
InferenceRecoveryAdvice | interface | interface InferenceRecoveryAdvice | Inference Recovery Advice interface with 4 public fields or methods. |
InferenceRecoveryOperation | type | type 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): InferenceRecoveryAdviceParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
failure | RecoveryFailure | Yes | Required 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): RecoveryFailureParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
error | unknown | Yes | Required parameter; accepted values are defined by the type column. |
context | InferenceFailureContext | Yes | Required 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): RecoveryFailureParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
error | unknown | Yes | Required parameter; accepted values are defined by the type column. |
context | InferenceFailureContext | Yes | Required 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
| Member | Kind | Signature | Description |
|---|---|---|---|
id | property | id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
metadata | property | metadata?: Record<string, unknown> | Public property; its type, readonly modifier and optionality are shown in the signature. |
occurredAt | property | occurredAt?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
operation | property | operation: InferenceRecoveryOperation | Public property; its type, readonly modifier and optionality are shown in the signature. |
policyRevision | property | policyRevision?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
providerId | property | providerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
providerRevision | property | providerRevision?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
request | property | request: InferenceRequest<unknown> | Public property; its type, readonly modifier and optionality are shown in the signature. |
specRevision | property | specRevision?: string | Public 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
| Member | Kind | Signature | Description |
|---|---|---|---|
mayBypassCache | property | mayBypassCache: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
mayUseCompatibleProviderFallback | property | mayUseCompatibleProviderFallback: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
reason | property | reason: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
strategy | property | strategy: "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';