Skip to content

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

Using this module

Use the Recovery supervisor module for handling bounded recovery, retry, or degradation. It exports 1 function, 6 interfaces, 1 type.

Import from the package entrypoint

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

import type {
  RecoveryParticipant,
  RecoveryParticipantContext,
  RecoveryParticipantResult,
  RecoverySupervisorOptions,
  RecoverySupervisorResult,
  RecoverySupervisorScheduler,
  RecoveryParticipantAction,
} from '@codesoul-co/hypha-harness';

Usage patterns

  • Use the 7 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
runRecoverySupervisorfunctionrunRecoverySupervisor(options: RecoverySupervisorOptions): Promise<RecoverySupervisorResult>Runs a dependency-ordered, FSM-governed recovery workflow. A participant is retried only while its evidence changes or the bounded strategy budget has not been exhausted. Completed upstream participants are not repeated.
RecoveryParticipantinterfaceinterface RecoveryParticipantRecovery Participant interface with 9 public fields or methods.
RecoveryParticipantContextinterfaceinterface RecoveryParticipantContextRecovery Participant Context interface with 10 public fields or methods.
RecoveryParticipantResultinterfaceinterface RecoveryParticipantResultRecovery Participant Result interface with 3 public fields or methods.
RecoverySupervisorOptionsinterfaceinterface RecoverySupervisorOptionsRecovery Supervisor Options interface with 18 public fields or methods.
RecoverySupervisorResultinterfaceinterface RecoverySupervisorResultRecovery Supervisor Result interface with 5 public fields or methods.
RecoverySupervisorSchedulerinterfaceinterface RecoverySupervisorSchedulerRecovery Supervisor Scheduler interface with 1 public fields or methods.
RecoveryParticipantActiontypetype RecoveryParticipantAction = (context: RecoveryParticipantContext) => Promise<RecoveryParticipantResult<TOutput>>Public type alias for Recovery Participant Action; the declaration contains its complete type expression.

runRecoverySupervisor

Runs a dependency-ordered, FSM-governed recovery workflow. A participant is retried only while its evidence changes or the bounded strategy budget has not been exhausted. Completed upstream participants are not repeated.

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

Declaration

text
export declare function runRecoverySupervisor(options: RecoverySupervisorOptions): Promise<RecoverySupervisorResult>;

Call signature

text
runRecoverySupervisor(options: RecoverySupervisorOptions): Promise<RecoverySupervisorResult>

Runs a dependency-ordered, FSM-governed recovery workflow. A participant is retried only while its evidence changes or the bounded strategy budget has not been exhausted. Completed upstream participants are not repeated.

Parameters

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

Returns

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

RecoveryParticipant

Recovery Participant interface with 9 public fields or methods.

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

Declaration

text
export interface RecoveryParticipant<TOutput = unknown> {
    id: string;
    module: RecoveryModule;
    dependsOn?: string[];
    execute: RecoveryParticipantAction<TOutput>;
    classify(error: unknown, context: RecoveryParticipantContext): RecoveryFailure | Promise<RecoveryFailure>;
    reconcile?: RecoveryParticipantAction<TOutput>;
    fallback?: RecoveryParticipantAction<TOutput>;
    degrade?: RecoveryParticipantAction<TOutput>;
    compensate?: RecoveryParticipantAction<TOutput>;
}

Contract members

MemberKindSignatureDescription
classifymethodclassify(error: unknown, context: RecoveryParticipantContext): RecoveryFailure | Promise<RecoveryFailure>Public method; parameters and return type are shown in the signature.
compensatemethodcompensate?(context: RecoveryParticipantContext): Promise<RecoveryParticipantResult<TOutput>>Public method; parameters and return type are shown in the signature.
degrademethoddegrade?(context: RecoveryParticipantContext): Promise<RecoveryParticipantResult<TOutput>>Public method; parameters and return type are shown in the signature.
dependsOnpropertydependsOn?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
executemethodexecute(context: RecoveryParticipantContext): Promise<RecoveryParticipantResult<TOutput>>Public method; parameters and return type are shown in the signature.
fallbackmethodfallback?(context: RecoveryParticipantContext): Promise<RecoveryParticipantResult<TOutput>>Public method; parameters and return type are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
modulepropertymodule: "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.
reconcilemethodreconcile?(context: RecoveryParticipantContext): Promise<RecoveryParticipantResult<TOutput>>Public method; parameters and return type are shown in the signature.

RecoveryParticipantContext

Recovery Participant Context interface with 10 public fields or methods.

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

Declaration

text
export interface RecoveryParticipantContext {
    caseId: string;
    runId: string;
    scope: RecoveryKnowledgeScope;
    participantId: string;
    module: RecoveryModule;
    cycle: number;
    outputs: Readonly<Record<string, unknown>>;
    snapshot?: Readonly<RecoveryCaseSnapshot>;
    failure?: RecoveryFailure;
    signal?: AbortSignal;
}

Contract members

MemberKindSignatureDescription
caseIdpropertycaseId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
cyclepropertycycle: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
failurepropertyfailure?: RecoveryFailurePublic property; its type, readonly modifier and optionality are shown in the signature.
modulepropertymodule: "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.
outputspropertyoutputs: Readonly<Record<string, unknown>>Public property; its type, readonly modifier and optionality are shown in the signature.
participantIdpropertyparticipantId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: RecoveryKnowledgeScopePublic 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.
snapshotpropertysnapshot?: Readonly<RecoveryCaseSnapshot>Public property; its type, readonly modifier and optionality are shown in the signature.

RecoveryParticipantResult

Recovery Participant Result interface with 3 public fields or methods.

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

Declaration

text
export interface RecoveryParticipantResult<TOutput = unknown> {
    output: TOutput;
    evidence: RecoveryEvidence;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
evidencepropertyevidence: RecoveryEvidencePublic 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.
outputpropertyoutput: TOutputPublic property; its type, readonly modifier and optionality are shown in the signature.

RecoverySupervisorOptions

Recovery Supervisor Options interface with 18 public fields or methods.

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

Declaration

text
export interface RecoverySupervisorOptions {
    fsm: FSMRuntime;
    caseId: string;
    userId: string;
    tenantId?: string;
    participants: RecoveryParticipant[];
    policy?: Partial<RecoveryConvergencePolicy>;
    knowledge?: RecoveryKnowledgePort;
    trace?: TraceRecorder;
    sessionId?: string;
    workspaceId?: string;
    stepId?: string;
    agentId?: string;
    domainPackId?: string;
    scheduler?: RecoverySupervisorScheduler;
    maxInlineDelayMs?: number;
    signal?: AbortSignal;
    now?: () => string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
caseIdpropertycaseId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
domainPackIdpropertydomainPackId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
fsmpropertyfsm: FSMRuntimePublic property; its type, readonly modifier and optionality are shown in the signature.
knowledgepropertyknowledge?: RecoveryKnowledgePortPublic 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.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
participantspropertyparticipants: RecoveryParticipant<unknown>[]Public property; its type, readonly modifier and optionality are shown in the signature.
policypropertypolicy?: Partial<RecoveryConvergencePolicy>Public property; its type, readonly modifier and optionality are shown in the signature.
schedulerpropertyscheduler?: RecoverySupervisorSchedulerPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId?: stringPublic 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.
stepIdpropertystepId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tracepropertytrace?: TraceRecorderPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
workspaceIdpropertyworkspaceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RecoverySupervisorResult

Recovery Supervisor Result interface with 5 public fields or methods.

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

Declaration

text
export interface RecoverySupervisorResult {
    status: 'succeeded' | 'degraded' | 'compensated' | 'suspended' | 'quarantined' | 'failed' | 'cancelled';
    outputs: Record<string, unknown>;
    snapshot?: RecoveryCaseSnapshot;
    failure?: RecoveryFailure;
    error?: unknown;
}

Contract members

MemberKindSignatureDescription
errorpropertyerror?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
failurepropertyfailure?: RecoveryFailurePublic property; its type, readonly modifier and optionality are shown in the signature.
outputspropertyoutputs: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
snapshotpropertysnapshot?: RecoveryCaseSnapshotPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "degraded" | "cancelled" | "failed" | "quarantined" | "succeeded" | "suspended" | "compensated"Public property; its type, readonly modifier and optionality are shown in the signature.

RecoverySupervisorScheduler

Recovery Supervisor Scheduler interface with 1 public fields or methods.

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

Declaration

text
export interface RecoverySupervisorScheduler {
    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.

RecoveryParticipantAction

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

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

Declaration

text
export type RecoveryParticipantAction<TOutput = unknown> = (context: RecoveryParticipantContext) => Promise<RecoveryParticipantResult<TOutput>>;