Skip to content

@codesoul-co/hypha-memory / context-cache-validity

Using this module

Use the Context cache validity module for reading, writing, or coordinating cache state. It exports 2 classes, 1 function, 4 interfaces.

Import from the package entrypoint

ts
import {
  InMemoryContextEnvelopeCacheStore,
  VersionValidContextCache,
  createContextCacheValidityHash,
} from '@codesoul-co/hypha-memory';

import type {
  ContextCacheVersionSnapshot,
  ContextEnvelopeCacheStore,
  VersionValidContextCacheOptions,
  VersionValidContextCacheRecord,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 4 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.
  • The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
InMemoryContextEnvelopeCacheStoreclassnew InMemoryContextEnvelopeCacheStore(): InMemoryContextEnvelopeCacheStoreIn Memory Context Envelope Cache Store class with 5 public constructor or member entries; its exact declarations are listed below.
VersionValidContextCacheclassnew VersionValidContextCache(options: VersionValidContextCacheOptions): VersionValidContextCacheVersion Valid Context Cache class with 5 public constructor or member entries; its exact declarations are listed below.
createContextCacheValidityHashfunctioncreateContextCacheValidityHash(snapshot: ContextCacheVersionSnapshot): stringCreate Context Cache Validity Hash function with 1 public call signature; parameters and return types are listed below.
ContextCacheVersionSnapshotinterfaceinterface ContextCacheVersionSnapshotContext Cache Version Snapshot interface with 9 public fields or methods.
ContextEnvelopeCacheStoreinterfaceinterface ContextEnvelopeCacheStoreContext Envelope Cache Store interface with 4 public fields or methods.
VersionValidContextCacheOptionsinterfaceinterface VersionValidContextCacheOptionsVersion Valid Context Cache Options interface with 5 public fields or methods.
VersionValidContextCacheRecordinterfaceinterface VersionValidContextCacheRecordVersion Valid Context Cache Record interface with 7 public fields or methods.

InMemoryContextEnvelopeCacheStore

In Memory Context Envelope Cache Store class with 5 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryContextEnvelopeCacheStore } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export declare class InMemoryContextEnvelopeCacheStore implements ContextEnvelopeCacheStore {
    get(key: string): Promise<VersionValidContextCacheRecord | null>;
    set(key: string, value: VersionValidContextCacheRecord): Promise<void>;
    delete(key: string): Promise<void>;
    invalidateScope(scopeHash: string): Promise<number>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(): InMemoryContextEnvelopeCacheStoreCreates an instance of this class.
deletemethoddelete(key: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget(key: string): Promise<VersionValidContextCacheRecord | null>Public method; parameters and return type are shown in the signature.
invalidateScopemethodinvalidateScope(scopeHash: string): Promise<number>Public method; parameters and return type are shown in the signature.
setmethodset(key: string, value: VersionValidContextCacheRecord): Promise<void>Public method; parameters and return type are shown in the signature.

VersionValidContextCache

Version Valid Context Cache class with 5 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { VersionValidContextCache } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export declare class VersionValidContextCache implements MemoryProjectionInvalidationTarget {
    readonly id: string;
    constructor(options: VersionValidContextCacheOptions);
    invalidateScope(scopeHash: string): Promise<number>;
    get(key: string, current: ContextCacheVersionSnapshot): Promise<ContextEnvelope | null>;
    set(key: string, envelope: ContextEnvelope, snapshot: ContextCacheVersionSnapshot, expiresAt?: string): Promise<void>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: VersionValidContextCacheOptions): VersionValidContextCacheCreates an instance of this class.
getmethodget(key: string, current: ContextCacheVersionSnapshot): Promise<ContextEnvelope | null>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.
invalidateScopemethodinvalidateScope(scopeHash: string): Promise<number>Public method; parameters and return type are shown in the signature.
setmethodset(key: string, envelope: ContextEnvelope, snapshot: ContextCacheVersionSnapshot, expiresAt?: string): Promise<void>Public method; parameters and return type are shown in the signature.

createContextCacheValidityHash

Create Context Cache Validity Hash function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { createContextCacheValidityHash } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export declare function createContextCacheValidityHash(snapshot: ContextCacheVersionSnapshot): string;

Call signature

text
createContextCacheValidityHash(snapshot: ContextCacheVersionSnapshot): string

Parameters

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

Returns

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

ContextCacheVersionSnapshot

Context Cache Version Snapshot interface with 9 public fields or methods.

  • Kind: interface
  • Import: import type { ContextCacheVersionSnapshot } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export interface ContextCacheVersionSnapshot {
    contextProfileRevision: string;
    memoryProfileRevision: string;
    scopeHash: string;
    providerRevision?: string;
    policyRevision?: string;
    mutationGeneration: string;
    selectedMemoryVersionIds: string[];
    sourceHashes: Record<string, string>;
    artifactHashes?: Record<string, string>;
}

Contract members

MemberKindSignatureDescription
artifactHashespropertyartifactHashes?: Record<string, string>Public property; its type, readonly modifier and optionality are shown in the signature.
contextProfileRevisionpropertycontextProfileRevision: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
memoryProfileRevisionpropertymemoryProfileRevision: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
mutationGenerationpropertymutationGeneration: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
policyRevisionpropertypolicyRevision?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerRevisionpropertyproviderRevision?: stringPublic 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.
selectedMemoryVersionIdspropertyselectedMemoryVersionIds: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
sourceHashespropertysourceHashes: Record<string, string>Public property; its type, readonly modifier and optionality are shown in the signature.

ContextEnvelopeCacheStore

Context Envelope Cache Store interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { ContextEnvelopeCacheStore } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export interface ContextEnvelopeCacheStore {
    get(key: string): Promise<VersionValidContextCacheRecord | null>;
    set(key: string, value: VersionValidContextCacheRecord): Promise<void>;
    delete(key: string): Promise<void>;
    invalidateScope(scopeHash: string): Promise<number>;
}

Contract members

MemberKindSignatureDescription
deletemethoddelete(key: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget(key: string): Promise<VersionValidContextCacheRecord | null>Public method; parameters and return type are shown in the signature.
invalidateScopemethodinvalidateScope(scopeHash: string): Promise<number>Public method; parameters and return type are shown in the signature.
setmethodset(key: string, value: VersionValidContextCacheRecord): Promise<void>Public method; parameters and return type are shown in the signature.

VersionValidContextCacheOptions

Version Valid Context Cache Options interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { VersionValidContextCacheOptions } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export interface VersionValidContextCacheOptions {
    store: ContextEnvelopeCacheStore;
    now?: () => string;
    artifactStore?: ContextArtifactStore;
    projectionId?: string;
    generations?: MemoryMutationGenerationStore;
}

Contract members

MemberKindSignatureDescription
artifactStorepropertyartifactStore?: ContextArtifactStorePublic property; its type, readonly modifier and optionality are shown in the signature.
generationspropertygenerations?: MemoryMutationGenerationStorePublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
projectionIdpropertyprojectionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
storepropertystore: ContextEnvelopeCacheStorePublic property; its type, readonly modifier and optionality are shown in the signature.

VersionValidContextCacheRecord

Version Valid Context Cache Record interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { VersionValidContextCacheRecord } from '@codesoul-co/hypha-memory';
  • Source module: context-cache-validity

Declaration

text
export interface VersionValidContextCacheRecord {
    key: string;
    envelope: ContextEnvelope;
    snapshot: ContextCacheVersionSnapshot;
    validityHash: string;
    envelopeHash: string;
    createdAt: string;
    expiresAt?: string;
}

Contract members

MemberKindSignatureDescription
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
envelopepropertyenvelope: ContextEnvelopePublic property; its type, readonly modifier and optionality are shown in the signature.
envelopeHashpropertyenvelopeHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
keypropertykey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
snapshotpropertysnapshot: ContextCacheVersionSnapshotPublic property; its type, readonly modifier and optionality are shown in the signature.
validityHashpropertyvalidityHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.