Skip to content

@codesoul-co/hypha-memory / provider-observability

Using this module

Use the Provider observability module for binding external or local providers to Hypha ports. It exports 2 classes, 6 interfaces, 3 types.

Import from the package entrypoint

ts
import {
  MemoryProviderTelemetry,
  ObservedMemoryManagementProvider,
} from '@codesoul-co/hypha-memory';

import type {
  MemoryProviderMetricSample,
  MemoryProviderOperationalReport,
  MemoryProviderOperationEstimate,
  MemoryProviderTelemetryOptions,
  MemoryProviderTelemetryPolicy,
  ObservedMemoryManagementProviderOptions,
  MemoryProviderCostEstimator,
  MemoryProviderOperation,
} from '@codesoul-co/hypha-memory';

// The complete export list is documented below.

Usage patterns

  • Use the 9 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 2 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
MemoryProviderTelemetryclassnew MemoryProviderTelemetry(options: MemoryProviderTelemetryOptions): MemoryProviderTelemetryBounded, content-free Provider telemetry with quota admission and SLO evaluation. Samples retain only operation metadata; requests, responses, scopes and content are never stored.
ObservedMemoryManagementProviderclassnew ObservedMemoryManagementProvider(options: ObservedMemoryManagementProviderOptions): ObservedMemoryManagementProviderProvider decorator that instruments every canonical operation without changing Provider APIs.
MemoryProviderMetricSampleinterfaceinterface MemoryProviderMetricSampleMemory Provider Metric Sample interface with 8 public fields or methods.
MemoryProviderOperationalReportinterfaceinterface MemoryProviderOperationalReportMemory Provider Operational Report interface with 9 public fields or methods.
MemoryProviderOperationEstimateinterfaceinterface MemoryProviderOperationEstimateMemory Provider Operation Estimate interface with 2 public fields or methods.
MemoryProviderTelemetryOptionsinterfaceinterface MemoryProviderTelemetryOptionsMemory Provider Telemetry Options interface with 3 public fields or methods.
MemoryProviderTelemetryPolicyinterfaceinterface MemoryProviderTelemetryPolicyMemory Provider Telemetry Policy interface with 4 public fields or methods.
ObservedMemoryManagementProviderOptionsinterfaceinterface ObservedMemoryManagementProviderOptionsObserved Memory Management Provider Options interface with 3 public fields or methods.
MemoryProviderCostEstimatortypetype MemoryProviderCostEstimator = (operation: MemoryProviderOperation, request: unknown) => MemoryProviderOperationEstimatePublic type alias for Memory Provider Cost Estimator; the declaration contains its complete type expression.
MemoryProviderOperationtypetype MemoryProviderOperation = 'add' | 'search' | 'get' | 'list' | 'update' | 'delete' | 'history' | 'health'Public type alias for Memory Provider Operation; the declaration contains its complete type expression.
MemoryProviderOperationOutcometypetype MemoryProviderOperationOutcome = 'succeeded' | 'failed' | 'quota_rejected'Public type alias for Memory Provider Operation Outcome; the declaration contains its complete type expression.

MemoryProviderTelemetry

Bounded, content-free Provider telemetry with quota admission and SLO evaluation. Samples retain only operation metadata; requests, responses, scopes and content are never stored.

  • Kind: class
  • Import: import { MemoryProviderTelemetry } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export declare class MemoryProviderTelemetry {
    constructor(options: MemoryProviderTelemetryOptions);
    begin(providerId: string, operation: MemoryProviderOperation, estimate?: MemoryProviderOperationEstimate): Reservation;
    snapshot(providerId: string): MemoryProviderOperationalReport;
}

Public members

MemberKindSignatureDescription
beginmethodbegin(providerId: string, operation: MemoryProviderOperation, estimate?: MemoryProviderOperationEstimate): ReservationPublic method; parameters and return type are shown in the signature.
constructorconstructor(options: MemoryProviderTelemetryOptions): MemoryProviderTelemetryCreates an instance of this class.
snapshotmethodsnapshot(providerId: string): MemoryProviderOperationalReportPublic method; parameters and return type are shown in the signature.

ObservedMemoryManagementProvider

Provider decorator that instruments every canonical operation without changing Provider APIs.

  • Kind: class
  • Import: import { ObservedMemoryManagementProvider } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export declare class ObservedMemoryManagementProvider implements MemoryManagementProvider {
    readonly id: string;
    constructor(options: ObservedMemoryManagementProviderOptions);
    capabilities(): Promise<import("./contracts").MemoryManagementCapabilities>;
    add(request: MemoryAddRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>;
    search(request: ManagedMemorySearchRequest, signal?: AbortSignal): Promise<ManagedMemorySearchResult[]>;
    get(request: MemoryGetRequest, signal?: AbortSignal): Promise<import("./contracts").ManagedMemoryRecord<unknown> | null>;
    list(request: MemoryListRequest, signal?: AbortSignal): Promise<MemoryListResult>;
    update(request: ManagedMemoryUpdateRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>;
    delete(request: ManagedMemoryDeleteRequest, signal?: AbortSignal): Promise<ManagedMemoryDeleteResult>;
    history(request: MemoryHistoryRequest, signal?: AbortSignal): Promise<MemoryVersion[]>;
    health(): Promise<ProviderHealth>;
    close(): Promise<void>;
}

Public members

MemberKindSignatureDescription
addmethodadd(request: MemoryAddRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>Public method; parameters and return type are shown in the signature.
capabilitiesmethodcapabilities(): Promise<import("./contracts").MemoryManagementCapabilities>Public method; parameters and return type are shown in the signature.
closemethodclose(): Promise<void>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: ObservedMemoryManagementProviderOptions): ObservedMemoryManagementProviderCreates an instance of this class.
deletemethoddelete(request: ManagedMemoryDeleteRequest, signal?: AbortSignal): Promise<ManagedMemoryDeleteResult>Public method; parameters and return type are shown in the signature.
getmethodget(request: MemoryGetRequest, signal?: AbortSignal): Promise<import("./contracts").ManagedMemoryRecord<unknown> | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
historymethodhistory(request: MemoryHistoryRequest, signal?: AbortSignal): Promise<MemoryVersion[]>Public method; parameters and return type are shown in the signature.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
listmethodlist(request: MemoryListRequest, signal?: AbortSignal): Promise<MemoryListResult>Public method; parameters and return type are shown in the signature.
searchmethodsearch(request: ManagedMemorySearchRequest, signal?: AbortSignal): Promise<ManagedMemorySearchResult[]>Public method; parameters and return type are shown in the signature.
updatemethodupdate(request: ManagedMemoryUpdateRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>Public method; parameters and return type are shown in the signature.

MemoryProviderMetricSample

Memory Provider Metric Sample interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryProviderMetricSample } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export interface MemoryProviderMetricSample {
    providerId: string;
    operation: MemoryProviderOperation;
    outcome: MemoryProviderOperationOutcome;
    latencyMs: number;
    occurredAt: string;
    costUnits?: number;
    storedBytesDelta?: number;
    errorCode?: string;
}

Contract members

MemberKindSignatureDescription
costUnitspropertycostUnits?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
errorCodepropertyerrorCode?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
latencyMspropertylatencyMs: numberPublic 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.
operationpropertyoperation: MemoryProviderOperationPublic property; its type, readonly modifier and optionality are shown in the signature.
outcomepropertyoutcome: MemoryProviderOperationOutcomePublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
storedBytesDeltapropertystoredBytesDelta?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryProviderOperationalReport

Memory Provider Operational Report interface with 9 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryProviderOperationalReport } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export interface MemoryProviderOperationalReport {
    providerId: string;
    window: {
        startedAt: string;
        endedAt: string;
        durationMs: number;
    };
    operations: {
        total: number;
        succeeded: number;
        failed: number;
        quotaRejected: number;
        inFlight: number;
        byOperation: Partial<Record<MemoryProviderOperation, number>>;
    };
    availability: number | null;
    latencyMs: {
        p50: number | null;
        p95: number | null;
        p99: number | null;
        max: number | null;
    };
    cost: {
        measuredUnits: number;
        unpricedOperations: number;
        complete: boolean;
    };
    storage: {
        measuredBytes: number;
    };
    quota: {
        maxOperations?: number;
        remainingOperations?: number;
        maxCostUnits?: number;
        remainingCostUnits?: number;
        maxStoredBytes?: number;
        remainingStoredBytes?: number;
    };
    slo: {
        status: 'met' | 'breached' | 'insufficient_data';
        reasons: string[];
        minimumOperations: number;
        availabilityTarget?: number;
        latencyP95Ms?: number;
    };
}

Contract members

MemberKindSignatureDescription
availabilitypropertyavailability: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
costpropertycost: { measuredUnits: number; unpricedOperations: number; complete: boolean; }Public property; its type, readonly modifier and optionality are shown in the signature.
latencyMspropertylatencyMs: { p50: number | null; p95: number | null; p99: number | null; max: number | null; }Public property; its type, readonly modifier and optionality are shown in the signature.
operationspropertyoperations: { total: number; succeeded: number; failed: number; quotaRejected: number; inFlight: number; byOperation: Partial<Record<MemoryProviderOperation, number>>; }Public property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
quotapropertyquota: { maxOperations?: number; remainingOperations?: number; maxCostUnits?: number; remainingCostUnits?: number; maxStoredBytes?: number; remainingStoredBytes?: number; }Public property; its type, readonly modifier and optionality are shown in the signature.
slopropertyslo: { status: "met" | "breached" | "insufficient_data"; reasons: string[]; minimumOperations: number; availabilityTarget?: number; latencyP95Ms?: number; }Public property; its type, readonly modifier and optionality are shown in the signature.
storagepropertystorage: { measuredBytes: number; }Public property; its type, readonly modifier and optionality are shown in the signature.
windowpropertywindow: { startedAt: string; endedAt: string; durationMs: number; }Public property; its type, readonly modifier and optionality are shown in the signature.

MemoryProviderOperationEstimate

Memory Provider Operation Estimate interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryProviderOperationEstimate } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export interface MemoryProviderOperationEstimate {
    costUnits?: number;
    storedBytesDelta?: number;
}

Contract members

MemberKindSignatureDescription
costUnitspropertycostUnits?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
storedBytesDeltapropertystoredBytesDelta?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryProviderTelemetryOptions

Memory Provider Telemetry Options interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryProviderTelemetryOptions } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export interface MemoryProviderTelemetryOptions {
    defaultPolicy: MemoryProviderTelemetryPolicy;
    providerPolicies?: Record<string, MemoryProviderTelemetryPolicy>;
    now?: () => Date;
}

Contract members

MemberKindSignatureDescription
defaultPolicypropertydefaultPolicy: MemoryProviderTelemetryPolicyPublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): DatePublic method; parameters and return type are shown in the signature.
providerPoliciespropertyproviderPolicies?: Record<string, MemoryProviderTelemetryPolicy>Public property; its type, readonly modifier and optionality are shown in the signature.

MemoryProviderTelemetryPolicy

Memory Provider Telemetry Policy interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryProviderTelemetryPolicy } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export interface MemoryProviderTelemetryPolicy {
    windowMs: number;
    maxSamples?: number;
    quota?: {
        maxOperations?: number;
        maxCostUnits?: number;
        maxStoredBytes?: number;
    };
    slo?: {
        minimumOperations?: number;
        availabilityTarget?: number;
        latencyP95Ms?: number;
    };
}

Contract members

MemberKindSignatureDescription
maxSamplespropertymaxSamples?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
quotapropertyquota?: { maxOperations?: number; maxCostUnits?: number; maxStoredBytes?: number; }Public property; its type, readonly modifier and optionality are shown in the signature.
slopropertyslo?: { minimumOperations?: number; availabilityTarget?: number; latencyP95Ms?: number; }Public property; its type, readonly modifier and optionality are shown in the signature.
windowMspropertywindowMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

ObservedMemoryManagementProviderOptions

Observed Memory Management Provider Options interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ObservedMemoryManagementProviderOptions } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export interface ObservedMemoryManagementProviderOptions {
    provider: MemoryManagementProvider;
    telemetry: MemoryProviderTelemetry;
    estimate?: MemoryProviderCostEstimator;
}

Contract members

MemberKindSignatureDescription
estimatemethodestimate?(operation: MemoryProviderOperation, request: unknown): MemoryProviderOperationEstimatePublic method; parameters and return type are shown in the signature.
providerpropertyprovider: MemoryManagementProviderPublic property; its type, readonly modifier and optionality are shown in the signature.
telemetrypropertytelemetry: MemoryProviderTelemetryPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryProviderCostEstimator

Public type alias for Memory Provider Cost Estimator; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MemoryProviderCostEstimator } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export type MemoryProviderCostEstimator = (operation: MemoryProviderOperation, request: unknown) => MemoryProviderOperationEstimate;

MemoryProviderOperation

Public type alias for Memory Provider Operation; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MemoryProviderOperation } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export type MemoryProviderOperation = 'add' | 'search' | 'get' | 'list' | 'update' | 'delete' | 'history' | 'health';

MemoryProviderOperationOutcome

Public type alias for Memory Provider Operation Outcome; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MemoryProviderOperationOutcome } from '@codesoul-co/hypha-memory';
  • Source module: provider-observability

Declaration

text
export type MemoryProviderOperationOutcome = 'succeeded' | 'failed' | 'quota_rejected';