@codesoul-co/hypha-harness / recovery-loop
- Package index:
@codesoul-co/hypha-harness - Source:
packages/harness/src/recovery-loop.ts - Exports: 5
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
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
| Symbol | Kind | Signature | Description |
|---|---|---|---|
runFSMRecoveryLoop | function | 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. |
FSMRecoveryAttemptContext | interface | interface FSMRecoveryAttemptContext | FSM Recovery Attempt Context interface with 2 public fields or methods. |
FSMRecoveryLoopOptions | interface | interface FSMRecoveryLoopOptions | FSM Recovery Loop Options interface with 12 public fields or methods. |
FSMRecoveryLoopResult | interface | interface FSMRecoveryLoopResult | FSM Recovery Loop Result interface with 5 public fields or methods. |
FSMRecoveryLoopScheduler | interface | interface FSMRecoveryLoopScheduler | FSM 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
export declare function runFSMRecoveryLoop<TOutput>(options: FSMRecoveryLoopOptions<TOutput>): Promise<FSMRecoveryLoopResult<TOutput>>;Call signature
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
| Parameter | Type | Required | Description |
|---|---|---|---|
options | FSMRecoveryLoopOptions<TOutput> | Yes | Required 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
export interface FSMRecoveryAttemptContext {
attempt: number;
signal?: AbortSignal;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
attempt | property | attempt: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
signal | property | signal?: AbortSignal | Public 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
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
| Member | Kind | Signature | Description |
|---|---|---|---|
classify | method | classify?(error: unknown, context: FSMRecoveryAttemptContext): FSMAnomaly | Promise<FSMAnomaly> | Public method; parameters and return type are shown in the signature. |
compensate | method | compensate?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<void> | Public method; parameters and return type are shown in the signature. |
degrade | method | degrade?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<TOutput> | Public method; parameters and return type are shown in the signature. |
execute | method | execute(context: FSMRecoveryAttemptContext): Promise<TOutput> | Public method; parameters and return type are shown in the signature. |
fallback | method | fallback?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<TOutput> | Public method; parameters and return type are shown in the signature. |
fsm | property | fsm: FSMRuntime | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxInlineDelayMs | property | maxInlineDelayMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
now | method | now?(): string | Public method; parameters and return type are shown in the signature. |
reconcile | method | reconcile?(decision: FSMRecoveryDecision, context: FSMRecoveryAttemptContext): Promise<TOutput> | Public method; parameters and return type are shown in the signature. |
scheduler | property | scheduler?: FSMRecoveryLoopScheduler | Public property; its type, readonly modifier and optionality are shown in the signature. |
signal | property | signal?: AbortSignal | Public property; its type, readonly modifier and optionality are shown in the signature. |
source | property | source: "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
export interface FSMRecoveryLoopResult<TOutput> {
status: 'succeeded' | 'degraded' | 'suspended' | 'compensated' | 'failed' | 'cancelled';
output?: TOutput;
error?: unknown;
decision?: FSMRecoveryDecision;
attempts: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
attempts | property | attempts: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
decision | property | decision?: FSMRecoveryDecision | Public property; its type, readonly modifier and optionality are shown in the signature. |
error | property | error?: unknown | Public property; its type, readonly modifier and optionality are shown in the signature. |
output | property | output?: TOutput | Public property; its type, readonly modifier and optionality are shown in the signature. |
status | property | status: "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
export interface FSMRecoveryLoopScheduler {
wait(delayMs: number, decision: FSMRecoveryDecision, signal?: AbortSignal): Promise<void>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
wait | method | wait(delayMs: number, decision: FSMRecoveryDecision, signal?: AbortSignal): Promise<void> | Public method; parameters and return type are shown in the signature. |
