@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
49 lines (48 loc) • 3.39 kB
TypeScript
/**
* Conversation erasure write fence (`conversation-erasure-v1`).
*
* A writer that opts in is admitted once, at initialization, against a
* standalone Redis running `maxmemory-policy noeviction`. Each later write is
* one atomic script that refuses unless the server run id, the store epoch and
* the eviction counter still match what the writer was admitted under, and
* refuses a session whose erasure tombstone exists. A permanent erasure sets
* the tombstone, deletes the session's keys and index entry in the same script.
*
* Only participating writers are fenced. A writer that did not opt in keeps the
* ordinary storage behaviour (`legacy` mode) and cannot erase permanently.
*/
import type { ConversationErasureProtocol, ConversationErasureResult, ConversationErasureWriteContext, ConversationErasureWriterStatus, RedisClient, RedisStorageConfig } from "../types/index.js";
export { ConversationSessionErasedError, ConversationWriterEpochError, } from "../types/index.js";
export declare const ERASURE_FENCE_PROTOCOL: ConversationErasureProtocol;
/** Key of the per-session erasure tombstone. */
export declare const erasureFenceKey: (sessionKey: string) => string;
/**
* Resolve the write context once, before the manager admits asynchronous work
* (not at the later commit of a write).
*
* Without `strict` the writer does not participate and stays `legacy`. With
* `strict`, anything short of a standalone, non-evicting Redis whose epoch
* could be read and pinned throws {@link ConversationWriterEpochError}.
*/
export declare const prepareConversationWriteContext: (client: RedisClient, config: Required<RedisStorageConfig>, strict?: boolean) => Promise<ConversationErasureWriteContext>;
/** Write the session metadata blob (SET plus TTL). */
export declare const fencedSessionMetadataWrite: (client: RedisClient, config: Required<RedisStorageConfig>, sessionId: string, userId: string | undefined, payload: string, context: ConversationErasureWriteContext | undefined) => Promise<void>;
/** Add the session to the user's session index (SADD plus TTL). */
export declare const fencedSessionIndexWrite: (client: RedisClient, config: Required<RedisStorageConfig>, sessionId: string, userId: string, context: ConversationErasureWriteContext | undefined) => Promise<void>;
/**
* Write the message LIST and the metadata blob together. Resolves to 1 once
* the write landed; a refused write throws instead.
*/
export declare const fencedSessionPersist: (client: RedisClient, config: Required<RedisStorageConfig>, sessionId: string, userId: string | undefined, write: {
mode: "replace" | "append";
messages: string[];
payload: string;
}, context: ConversationErasureWriteContext | undefined) => Promise<number>;
/**
* Permanently erase one session: tombstone, data keys and index entry in one
* atomic step. Requires a strict, fenced writer and an explicit session and
* user id.
*/
export declare const eraseSessionPermanently: (client: RedisClient, config: Required<RedisStorageConfig>, sessionId: string, userId: string, context: ConversationErasureWriteContext | undefined) => Promise<ConversationErasureResult>;
/** Whether the writer that resolved `context` participates in the v1 fence. */
export declare const conversationErasureWriterStatus: (context: ConversationErasureWriteContext | undefined) => ConversationErasureWriterStatus;