Skip to content

@codesoul-co/hypha-memory / lifecycle-workers

Using this module

Use the Lifecycle workers module for using the public contracts and operations for this capability boundary. It exports 8 classes, 5 interfaces, 2 types.

Import from the package entrypoint

ts
import {
  InMemoryMemoryLifecycleTaskStore,
  LeasedMemoryLifecycleWorker,
  MemoryConsolidationWorker,
  MemoryDecayWorker,
  MemoryDeletionWorker,
  MemoryReindexWorker,
  MemoryRetentionWorker,
  ProviderReconciliationWorker,
} from '@codesoul-co/hypha-memory';

import type {
  MemoryLifecycleTask,
  MemoryLifecycleTaskStore,
  MemoryLifecycleWorkerEvent,
  MemoryLifecycleWorkerOptions,
  MemoryLifecycleWorkerRunResult,
  MemoryLifecycleTaskHandler,
  MemoryLifecycleWorkerType,
} from '@codesoul-co/hypha-memory';

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 8 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
InMemoryMemoryLifecycleTaskStoreclassnew InMemoryMemoryLifecycleTaskStore(): InMemoryMemoryLifecycleTaskStoreIn Memory Memory Lifecycle Task Store class with 7 public constructor or member entries; its exact declarations are listed below.
LeasedMemoryLifecycleWorkerclassnew LeasedMemoryLifecycleWorker(options: MemoryLifecycleWorkerOptions): LeasedMemoryLifecycleWorkerLeased Memory Lifecycle Worker class with 6 public constructor or member entries; its exact declarations are listed below.
MemoryConsolidationWorkerclassnew MemoryConsolidationWorker(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryConsolidationWorkerMemory Consolidation Worker class with 6 public constructor or member entries; its exact declarations are listed below.
MemoryDecayWorkerclassnew MemoryDecayWorker(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryDecayWorkerMemory Decay Worker class with 6 public constructor or member entries; its exact declarations are listed below.
MemoryDeletionWorkerclassnew MemoryDeletionWorker(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryDeletionWorkerMemory Deletion Worker class with 6 public constructor or member entries; its exact declarations are listed below.
MemoryReindexWorkerclassnew MemoryReindexWorker(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryReindexWorkerMemory Reindex Worker class with 6 public constructor or member entries; its exact declarations are listed below.
MemoryRetentionWorkerclassnew MemoryRetentionWorker(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryRetentionWorkerMemory Retention Worker class with 6 public constructor or member entries; its exact declarations are listed below.
ProviderReconciliationWorkerclassnew ProviderReconciliationWorker(options: Omit<MemoryLifecycleWorkerOptions, "type">): ProviderReconciliationWorkerProvider Reconciliation Worker class with 6 public constructor or member entries; its exact declarations are listed below.
MemoryLifecycleTaskinterfaceinterface MemoryLifecycleTaskMemory Lifecycle Task interface with 15 public fields or methods.
MemoryLifecycleTaskStoreinterfaceinterface MemoryLifecycleTaskStoreMemory Lifecycle Task Store interface with 6 public fields or methods.
MemoryLifecycleWorkerEventinterfaceinterface MemoryLifecycleWorkerEventMemory Lifecycle Worker Event interface with 5 public fields or methods.
MemoryLifecycleWorkerOptionsinterfaceinterface MemoryLifecycleWorkerOptionsMemory Lifecycle Worker Options interface with 12 public fields or methods.
MemoryLifecycleWorkerRunResultinterfaceinterface MemoryLifecycleWorkerRunResultMemory Lifecycle Worker Run Result interface with 4 public fields or methods.
MemoryLifecycleTaskHandlertypetype MemoryLifecycleTaskHandler = (task: MemoryLifecycleTask, signal: AbortSignal) => Promise<void>Public type alias for Memory Lifecycle Task Handler; the declaration contains its complete type expression.
MemoryLifecycleWorkerTypetypetype MemoryLifecycleWorkerType = 'retention' | 'decay' | 'consolidation' | 'deletion' | 'reindex' | 'provider_reconciliation'Public type alias for Memory Lifecycle Worker Type; the declaration contains its complete type expression.

InMemoryMemoryLifecycleTaskStore

In Memory Memory Lifecycle Task Store class with 7 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryMemoryLifecycleTaskStore } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class InMemoryMemoryLifecycleTaskStore implements MemoryLifecycleTaskStore {
    enqueue(task: MemoryLifecycleTask): Promise<void>;
    lease(type: MemoryLifecycleWorkerType, ownerId: string, now: string, leaseUntil: string, limit: number): Promise<MemoryLifecycleTask[]>;
    renew(taskId: string, ownerId: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>;
    complete(taskId: string, ownerId: string, leaseToken: string, now: string): Promise<boolean>;
    fail(taskId: string, ownerId: string, leaseToken: string, now: string, error: NormalizedMemoryError, retryAt: string, deadLetter: boolean): Promise<boolean>;
    list(type?: MemoryLifecycleWorkerType): Promise<MemoryLifecycleTask[]>;
}

Public members

MemberKindSignatureDescription
completemethodcomplete(taskId: string, ownerId: string, leaseToken: string, now: string): Promise<boolean>Public method; parameters and return type are shown in the signature.
constructorconstructor(): InMemoryMemoryLifecycleTaskStoreCreates an instance of this class.
enqueuemethodenqueue(task: MemoryLifecycleTask): Promise<void>Public method; parameters and return type are shown in the signature.
failmethodfail(taskId: string, ownerId: string, leaseToken: string, now: string, error: NormalizedMemoryError, retryAt: string, deadLetter: boolean): Promise<boolean>Public method; parameters and return type are shown in the signature.
leasemethodlease(type: MemoryLifecycleWorkerType, ownerId: string, now: string, leaseUntil: string, limit: number): Promise<MemoryLifecycleTask[]>Public method; parameters and return type are shown in the signature.
listmethodlist(type?: MemoryLifecycleWorkerType): Promise<MemoryLifecycleTask[]>Public method; parameters and return type are shown in the signature.
renewmethodrenew(taskId: string, ownerId: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>Public method; parameters and return type are shown in the signature.

LeasedMemoryLifecycleWorker

Leased Memory Lifecycle Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { LeasedMemoryLifecycleWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class LeasedMemoryLifecycleWorker {
    constructor(options: MemoryLifecycleWorkerOptions);
    runOnce(): Promise<MemoryLifecycleWorkerRunResult>;
    start(): void;
    stop(): void;
    drain(): Promise<void>;
    stopAndDrain(): Promise<void>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: MemoryLifecycleWorkerOptions): LeasedMemoryLifecycleWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryConsolidationWorker

Memory Consolidation Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { MemoryConsolidationWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class MemoryConsolidationWorker extends LeasedMemoryLifecycleWorker {
    constructor(options: Omit<MemoryLifecycleWorkerOptions, 'type'>);
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryConsolidationWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryDecayWorker

Memory Decay Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { MemoryDecayWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class MemoryDecayWorker extends LeasedMemoryLifecycleWorker {
    constructor(options: Omit<MemoryLifecycleWorkerOptions, 'type'>);
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryDecayWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryDeletionWorker

Memory Deletion Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { MemoryDeletionWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class MemoryDeletionWorker extends LeasedMemoryLifecycleWorker {
    constructor(options: Omit<MemoryLifecycleWorkerOptions, 'type'>);
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryDeletionWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryReindexWorker

Memory Reindex Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { MemoryReindexWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class MemoryReindexWorker extends LeasedMemoryLifecycleWorker {
    constructor(options: Omit<MemoryLifecycleWorkerOptions, 'type'>);
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryReindexWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryRetentionWorker

Memory Retention Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { MemoryRetentionWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class MemoryRetentionWorker extends LeasedMemoryLifecycleWorker {
    constructor(options: Omit<MemoryLifecycleWorkerOptions, 'type'>);
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: Omit<MemoryLifecycleWorkerOptions, "type">): MemoryRetentionWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

ProviderReconciliationWorker

Provider Reconciliation Worker class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { ProviderReconciliationWorker } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export declare class ProviderReconciliationWorker extends LeasedMemoryLifecycleWorker {
    constructor(options: Omit<MemoryLifecycleWorkerOptions, 'type'>);
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: Omit<MemoryLifecycleWorkerOptions, "type">): ProviderReconciliationWorkerCreates an instance of this class.
drainmethoddrain(): Promise<void>Public method; parameters and return type are shown in the signature.
runOncemethodrunOnce(): Promise<MemoryLifecycleWorkerRunResult>Public method; parameters and return type are shown in the signature.
startmethodstart(): voidPublic method; parameters and return type are shown in the signature.
stopmethodstop(): voidPublic method; parameters and return type are shown in the signature.
stopAndDrainmethodstopAndDrain(): Promise<void>Public method; parameters and return type are shown in the signature.

MemoryLifecycleTask

Memory Lifecycle Task interface with 15 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryLifecycleTask } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export interface MemoryLifecycleTask<TPayload = unknown> {
    id: string;
    operationId: string;
    type: MemoryLifecycleWorkerType;
    scopeHash: string;
    payload: TPayload;
    state: 'pending' | 'processing' | 'completed' | 'failed' | 'dead_letter';
    attempts: number;
    availableAt: string;
    leaseOwner?: string;
    leaseToken?: string;
    leaseExpiresAt?: string;
    fencingToken?: number;
    lastError?: NormalizedMemoryError;
    createdAt: string;
    updatedAt: string;
}

Contract members

MemberKindSignatureDescription
attemptspropertyattempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
availableAtpropertyavailableAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
fencingTokenpropertyfencingToken?: numberPublic 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.
lastErrorpropertylastError?: NormalizedMemoryErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseExpiresAtpropertyleaseExpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseOwnerpropertyleaseOwner?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseTokenpropertyleaseToken?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
payloadpropertypayload: TPayloadPublic property; its type, readonly modifier and optionality are shown in the signature.
scopeHashpropertyscopeHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statepropertystate: "completed" | "failed" | "processing" | "pending" | "dead_letter"Public property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: MemoryLifecycleWorkerTypePublic 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.

MemoryLifecycleTaskStore

Memory Lifecycle Task Store interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryLifecycleTaskStore } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export interface MemoryLifecycleTaskStore {
    enqueue(task: MemoryLifecycleTask): Promise<void>;
    lease(type: MemoryLifecycleWorkerType, ownerId: string, now: string, leaseUntil: string, limit: number): Promise<MemoryLifecycleTask[]>;
    renew(taskId: string, ownerId: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>;
    complete(taskId: string, ownerId: string, leaseToken: string, now: string): Promise<boolean>;
    fail(taskId: string, ownerId: string, leaseToken: string, now: string, error: NormalizedMemoryError, retryAt: string, deadLetter: boolean): Promise<boolean>;
    list(type?: MemoryLifecycleWorkerType): Promise<MemoryLifecycleTask[]>;
}

Contract members

MemberKindSignatureDescription
completemethodcomplete(taskId: string, ownerId: string, leaseToken: string, now: string): Promise<boolean>Public method; parameters and return type are shown in the signature.
enqueuemethodenqueue(task: MemoryLifecycleTask): Promise<void>Public method; parameters and return type are shown in the signature.
failmethodfail(taskId: string, ownerId: string, leaseToken: string, now: string, error: NormalizedMemoryError, retryAt: string, deadLetter: boolean): Promise<boolean>Public method; parameters and return type are shown in the signature.
leasemethodlease(type: MemoryLifecycleWorkerType, ownerId: string, now: string, leaseUntil: string, limit: number): Promise<MemoryLifecycleTask[]>Public method; parameters and return type are shown in the signature.
listmethodlist(type?: MemoryLifecycleWorkerType): Promise<MemoryLifecycleTask[]>Public method; parameters and return type are shown in the signature.
renewmethodrenew(taskId: string, ownerId: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>Public method; parameters and return type are shown in the signature.

MemoryLifecycleWorkerEvent

Memory Lifecycle Worker Event interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryLifecycleWorkerEvent } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export interface MemoryLifecycleWorkerEvent {
    type: 'memory.worker.started' | 'memory.worker.stopped' | 'memory.worker.failed' | 'memory.worker.dead_lettered';
    workerType: MemoryLifecycleWorkerType;
    taskId?: string;
    operationId?: string;
    error?: NormalizedMemoryError;
}

Contract members

MemberKindSignatureDescription
errorpropertyerror?: NormalizedMemoryErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
taskIdpropertytaskId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: "memory.worker.started" | "memory.worker.stopped" | "memory.worker.failed" | "memory.worker.dead_lettered"Public property; its type, readonly modifier and optionality are shown in the signature.
workerTypepropertyworkerType: MemoryLifecycleWorkerTypePublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryLifecycleWorkerOptions

Memory Lifecycle Worker Options interface with 12 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryLifecycleWorkerOptions } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export interface MemoryLifecycleWorkerOptions {
    type: MemoryLifecycleWorkerType;
    ownerId: string;
    store: MemoryLifecycleTaskStore;
    handler: MemoryLifecycleTaskHandler;
    batchSize?: number;
    leaseMs?: number;
    renewalMs?: number;
    retryDelayMs?: number;
    maxAttempts?: number;
    pollIntervalMs?: number;
    now?: () => Date;
    onEvent?: (event: MemoryLifecycleWorkerEvent) => void | Promise<void>;
}

Contract members

MemberKindSignatureDescription
batchSizepropertybatchSize?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
handlermethodhandler(task: MemoryLifecycleTask, signal: AbortSignal): Promise<void>Public method; parameters and return type are shown in the signature.
leaseMspropertyleaseMs?: numberPublic 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.
nowmethodnow?(): DatePublic method; parameters and return type are shown in the signature.
onEventmethodonEvent?(event: MemoryLifecycleWorkerEvent): void | Promise<void>Public method; parameters and return type are shown in the signature.
ownerIdpropertyownerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
pollIntervalMspropertypollIntervalMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
renewalMspropertyrenewalMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
retryDelayMspropertyretryDelayMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
storepropertystore: MemoryLifecycleTaskStorePublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: MemoryLifecycleWorkerTypePublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryLifecycleWorkerRunResult

Memory Lifecycle Worker Run Result interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryLifecycleWorkerRunResult } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export interface MemoryLifecycleWorkerRunResult {
    leased: number;
    completed: number;
    failed: number;
    deadLettered: number;
}

Contract members

MemberKindSignatureDescription
completedpropertycompleted: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
deadLetteredpropertydeadLettered: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
failedpropertyfailed: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
leasedpropertyleased: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryLifecycleTaskHandler

Public type alias for Memory Lifecycle Task Handler; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MemoryLifecycleTaskHandler } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export type MemoryLifecycleTaskHandler = (task: MemoryLifecycleTask, signal: AbortSignal) => Promise<void>;

MemoryLifecycleWorkerType

Public type alias for Memory Lifecycle Worker Type; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MemoryLifecycleWorkerType } from '@codesoul-co/hypha-memory';
  • Source module: lifecycle-workers

Declaration

text
export type MemoryLifecycleWorkerType = 'retention' | 'decay' | 'consolidation' | 'deletion' | 'reindex' | 'provider_reconciliation';