Skip to content

@codesoul-co/hypha-fsm / recovery

Using this module

Use the Recovery module for handling bounded recovery, retry, or degradation. It exports 7 constants, 5 functions, 10 interfaces, 5 types.

Import from the package entrypoint

ts
import {
  defaultFSMRecoveryPolicy,
  FSM_ANOMALY_CATEGORIES,
  FSM_ANOMALY_SOURCES,
  FSM_RECOVERY_ACTIONS,
  fsmAnomalySchema,
  fsmRecoveryPolicySpecSchema,
  fsmRecoverySnapshotSchema,
  classifyFSMAnomaly,
} from '@codesoul-co/hypha-fsm';

import type {
  FSMAnomaly,
  FSMAnomalyClassificationInput,
  FSMCircuitBreakerPolicy,
  FSMCircuitSnapshot,
  FSMRecoveryBackoffPolicy,
  FSMRecoveryDecision,
  FSMRecoveryPlan,
  FSMRecoveryPolicySpec,
} from '@codesoul-co/hypha-fsm';

// The complete export list is documented below.

Usage patterns

  • Use the 15 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 5 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
  • The 7 constant/enum exports provide stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Runtime validation example

ts
import { fsmAnomalySchema } from '@codesoul-co/hypha-fsm';

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = fsmAnomalySchema.parse(input);

Parse untrusted configuration, network, or persisted input with the runtime schema before passing it to functions or classes that expect a validated contract.

Public exports

SymbolKindSignatureDescription
defaultFSMRecoveryPolicyconstantconst defaultFSMRecoveryPolicy: FSMRecoveryPolicySpecDefault FSM Recovery Policy constant exported by the recovery module.
FSM_ANOMALY_CATEGORIESconstantconst FSM_ANOMALY_CATEGORIES: readonly ["validation", "policy_denied", "authentication", "authorization", "rate_limit", "timeout", "transient_dependency", "permanent_dependency", "concurrency_conflict", "resource_exhausted", "tool_failure", "inference_failure", "memory_failure", "execution_failure", "storage_failure", "message_failure", "cache_failure", "invariant_violation", "cancellation", "unknown"]FSM ANOMALY CATEGORIES constant exported by the recovery module.
FSM_ANOMALY_SOURCESconstantconst FSM_ANOMALY_SOURCES: readonly ["fsm", "inference", "tool", "memory", "execution", "mcp", "workspace", "storage", "message_bus", "cache", "policy", "domain", "unknown"]FSM ANOMALY SOURCES constant exported by the recovery module.
FSM_RECOVERY_ACTIONSconstantconst FSM_RECOVERY_ACTIONS: readonly ["retry", "reconcile", "fallback", "degrade", "wait", "compensate", "human_review", "quarantine", "fail", "cancel"]FSM RECOVERY ACTIONS constant exported by the recovery module.
fsmAnomalySchemaconstantconst fsmAnomalySchema: z.ZodObject<{ id: z.ZodString; source: z.ZodEnum<["fsm", "inference", "tool", "memory", "execution", "mcp", "workspace", "storage", "message_bus", "cache", "policy", "domain", "unknown"]>; category: z.ZodEnum<["validation", "policy_denied", "authentication", "authorization", "rate_limit", "timeout", "transient_dependency", "permanent_dependency", "concurrency_conflict", "resource_exhausted"...Runtime schema for FSM Anomaly.
fsmRecoveryPolicySpecSchemaconstantconst fsmRecoveryPolicySpecSchema: z.ZodObject<{ maxAttemptsPerState: z.ZodNumber; maxTotalAttempts: z.ZodNumber; maxElapsedMs: z.ZodNumber; retryableCategories: z.ZodArray<z.ZodEnum<["validation", "policy_denied", "authentication", "authorization", "rate_limit", "timeout", "transient_dependency", "permanent_dependency", "concurrency_conflict", "resource_exhausted", "tool_failure", "inference_failure", "memory_fai...Runtime schema for FSM Recovery Policy Spec.
fsmRecoverySnapshotSchemaconstantconst fsmRecoverySnapshotSchema: z.ZodObject<{ startedAt: z.ZodString; updatedAt: z.ZodString; totalAttempts: z.ZodNumber; attemptsByState: z.ZodRecord<z.ZodString, z.ZodNumber>; circuits: z.ZodRecord<z.ZodString, z.ZodObject<{ status: z.ZodEnum<["closed", "open", "half_open"]>; consecutiveFailures: z.ZodNumber; halfOpenAttempts: z.ZodNumber; openedAt: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { status...Runtime schema for FSM Recovery Snapshot.
classifyFSMAnomalyfunctionclassifyFSMAnomaly(error: unknown, input: FSMAnomalyClassificationInput): FSMAnomalyClassify FSM Anomaly function with 1 public call signature; parameters and return types are listed below.
computeFSMRecoveryDelayfunctioncomputeFSMRecoveryDelay(policy: FSMRecoveryBackoffPolicy, attempt: number, seed: string): numberCompute FSM Recovery Delay function with 1 public call signature; parameters and return types are listed below.
createInitialFSMRecoverySnapshotfunctioncreateInitialFSMRecoverySnapshot(now?: string): FSMRecoverySnapshotCreate Initial FSM Recovery Snapshot function with 1 public call signature; parameters and return types are listed below.
planFSMRecoveryfunctionplanFSMRecovery(input: { anomaly: FSMAnomaly; stateId: string; policy?: FSMRecoveryPolicySpec; snapshot?: FSMRecoverySnapshot; now?: string; }): FSMRecoveryPlanPlan FSM Recovery function with 1 public call signature; parameters and return types are listed below.
registerFSMRecoverySuccessfunctionregisterFSMRecoverySuccess(snapshot: FSMRecoverySnapshot, circuitKey: string, now?: string): FSMRecoverySnapshotRegister FSM Recovery Success function with 1 public call signature; parameters and return types are listed below.
FSMAnomalyinterfaceinterface FSMAnomalyFSM Anomaly interface with 15 public fields or methods.
FSMAnomalyClassificationInputinterfaceinterface FSMAnomalyClassificationInputFSM Anomaly Classification Input interface with 12 public fields or methods.
FSMCircuitBreakerPolicyinterfaceinterface FSMCircuitBreakerPolicyFSM Circuit Breaker Policy interface with 3 public fields or methods.
FSMCircuitSnapshotinterfaceinterface FSMCircuitSnapshotFSM Circuit Snapshot interface with 4 public fields or methods.
FSMRecoveryBackoffPolicyinterfaceinterface FSMRecoveryBackoffPolicyFSM Recovery Backoff Policy interface with 4 public fields or methods.
FSMRecoveryDecisioninterfaceinterface FSMRecoveryDecisionFSM Recovery Decision interface with 16 public fields or methods.
FSMRecoveryPlaninterfaceinterface FSMRecoveryPlanFSM Recovery Plan interface with 2 public fields or methods.
FSMRecoveryPolicySpecinterfaceinterface FSMRecoveryPolicySpecFSM Recovery Policy Spec interface with 10 public fields or methods.
FSMRecoverySnapshotinterfaceinterface FSMRecoverySnapshotFSM Recovery Snapshot interface with 7 public fields or methods.
FSMRecoveryStateTargetsinterfaceinterface FSMRecoveryStateTargetsFSM Recovery State Targets interface with 6 public fields or methods.
FSMAnomalyCategorytypetype FSMAnomalyCategory = RecoveryCategoryPublic type alias for FSM Anomaly Category; the declaration contains its complete type expression.
FSMAnomalySourcetypetype FSMAnomalySource = RecoveryModulePublic type alias for FSM Anomaly Source; the declaration contains its complete type expression.
FSMCircuitStatustypetype FSMCircuitStatus = 'closed' | 'open' | 'half_open'Public type alias for FSM Circuit Status; the declaration contains its complete type expression.
FSMRecoveryActiontypetype FSMRecoveryAction = (typeof FSM_RECOVERY_ACTIONS)[number]Public type alias for FSM Recovery Action; the declaration contains its complete type expression.
FSMSideEffectStatetypetype FSMSideEffectState = RecoverySideEffectStatePublic type alias for FSM Side Effect State; the declaration contains its complete type expression.

defaultFSMRecoveryPolicy

Default FSM Recovery Policy constant exported by the recovery module.

  • Kind: constant
  • Import: import { defaultFSMRecoveryPolicy } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const defaultFSMRecoveryPolicy: FSMRecoveryPolicySpec;

FSM_ANOMALY_CATEGORIES

FSM ANOMALY CATEGORIES constant exported by the recovery module.

  • Kind: constant
  • Import: import { FSM_ANOMALY_CATEGORIES } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const FSM_ANOMALY_CATEGORIES: readonly ["validation", "policy_denied", "authentication", "authorization", "rate_limit", "timeout", "transient_dependency", "permanent_dependency", "concurrency_conflict", "resource_exhausted", "tool_failure", "inference_failure", "memory_failure", "execution_failure", "storage_failure", "message_failure", "cache_failure", "invariant_violation", "cancellation", "unknown"];

FSM_ANOMALY_SOURCES

FSM ANOMALY SOURCES constant exported by the recovery module.

  • Kind: constant
  • Import: import { FSM_ANOMALY_SOURCES } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const FSM_ANOMALY_SOURCES: readonly ["fsm", "inference", "tool", "memory", "execution", "mcp", "workspace", "storage", "message_bus", "cache", "policy", "domain", "unknown"];

FSM_RECOVERY_ACTIONS

FSM RECOVERY ACTIONS constant exported by the recovery module.

  • Kind: constant
  • Import: import { FSM_RECOVERY_ACTIONS } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const FSM_RECOVERY_ACTIONS: readonly ["retry", "reconcile", "fallback", "degrade", "wait", "compensate", "human_review", "quarantine", "fail", "cancel"];

fsmAnomalySchema

Runtime schema for FSM Anomaly.

  • Kind: constant
  • Import: import { fsmAnomalySchema } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const fsmAnomalySchema: z.ZodObject<{ id: z.ZodString; source: z.ZodEnum<["fsm", "inference", "tool", "memory", "execution", "mcp", "workspace", "storage", "message_bus", "cache", "policy", "domain", "unknown"]>; category: z.ZodEnum<["validation", "policy_denied", "authentication", "authorization", "rate_limit", "timeout", "transient_dependency", "permanent_dependency", "concurrency_conflict", "resource_exhausted", "tool_failure", "inference_failure", "memory_failure", "execution_failure", "storage_failure", "message_failure", "cache_failure", "invariant_violation", "cancellation", "unknown"]>; code: z.ZodString; message: z.ZodString; occurredAt: z.ZodString; retryable: z.ZodOptional<z.ZodBoolean>; retryAfterMs: z.ZodOptional<z.ZodNumber>; circuitKey: z.ZodOptional<z.ZodString>; sideEffectState: z.ZodOptional<z.ZodEnum<["none", "not_started", "committed", "unknown"]>>; compensationAvailable: z.ZodOptional<z.ZodBoolean>; reconciliationAvailable: z.ZodOptional<z.ZodBoolean>; fallbackAvailable: z.ZodOptional<z.ZodBoolean>; degradationAvailable: z.ZodOptional<z.ZodBoolean>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { id: string; source: "fsm" | "inference" | "tool" | "memory" | "execution" | "mcp" | "workspace" | "storage" | "message_bus" | "cache" | "policy" | "domain" | "unknown"; category: "unknown" | "validation" | "policy_denied" | "authentication" | "authorization" | "rate_limit" | "timeout" | "transient_dependency" | "permanent_dependency" | "concurrency_conflict" | "resource_exhausted" | "tool_failure" | "inference_failure" | "memory_failure" | "execution_failure" | "storage_failure" | "message_failure" | "cache_failure" | "invariant_violation" | "cancellation"; code: string; message: string; occurredAt: string; retryable?: boolean | undefined; retryAfterMs?: number | undefined; circuitKey?: string | undefined; sideEffectState?: "unknown" | "none" | "not_started" | "committed" | undefined; compensationAvailable?: boolean | undefined; reconciliationAvailable?: boolean | undefined; fallbackAvailable?: boolean | undefined; degradationAvailable?: boolean | undefined; metadata?: Record<string, unknown> | undefined; }, { id: string; source: "fsm" | "inference" | "tool" | "memory" | "execution" | "mcp" | "workspace" | "storage" | "message_bus" | "cache" | "policy" | "domain" | "unknown"; category: "unknown" | "validation" | "policy_denied" | "authentication" | "authorization" | "rate_limit" | "timeout" | "transient_dependency" | "permanent_dependency" | "concurrency_conflict" | "resource_exhausted" | "tool_failure" | "inference_failure" | "memory_failure" | "execution_failure" | "storage_failure" | "message_failure" | "cache_failure" | "invariant_violation" | "cancellation"; code: string; message: string; occurredAt: string; retryable?: boolean | undefined; retryAfterMs?: number | undefined; circuitKey?: string | undefined; sideEffectState?: "unknown" | "none" | "not_started" | "committed" | undefined; compensationAvailable?: boolean | undefined; reconciliationAvailable?: boolean | undefined; fallbackAvailable?: boolean | undefined; degradationAvailable?: boolean | undefined; metadata?: Record<string, unknown> | undefined; }>;

fsmRecoveryPolicySpecSchema

Runtime schema for FSM Recovery Policy Spec.

  • Kind: constant
  • Import: import { fsmRecoveryPolicySpecSchema } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const fsmRecoveryPolicySpecSchema: z.ZodObject<{ maxAttemptsPerState: z.ZodNumber; maxTotalAttempts: z.ZodNumber; maxElapsedMs: z.ZodNumber; retryableCategories: z.ZodArray<z.ZodEnum<["validation", "policy_denied", "authentication", "authorization", "rate_limit", "timeout", "transient_dependency", "permanent_dependency", "concurrency_conflict", "resource_exhausted", "tool_failure", "inference_failure", "memory_failure", "execution_failure", "storage_failure", "message_failure", "cache_failure", "invariant_violation", "cancellation", "unknown"]>, "many">; nonRetryableCodes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; backoff: z.ZodObject<{ initialDelayMs: z.ZodNumber; maxDelayMs: z.ZodNumber; multiplier: z.ZodNumber; jitterRatio: z.ZodNumber; }, "strip", z.ZodTypeAny, { initialDelayMs: number; maxDelayMs: number; multiplier: number; jitterRatio: number; }, { initialDelayMs: number; maxDelayMs: number; multiplier: number; jitterRatio: number; }>; circuitBreaker: z.ZodObject<{ failureThreshold: z.ZodNumber; resetTimeoutMs: z.ZodNumber; halfOpenMaxAttempts: z.ZodNumber; }, "strip", z.ZodTypeAny, { failureThreshold: number; resetTimeoutMs: number; halfOpenMaxAttempts: number; }, { failureThreshold: number; resetTimeoutMs: number; halfOpenMaxAttempts: number; }>; stateTargets: z.ZodObject<{ recovering: z.ZodString; compensating: z.ZodString; humanReview: z.ZodString; quarantined: z.ZodString; failed: z.ZodString; cancelled: z.ZodString; }, "strip", z.ZodTypeAny, { recovering: string; compensating: string; humanReview: string; quarantined: string; failed: string; cancelled: string; }, { recovering: string; compensating: string; humanReview: string; quarantined: string; failed: string; cancelled: string; }>; onExhausted: z.ZodEnum<["human_review", "quarantine", "fail"]>; afterCompensation: z.ZodEnum<["human_review", "quarantine", "fail"]>; }, "strip", z.ZodTypeAny, { maxAttemptsPerState: number; maxTotalAttempts: number; maxElapsedMs: number; retryableCategories: ("unknown" | "validation" | "policy_denied" | "authentication" | "authorization" | "rate_limit" | "timeout" | "transient_dependency" | "permanent_dependency" | "concurrency_conflict" | "resource_exhausted" | "tool_failure" | "inference_failure" | "memory_failure" | "execution_failure" | "storage_failure" | "message_failure" | "cache_failure" | "invariant_violation" | "cancellation")[]; backoff: { initialDelayMs: number; maxDelayMs: number; multiplier: number; jitterRatio: number; }; circuitBreaker: { failureThreshold: number; resetTimeoutMs: number; halfOpenMaxAttempts: number; }; stateTargets: { recovering: string; compensating: string; humanReview: string; quarantined: string; failed: string; cancelled: string; }; onExhausted: "human_review" | "quarantine" | "fail"; afterCompensation: "human_review" | "quarantine" | "fail"; nonRetryableCodes?: string[] | undefined; }, { maxAttemptsPerState: number; maxTotalAttempts: number; maxElapsedMs: number; retryableCategories: ("unknown" | "validation" | "policy_denied" | "authentication" | "authorization" | "rate_limit" | "timeout" | "transient_dependency" | "permanent_dependency" | "concurrency_conflict" | "resource_exhausted" | "tool_failure" | "inference_failure" | "memory_failure" | "execution_failure" | "storage_failure" | "message_failure" | "cache_failure" | "invariant_violation" | "cancellation")[]; backoff: { initialDelayMs: number; maxDelayMs: number; multiplier: number; jitterRatio: number; }; circuitBreaker: { failureThreshold: number; resetTimeoutMs: number; halfOpenMaxAttempts: number; }; stateTargets: { recovering: string; compensating: string; humanReview: string; quarantined: string; failed: string; cancelled: string; }; onExhausted: "human_review" | "quarantine" | "fail"; afterCompensation: "human_review" | "quarantine" | "fail"; nonRetryableCodes?: string[] | undefined; }>;

fsmRecoverySnapshotSchema

Runtime schema for FSM Recovery Snapshot.

  • Kind: constant
  • Import: import { fsmRecoverySnapshotSchema } from '@codesoul-co/hypha-fsm';
  • Source module: recovery

Declaration

text
export declare const fsmRecoverySnapshotSchema: z.ZodObject<{ startedAt: z.ZodString; updatedAt: z.ZodString; totalAttempts: z.ZodNumber; attemptsByState: z.ZodRecord<z.ZodString, z.ZodNumber>; circuits: z.ZodRecord<z.ZodString, z.ZodObject<{ status: z.ZodEnum<["closed", "open", "half_open"]>; consecutiveFailures: z.ZodNumber; halfOpenAttempts: z.ZodNumber; openedAt: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { status: "closed" | "open" | "half_open"; consecutiveFailures: number; halfOpenAttempts: number; openedAt?: string | undefined; }, { status: "closed" | "open" | "half_open"; consecutiveFailures: number; halfOpenAttempts: number; openedAt?: string | undefined; }>>; lastAnomalyId: z.ZodOptional<z.ZodString>; lastAction: z.ZodOptional<z.ZodEnum<["retry", "reconcile", "fallback", "degrade", "wait", "compensate", "human_review", "quarantine", "fail", "cancel"]>>; }, "strip", z.ZodTypeAny, { startedAt: string; updatedAt: string; totalAttempts: number; attemptsByState: Record<string, number>; circuits: Record<string, { status: "closed" | "open" | "half_open"; consecutiveFailures: number; halfOpenAttempts: number; openedAt?: string | undefined; }>; lastAnomalyId?: string | undefined; lastAction?: "retry" | "reconcile" | "fallback" | "degrade" | "wait" | "compensate" | "human_review" | "quarantine" | "fail" | "cancel" | undefined; }, { startedAt: string; updatedAt: string; totalAttempts: number; attemptsByState: Record<string, number>; circuits: Record<string, { status: "closed" | "open" | "half_open"; consecutiveFailures: number; halfOpenAttempts: number; openedAt?: string | undefined; }>; lastAnomalyId?: string | undefined; lastAction?: "retry" | "reconcile" | "fallback" | "degrade" | "wait" | "compensate" | "human_review" | "quarantine" | "fail" | "cancel" | undefined; }>;

classifyFSMAnomaly

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

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

Declaration

text
export declare function classifyFSMAnomaly(error: unknown, input: FSMAnomalyClassificationInput): FSMAnomaly;

Call signature

text
classifyFSMAnomaly(error: unknown, input: FSMAnomalyClassificationInput): FSMAnomaly

Parameters

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

Returns

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

computeFSMRecoveryDelay

Compute FSM Recovery Delay function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function computeFSMRecoveryDelay(policy: FSMRecoveryBackoffPolicy, attempt: number, seed: string): number;

Call signature

text
computeFSMRecoveryDelay(policy: FSMRecoveryBackoffPolicy, attempt: number, seed: string): number

Parameters

ParameterTypeRequiredDescription
policyFSMRecoveryBackoffPolicyYesRequired parameter; accepted values are defined by the type column.
attemptnumberYesRequired parameter; accepted values are defined by the type column.
seedstringYesRequired parameter; accepted values are defined by the type column.

Returns

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

createInitialFSMRecoverySnapshot

Create Initial FSM Recovery Snapshot function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function createInitialFSMRecoverySnapshot(now?: string): FSMRecoverySnapshot;

Call signature

text
createInitialFSMRecoverySnapshot(now?: string): FSMRecoverySnapshot

Parameters

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

Returns

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

planFSMRecovery

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

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

Declaration

text
export declare function planFSMRecovery(input: {
    anomaly: FSMAnomaly;
    stateId: string;
    policy?: FSMRecoveryPolicySpec;
    snapshot?: FSMRecoverySnapshot;
    now?: string;
}): FSMRecoveryPlan;

Call signature

text
planFSMRecovery(input: { anomaly: FSMAnomaly; stateId: string; policy?: FSMRecoveryPolicySpec; snapshot?: FSMRecoverySnapshot; now?: string; }): FSMRecoveryPlan

Parameters

ParameterTypeRequiredDescription
input{ anomaly: FSMAnomaly; stateId: string; policy?: FSMRecoveryPolicySpec; snapshot?: FSMRecoverySnapshot; now?: string; }YesRequired parameter; accepted values are defined by the type column.

Returns

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

registerFSMRecoverySuccess

Register FSM Recovery Success function with 1 public call signature; parameters and return types are listed below.

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

Declaration

text
export declare function registerFSMRecoverySuccess(snapshot: FSMRecoverySnapshot, circuitKey: string, now?: string): FSMRecoverySnapshot;

Call signature

text
registerFSMRecoverySuccess(snapshot: FSMRecoverySnapshot, circuitKey: string, now?: string): FSMRecoverySnapshot

Parameters

ParameterTypeRequiredDescription
snapshotFSMRecoverySnapshotYesRequired parameter; accepted values are defined by the type column.
circuitKeystringYesRequired parameter; accepted values are defined by the type column.
nowstringNoOptional parameter; accepted values are defined by the type column.

Returns

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

FSMAnomaly

FSM Anomaly interface with 15 public fields or methods.

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

Declaration

text
export interface FSMAnomaly {
    id: string;
    source: FSMAnomalySource;
    category: FSMAnomalyCategory;
    code: string;
    message: string;
    occurredAt: string;
    retryable?: boolean;
    retryAfterMs?: number;
    circuitKey?: string;
    sideEffectState?: FSMSideEffectState;
    compensationAvailable?: boolean;
    reconciliationAvailable?: boolean;
    fallbackAvailable?: boolean;
    degradationAvailable?: boolean;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
categorypropertycategory: "unknown" | "cancellation" | "timeout" | "validation" | "policy_denied" | "authentication" | "authorization" | "rate_limit" | "transient_dependency" | "permanent_dependency" | "concurrency_conflict" | "resource_exhausted" | "tool_failure" | "inference_failure" | "memory_failure" | "execution_failure" | "storage_failure" | "message_failure" | "cache_failure" | "invariant_violation"Public property; its type, readonly modifier and optionality are shown in the signature.
circuitKeypropertycircuitKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
codepropertycode: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
compensationAvailablepropertycompensationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
degradationAvailablepropertydegradationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
fallbackAvailablepropertyfallbackAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
messagepropertymessage: 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.
reconciliationAvailablepropertyreconciliationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
retryablepropertyretryable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
retryAfterMspropertyretryAfterMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sideEffectStatepropertysideEffectState?: RecoverySideEffectStatePublic 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.

FSMAnomalyClassificationInput

FSM Anomaly Classification Input interface with 12 public fields or methods.

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

Declaration

text
export interface FSMAnomalyClassificationInput {
    id: string;
    source?: FSMAnomalySource;
    occurredAt?: string;
    sideEffectState?: FSMSideEffectState;
    compensationAvailable?: boolean;
    reconciliationAvailable?: boolean;
    fallbackAvailable?: boolean;
    degradationAvailable?: boolean;
    retryable?: boolean;
    retryAfterMs?: number;
    circuitKey?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
circuitKeypropertycircuitKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
compensationAvailablepropertycompensationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
degradationAvailablepropertydegradationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
fallbackAvailablepropertyfallbackAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
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.
reconciliationAvailablepropertyreconciliationAvailable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
retryablepropertyretryable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
retryAfterMspropertyretryAfterMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sideEffectStatepropertysideEffectState?: RecoverySideEffectStatePublic 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.

FSMCircuitBreakerPolicy

FSM Circuit Breaker Policy interface with 3 public fields or methods.

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

Declaration

text
export interface FSMCircuitBreakerPolicy {
    failureThreshold: number;
    resetTimeoutMs: number;
    halfOpenMaxAttempts: number;
}

Contract members

MemberKindSignatureDescription
failureThresholdpropertyfailureThreshold: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
halfOpenMaxAttemptspropertyhalfOpenMaxAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
resetTimeoutMspropertyresetTimeoutMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMCircuitSnapshot

FSM Circuit Snapshot interface with 4 public fields or methods.

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

Declaration

text
export interface FSMCircuitSnapshot {
    status: FSMCircuitStatus;
    consecutiveFailures: number;
    halfOpenAttempts: number;
    openedAt?: string;
}

Contract members

MemberKindSignatureDescription
consecutiveFailurespropertyconsecutiveFailures: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
halfOpenAttemptspropertyhalfOpenAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
openedAtpropertyopenedAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: FSMCircuitStatusPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryBackoffPolicy

FSM Recovery Backoff Policy interface with 4 public fields or methods.

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

Declaration

text
export interface FSMRecoveryBackoffPolicy {
    initialDelayMs: number;
    maxDelayMs: number;
    multiplier: number;
    jitterRatio: number;
}

Contract members

MemberKindSignatureDescription
initialDelayMspropertyinitialDelayMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
jitterRatiopropertyjitterRatio: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxDelayMspropertymaxDelayMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
multiplierpropertymultiplier: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryDecision

FSM Recovery Decision interface with 16 public fields or methods.

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

Declaration

text
export interface FSMRecoveryDecision {
    anomaly: FSMAnomaly;
    action: FSMRecoveryAction;
    fromState: string;
    transitionState: string;
    resumeState?: string;
    attempt: number;
    totalAttempts: number;
    delayMs: number;
    decidedAt: string;
    nextEligibleAt?: string;
    circuitKey: string;
    circuitStatus: FSMCircuitStatus;
    reason: string;
    quarantineState: string;
    afterCompensationAction?: Extract<FSMRecoveryAction, 'human_review' | 'quarantine' | 'fail'>;
    afterCompensationState?: string;
}

Contract members

MemberKindSignatureDescription
actionpropertyaction: "fail" | "retry" | "human_review" | "reconcile" | "fallback" | "degrade" | "compensate" | "wait" | "quarantine" | "cancel"Public property; its type, readonly modifier and optionality are shown in the signature.
afterCompensationActionpropertyafterCompensationAction?: "fail" | "human_review" | "quarantine"Public property; its type, readonly modifier and optionality are shown in the signature.
afterCompensationStatepropertyafterCompensationState?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
anomalypropertyanomaly: FSMAnomalyPublic property; its type, readonly modifier and optionality are shown in the signature.
attemptpropertyattempt: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
circuitKeypropertycircuitKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
circuitStatuspropertycircuitStatus: FSMCircuitStatusPublic property; its type, readonly modifier and optionality are shown in the signature.
decidedAtpropertydecidedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
delayMspropertydelayMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
fromStatepropertyfromState: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
nextEligibleAtpropertynextEligibleAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
quarantineStatepropertyquarantineState: stringPublic 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.
resumeStatepropertyresumeState?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
totalAttemptspropertytotalAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
transitionStatepropertytransitionState: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryPlan

FSM Recovery Plan interface with 2 public fields or methods.

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

Declaration

text
export interface FSMRecoveryPlan {
    decision: FSMRecoveryDecision;
    snapshot: FSMRecoverySnapshot;
}

Contract members

MemberKindSignatureDescription
decisionpropertydecision: FSMRecoveryDecisionPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotpropertysnapshot: FSMRecoverySnapshotPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryPolicySpec

FSM Recovery Policy Spec interface with 10 public fields or methods.

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

Declaration

text
export interface FSMRecoveryPolicySpec {
    maxAttemptsPerState: number;
    maxTotalAttempts: number;
    maxElapsedMs: number;
    retryableCategories: FSMAnomalyCategory[];
    nonRetryableCodes?: string[];
    backoff: FSMRecoveryBackoffPolicy;
    circuitBreaker: FSMCircuitBreakerPolicy;
    stateTargets: FSMRecoveryStateTargets;
    onExhausted: Extract<FSMRecoveryAction, 'human_review' | 'quarantine' | 'fail'>;
    afterCompensation: Extract<FSMRecoveryAction, 'human_review' | 'quarantine' | 'fail'>;
}

Contract members

MemberKindSignatureDescription
afterCompensationpropertyafterCompensation: "fail" | "human_review" | "quarantine"Public property; its type, readonly modifier and optionality are shown in the signature.
backoffpropertybackoff: FSMRecoveryBackoffPolicyPublic property; its type, readonly modifier and optionality are shown in the signature.
circuitBreakerpropertycircuitBreaker: FSMCircuitBreakerPolicyPublic property; its type, readonly modifier and optionality are shown in the signature.
maxAttemptsPerStatepropertymaxAttemptsPerState: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxElapsedMspropertymaxElapsedMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxTotalAttemptspropertymaxTotalAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
nonRetryableCodespropertynonRetryableCodes?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
onExhaustedpropertyonExhausted: "fail" | "human_review" | "quarantine"Public property; its type, readonly modifier and optionality are shown in the signature.
retryableCategoriespropertyretryableCategories: ("unknown" | "cancellation" | "timeout" | "validation" | "policy_denied" | "authentication" | "authorization" | "rate_limit" | "transient_dependency" | "permanent_dependency" | "concurrency_conflict" | "resource_exhausted" | "tool_failure" | "inference_failure" | "memory_failure" | "execution_failure" | "storage_failure" | "message_failure" | "cache_failure" | "invariant_violation")[]Public property; its type, readonly modifier and optionality are shown in the signature.
stateTargetspropertystateTargets: FSMRecoveryStateTargetsPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoverySnapshot

FSM Recovery Snapshot interface with 7 public fields or methods.

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

Declaration

text
export interface FSMRecoverySnapshot {
    startedAt: string;
    updatedAt: string;
    totalAttempts: number;
    attemptsByState: Record<string, number>;
    circuits: Record<string, FSMCircuitSnapshot>;
    lastAnomalyId?: string;
    lastAction?: FSMRecoveryAction;
}

Contract members

MemberKindSignatureDescription
attemptsByStatepropertyattemptsByState: Record<string, number>Public property; its type, readonly modifier and optionality are shown in the signature.
circuitspropertycircuits: Record<string, FSMCircuitSnapshot>Public property; its type, readonly modifier and optionality are shown in the signature.
lastActionpropertylastAction?: "fail" | "retry" | "human_review" | "reconcile" | "fallback" | "degrade" | "compensate" | "wait" | "quarantine" | "cancel"Public property; its type, readonly modifier and optionality are shown in the signature.
lastAnomalyIdpropertylastAnomalyId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
startedAtpropertystartedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
totalAttemptspropertytotalAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
updatedAtpropertyupdatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMRecoveryStateTargets

FSM Recovery State Targets interface with 6 public fields or methods.

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

Declaration

text
export interface FSMRecoveryStateTargets {
    recovering: string;
    compensating: string;
    humanReview: string;
    quarantined: string;
    failed: string;
    cancelled: string;
}

Contract members

MemberKindSignatureDescription
cancelledpropertycancelled: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
compensatingpropertycompensating: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
failedpropertyfailed: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
humanReviewpropertyhumanReview: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
quarantinedpropertyquarantined: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
recoveringpropertyrecovering: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

FSMAnomalyCategory

Public type alias for FSM Anomaly Category; the declaration contains its complete type expression.

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

Declaration

text
export type FSMAnomalyCategory = RecoveryCategory;

FSMAnomalySource

Public type alias for FSM Anomaly Source; the declaration contains its complete type expression.

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

Declaration

text
export type FSMAnomalySource = RecoveryModule;

FSMCircuitStatus

Public type alias for FSM Circuit Status; the declaration contains its complete type expression.

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

Declaration

text
export type FSMCircuitStatus = 'closed' | 'open' | 'half_open';

FSMRecoveryAction

Public type alias for FSM Recovery Action; the declaration contains its complete type expression.

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

Declaration

text
export type FSMRecoveryAction = (typeof FSM_RECOVERY_ACTIONS)[number];

FSMSideEffectState

Public type alias for FSM Side Effect State; the declaration contains its complete type expression.

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

Declaration

text
export type FSMSideEffectState = RecoverySideEffectState;