Skip to content

@codesoul-co/hypha-memory / memory-server-migration-contract

Using this module

Use the Memory server migration contract module for declaring and runtime-validating contracts. It exports 1 constant, 1 function, 3 interfaces, 2 types.

Import from the package entrypoint

ts
import {
  memoryServerMigrationAcceptance,
  verifyRedisWorkingMemoryRetention,
} from '@codesoul-co/hypha-memory';

import type {
  MemoryServerMigrationAcceptance,
  MemoryServerMigrationSharedFixture,
  RedisWorkingMemoryRetentionCase,
  MemoryServerConsumer,
  MemoryServerMigrationIssue,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 5 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.
  • The 1 constant/enum export provides stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
memoryServerMigrationAcceptanceconstantconst memoryServerMigrationAcceptance: MemoryServerMigrationAcceptanceMemory Server Migration Acceptance constant exported by the memory-server-migration-contract module.
verifyRedisWorkingMemoryRetentionfunctionverifyRedisWorkingMemoryRetention(observedCounts: readonly number[], acceptance?: MemoryServerMigrationAcceptance): string[]Verify Redis Working Memory Retention function with 1 public call signature; parameters and return types are listed below.
MemoryServerMigrationAcceptanceinterfaceinterface MemoryServerMigrationAcceptanceFramework-owned handoff contract for the Server/dev composition migration. It contains no Server implementation and can be consumed by integration tests.
MemoryServerMigrationSharedFixtureinterfaceinterface MemoryServerMigrationSharedFixtureMemory Server Migration Shared Fixture interface with 5 public fields or methods.
RedisWorkingMemoryRetentionCaseinterfaceinterface RedisWorkingMemoryRetentionCaseRedis Working Memory Retention Case interface with 3 public fields or methods.
MemoryServerConsumertypetype MemoryServerConsumer = 'chat' | 'memory-routes' | 'tool' | 'workflow' | 'harness'Public type alias for Memory Server Consumer; the declaration contains its complete type expression.
MemoryServerMigrationIssuetypetype MemoryServerMigrationIssue = 'P0-1' | 'P0-2' | 'P0-3'Public type alias for Memory Server Migration Issue; the declaration contains its complete type expression.

memoryServerMigrationAcceptance

Memory Server Migration Acceptance constant exported by the memory-server-migration-contract module.

Declaration

text
export declare const memoryServerMigrationAcceptance: MemoryServerMigrationAcceptance;

verifyRedisWorkingMemoryRetention

Verify Redis Working Memory Retention function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function verifyRedisWorkingMemoryRetention(observedCounts: readonly number[], acceptance?: MemoryServerMigrationAcceptance): string[];

Call signature

text
verifyRedisWorkingMemoryRetention(observedCounts: readonly number[], acceptance?: MemoryServerMigrationAcceptance): string[]

Parameters

ParameterTypeRequiredDescription
observedCountsreadonly number[]YesRequired parameter; accepted values are defined by the type column.
acceptanceMemoryServerMigrationAcceptanceNoOptional parameter; accepted values are defined by the type column.

Returns

  • Type: string[]
  • Description: The return contract is defined by the type shown above.

MemoryServerMigrationAcceptance

Framework-owned handoff contract for the Server/dev composition migration. It contains no Server implementation and can be consumed by integration tests.

Declaration

text
export interface MemoryServerMigrationAcceptance {
    contractRef: MemoryContractSpecRef;
    issues: readonly ['P0-1', 'P0-2', 'P0-3'];
    canonicalService: '@codesoul-co/hypha-memory.MemoryApplicationService';
    requiredConsumers: readonly ['chat', 'memory-routes', 'tool', 'workflow', 'harness'];
    prohibitedRuntimeDependencies: readonly ['TemporaryMemory', 'PermanentMemory'];
    canonicalConsumption: {
        serviceRegistration: 'single';
        minimumProfileSwitchCases: 2;
        compositionReceiptRequired: true;
        allowedLegacyAdapterResponsibilities: readonly ['delegate', 'scope_mapping', 'error_mapping'];
        prohibitedLegacyAdapterResponsibilities: readonly [
            'business_rules',
            'provider_selection',
            'independent_persistence'
        ];
    };
    migration: {
        phases: readonly [
            'planned',
            'shadow_read',
            'bounded_dual_write',
            'verify',
            'cutover',
            'retire',
            'rollback'
        ];
        dualWriteRequirements: readonly ['deadlineAt', 'revision', 'idempotencyKey', 'checkpointRef'];
        requiredEventFields: readonly ['migrationRevision', 'activePath', 'shadowResult', 'reason'];
        retirementConditions: readonly [
            'legacyReadTraffic',
            'legacyWriteTraffic',
            'reconciliationPassed',
            'rollbackWindowClosed',
            'legacyImports',
            'legacyRegistrations'
        ];
    };
    sharedFixture: MemoryServerMigrationSharedFixture;
    redisWorkingMemory: {
        trimMode: 'MAXLEN';
        trimArgumentSemantics: 'target_max_length';
        trimPrecision: 'exact';
        maxZeroBehavior: 'clear';
        newestReadCommand: 'XREVRANGE';
        emptyLatestResult: 'null';
        cleanupCommand: 'SCAN';
        scanBudgetRequired: true;
        requiredBoundaryCases: readonly [
            'max_zero',
            'empty_to_one',
            'at_max',
            'max_plus_one',
            'large_batch',
            'concurrent',
            'scope_isolation',
            'restart_latest',
            'empty_latest',
            'scan_multi_page',
            'repeated_cursor'
        ];
        prohibitedCommands: readonly ['XTRIM MAXLEN with deletion count', 'XRANGE + -', 'KEYS'];
        retentionCases: readonly RedisWorkingMemoryRetentionCase[];
    };
    permanentMemory: {
        emptyResultCause: 'not_found_only';
        providerFailureResult: 'normalized_error';
        requiredFailureDisposition: 'retry_reconcile_quarantine_or_dlq';
        requiredOperations: readonly ['get', 'list', 'delete', 'write'];
        requiredFailureCases: readonly [
            'explicit_not_found',
            'network_timeout',
            'connection_unavailable',
            'authentication',
            'authorization',
            'write_conflict',
            'validation',
            'cursor_interrupted',
            'write_outcome_unknown',
            'retry_exhausted',
            'persistent_anomaly',
            'unknown_provider_error'
        ];
        requiredErrorContext: readonly [
            'operation',
            'providerRef',
            'profileRef',
            'scopeHash',
            'causeRef'
        ];
        recoveryDispositions: readonly ['retry', 'reconcile', 'quarantine', 'dlq'];
        prohibitedFailureResults: readonly ['null', 'empty_array', 'false', 'zero_stats', 'success'];
        safeDiagnosticsOnly: true;
        failureEventRequired: true;
    };
}

Contract members

MemberKindSignatureDescription
canonicalConsumptionpropertycanonicalConsumption: { serviceRegistration: "single"; minimumProfileSwitchCases: 2; compositionReceiptRequired: true; allowedLegacyAdapterResponsibilities: readonly ["delegate", "scope_mapping", "error_mapping"]; prohibitedLegacyAdapterResponsibilities: readonly ["business_rules", "provider_selection", "independent_persistence"]; }Public property; its type, readonly modifier and optionality are shown in the signature.
canonicalServicepropertycanonicalService: "@codesoul-co/hypha-memory.MemoryApplicationService"Public property; its type, readonly modifier and optionality are shown in the signature.
contractRefpropertycontractRef: MemoryContractSpecRefPublic property; its type, readonly modifier and optionality are shown in the signature.
issuespropertyissues: readonly ["P0-1", "P0-2", "P0-3"]Public property; its type, readonly modifier and optionality are shown in the signature.
migrationpropertymigration: { phases: readonly ["planned", "shadow_read", "bounded_dual_write", "verify", "cutover", "retire", "rollback"]; dualWriteRequirements: readonly ["deadlineAt", "revision", "idempotencyKey", "checkpointRef"]; requiredEventFields: readonly ["migrationRevision", "activePath", "shadowResult", "reason"]; retirementConditions: readonly ["legacyReadTraffic", "legacyWriteTraffic", "reconciliationPassed", "rollba...Public property; its type, readonly modifier and optionality are shown in the signature.
permanentMemorypropertypermanentMemory: { emptyResultCause: "not_found_only"; providerFailureResult: "normalized_error"; requiredFailureDisposition: "retry_reconcile_quarantine_or_dlq"; requiredOperations: readonly ["get", "list", "delete", "write"]; requiredFailureCases: readonly ["explicit_not_found", "network_timeout", "connection_unavailable", "authentication", "authorization", "write_conflict", "validation", "cursor_interrupted", "...Public property; its type, readonly modifier and optionality are shown in the signature.
prohibitedRuntimeDependenciespropertyprohibitedRuntimeDependencies: readonly ["TemporaryMemory", "PermanentMemory"]Public property; its type, readonly modifier and optionality are shown in the signature.
redisWorkingMemorypropertyredisWorkingMemory: { trimMode: "MAXLEN"; trimArgumentSemantics: "target_max_length"; trimPrecision: "exact"; maxZeroBehavior: "clear"; newestReadCommand: "XREVRANGE"; emptyLatestResult: "null"; cleanupCommand: "SCAN"; scanBudgetRequired: true; requiredBoundaryCases: readonly ["max_zero", "empty_to_one", "at_max", "max_plus_one", "large_batch", "concurrent", "scope_isolation", "restart_latest", "empty_latest", "sc...Public property; its type, readonly modifier and optionality are shown in the signature.
requiredConsumerspropertyrequiredConsumers: readonly ["chat", "memory-routes", "tool", "workflow", "harness"]Public property; its type, readonly modifier and optionality are shown in the signature.
sharedFixturepropertysharedFixture: MemoryServerMigrationSharedFixturePublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryServerMigrationSharedFixture

Memory Server Migration Shared Fixture interface with 5 public fields or methods.

Declaration

text
export interface MemoryServerMigrationSharedFixture {
    scope: ManagedMemoryScope;
    observedAt: string;
    canonicalServiceInstanceId: string;
    migration: {
        revision: string;
        phase: 'planned';
        deadlineAt: string;
    };
    failure: {
        operation: 'get';
        providerId: string;
        expectedError: NormalizedMemoryError;
    };
}

Contract members

MemberKindSignatureDescription
canonicalServiceInstanceIdpropertycanonicalServiceInstanceId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
failurepropertyfailure: { operation: "get"; providerId: string; expectedError: NormalizedMemoryError; }Public property; its type, readonly modifier and optionality are shown in the signature.
migrationpropertymigration: { revision: string; phase: "planned"; deadlineAt: string; }Public property; its type, readonly modifier and optionality are shown in the signature.
observedAtpropertyobservedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: ManagedMemoryScopePublic property; its type, readonly modifier and optionality are shown in the signature.

RedisWorkingMemoryRetentionCase

Redis Working Memory Retention Case interface with 3 public fields or methods.

Declaration

text
export interface RedisWorkingMemoryRetentionCase {
    beforeAppend: number;
    maxMessages: number;
    expectedAfterAppend: number;
}

Contract members

MemberKindSignatureDescription
beforeAppendpropertybeforeAppend: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedAfterAppendpropertyexpectedAfterAppend: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxMessagespropertymaxMessages: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryServerConsumer

Public type alias for Memory Server Consumer; the declaration contains its complete type expression.

Declaration

text
export type MemoryServerConsumer = 'chat' | 'memory-routes' | 'tool' | 'workflow' | 'harness';

MemoryServerMigrationIssue

Public type alias for Memory Server Migration Issue; the declaration contains its complete type expression.

Declaration

text
export type MemoryServerMigrationIssue = 'P0-1' | 'P0-2' | 'P0-3';