Skip to content

@codesoul-co/hypha-harness / recovery-loop

Using this module

Use the Recovery loop module for handling bounded recovery, retry, or degradation. It exports 1 function, 4 interfaces.

Import from the package entrypoint

ts
import {
  runFSMRecoveryLoop,
} from '@codesoul-co/hypha-harness';

import type {
  FSMRecoveryAttemptContext,
  FSMRecoveryLoopOptions,
  FSMRecoveryLoopResult,
  FSMRecoveryLoopScheduler,
} from '@codesoul-co/hypha-harness';

Usage patterns

  • Use the 4 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 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
runFSMRecoveryLoopfunctionrunFSMRecoveryLoop<TOutput>(options: FSMRecoveryLoopOptions<TOutput>): Promise<FSMRecoveryLoopResult<TOutput>>Runs only the bounded recovery loop described by the FSM recovery policy. Delayed retries are suspended by default; a caller must inject a scheduler and explicitly opt into an inline delay budget to keep them in-process.
FSMRecoveryAttemptContextinterfaceinterface FSMRecoveryAttemptContextFSM Recovery Attempt Context interface with 2 public fields or methods.
FSMRecoveryLoopOptionsinterfaceinterface FSMRecoveryLoopOptionsFSM Recovery Loop Options interface with 12 public fields or methods.
FSMRecoveryLoopResultinterfaceinterface FSMRecoveryLoopResultFSM Recovery Loop Result interface with 5 public fields or methods.
FSMRecoveryLoopSchedulerinterfaceinterface FSMRecoveryLoopSchedulerFSM Recovery Loop Scheduler interface with 1 public fields or methods.

runFSMRecoveryLoop

Runs only the bounded recovery loop described by the FSM recovery policy. Delayed retries are suspended by default; a caller must inject a scheduler and explicitly opt into an inline delay budget to keep them in-process.

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

Declaration

text
export declare function runFSMRecoveryLoop<TOutput>(options: FSMRecoveryLoopOptions<TOutput>): Promise<FSMRecoveryLoopResult<TOutput>>;

Call signature

text
runFSMRecoveryLoop<TOutput>(options: FSMRecoveryLoopOptions<TOutput>): Promise<FSMRecoveryLoopResult<TOutput>>

Runs only the bounded recovery loop described by the FSM recovery policy. Delayed retries are suspended by default; a caller must inject a scheduler and explicitly opt into an inline delay budget to keep them in-process.

Parameters

ParameterTypeRequiredDescription
optionsFSMRecoveryLoopOptions<TOutput>YesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: Promise<FSMRecoveryLoopResult<TOutput>>
  • Description: The return contract is defined by the type shown above.

FSMRecoveryAttemptContext

FSM Recovery Attempt Context interface with 2 public fields or methods.

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

Declaration

text
export interface FSMRecoveryAttemptContext {
    attempt: number;
    signal?: AbortSignal;
}

Contract members

MemberKindSignatureDescription
attemptpropertyattempt: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
signalpropertysignal?: AbortSignalPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryLoopOptions

FSM Recovery Loop Options interface with 12 public fields or methods.

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

Declaration

text
export interface FSMRecoveryLoopOptions<TOutput> {
    fsm: FSMRuntime;
    source: FSMAnomalySource;
    execute(context: FSMRecoveryAttemptContext): Promise<TOutput>;
    classify?: (error: unknown, context: FSMRecoveryAttemptContext) => FSMAnomaly | Promise<FSMAnomaly>;
    compensate?: (decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext) => Promise<void>;
    reconcile?: (decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext) => Promise<TOutput>;
    fallback?: (decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext) => Promise<TOutput>;
    degrade?: (decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext) => Promise<TOutput>;
    scheduler?: FSMRecoveryLoopScheduler;
    maxInlineDelayMs?: number;
    signal?: AbortSignal;
    now?: () => string;
}

Contract members

MemberKindSignatureDescription
classifymethodclassify?(error: unknown, context: FSMRecoveryAttemptContext): FSMAnomaly | Promise<FSMAnomaly>Public method; parameters and return type are shown in the signature.
compensatemethodcompensate?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<void>Public method; parameters and return type are shown in the signature.
degrademethoddegrade?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<TOutput>Public method; parameters and return type are shown in the signature.
executemethodexecute(context: FSMRecoveryAttemptContext): Promise<TOutput>Public method; parameters and return type are shown in the signature.
fallbackmethodfallback?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<TOutput>Public method; parameters and return type are shown in the signature.
fsmpropertyfsm: FSMRuntimePublic property; its type, readonly modifier and optionality are shown in the signature.
maxInlineDelayMspropertymaxInlineDelayMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
reconcilemethodreconcile?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<TOutput>Public method; parameters and return type are shown in the signature.
schedulerpropertyscheduler?: FSMRecoveryLoopSchedulerPublic property; its type, readonly modifier and optionality are shown in the signature.
signalpropertysignal?: AbortSignalPublic property; its type, readonly modifier and optionality are shown in the signature.
sourcepropertysource: "memory" | "domain" | "mcp" | "policy" | "workspace" | "tool" | "unknown" | "execution" | "fsm" | "inference" | "storage" | "message_bus" | "cache"Public property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryLoopResult

FSM Recovery Loop Result interface with 5 public fields or methods.

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

Declaration

text
export interface FSMRecoveryLoopResult<TOutput> {
    status: 'succeeded' | 'degraded' | 'suspended' | 'compensated' | 'failed' | 'cancelled';
    output?: TOutput;
    error?: unknown;
    decision?: FSMRecoveryDecision;
    attempts: number;
}

Contract members

MemberKindSignatureDescription
attemptspropertyattempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
decisionpropertydecision?: FSMRecoveryDecisionPublic property; its type, readonly modifier and optionality are shown in the signature.
errorpropertyerror?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
outputpropertyoutput?: TOutputPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "degraded" | "cancelled" | "failed" | "succeeded" | "suspended" | "compensated"Public property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryLoopScheduler

FSM Recovery Loop Scheduler interface with 1 public fields or methods.

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

Declaration

text
export interface FSMRecoveryLoopScheduler {
    wait(delayMs: number, decision: FSMRecoveryDecision, signal?: AbortSignal): Promise<void>;
}

Contract members

MemberKindSignatureDescription
waitmethodwait(delayMs: number, decision: FSMRecoveryDecision, signal?: AbortSignal): Promise<void>Public method; parameters and return type are shown in the signature.