Skip to content

@codesoul-co/hypha-memory / bounded-recovery

Using this module

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

Import from the package entrypoint

ts
import {
  createMemoryFailureFingerprint,
  resolveBoundedMemoryRecovery,
} from '@codesoul-co/hypha-memory';

import type {
  BoundedMemoryRecoveryOutcome,
  MemoryRecoveryBudget,
  MemoryRunRecoveryState,
} from '@codesoul-co/hypha-memory';

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
createMemoryFailureFingerprintfunctioncreateMemoryFailureFingerprint(failure: RecoveryFailure): stringCreate Memory Failure Fingerprint function with 1 public call signature; parameters and return types are listed below.
resolveBoundedMemoryRecoveryfunctionresolveBoundedMemoryRecovery(failure: RecoveryFailure, budget: MemoryRecoveryBudget): BoundedMemoryRecoveryOutcomeResolve Bounded Memory Recovery function with 1 public call signature; parameters and return types are listed below.
BoundedMemoryRecoveryOutcomeinterfaceinterface BoundedMemoryRecoveryOutcomeBounded Memory Recovery Outcome interface with 7 public fields or methods.
MemoryRecoveryBudgetinterfaceinterface MemoryRecoveryBudgetMemory Recovery Budget interface with 5 public fields or methods.
MemoryRunRecoveryStatetypetype MemoryRunRecoveryState = 'degraded' | 'waiting' | 'review' | 'quarantined' | 'failed'Public type alias for Memory Run Recovery State; the declaration contains its complete type expression.

createMemoryFailureFingerprint

Create Memory Failure Fingerprint function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function createMemoryFailureFingerprint(failure: RecoveryFailure): string;

Call signature

text
createMemoryFailureFingerprint(failure: RecoveryFailure): string

Parameters

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

Returns

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

resolveBoundedMemoryRecovery

Resolve Bounded Memory Recovery function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function resolveBoundedMemoryRecovery(failure: RecoveryFailure, budget: MemoryRecoveryBudget): BoundedMemoryRecoveryOutcome;

Call signature

text
resolveBoundedMemoryRecovery(failure: RecoveryFailure, budget: MemoryRecoveryBudget): BoundedMemoryRecoveryOutcome

Parameters

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

Returns

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

BoundedMemoryRecoveryOutcome

Bounded Memory Recovery Outcome interface with 7 public fields or methods.

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

Declaration

text
export interface BoundedMemoryRecoveryOutcome {
    state: MemoryRunRecoveryState;
    strategy: ReturnType<typeof adviseMemoryRecovery>['strategy'];
    retryAllowed: boolean;
    boundedEmptyResultAllowed: boolean;
    failureFingerprint: string;
    reason: string;
    nextAttempt?: number;
}

Contract members

MemberKindSignatureDescription
boundedEmptyResultAllowedpropertyboundedEmptyResultAllowed: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
failureFingerprintpropertyfailureFingerprint: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
nextAttemptpropertynextAttempt?: numberPublic 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.
retryAllowedpropertyretryAllowed: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
statepropertystate: MemoryRunRecoveryStatePublic 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.

MemoryRecoveryBudget

Memory Recovery Budget interface with 5 public fields or methods.

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

Declaration

text
export interface MemoryRecoveryBudget {
    maxAttempts: number;
    attemptsUsed: number;
    deadline?: string;
    now?: string;
    seenFailureFingerprints?: string[];
}

Contract members

MemberKindSignatureDescription
attemptsUsedpropertyattemptsUsed: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
deadlinepropertydeadline?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
maxAttemptspropertymaxAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
nowpropertynow?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
seenFailureFingerprintspropertyseenFailureFingerprints?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.

MemoryRunRecoveryState

Public type alias for Memory Run Recovery State; the declaration contains its complete type expression.

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

Declaration

text
export type MemoryRunRecoveryState = 'degraded' | 'waiting' | 'review' | 'quarantined' | 'failed';