socraticode
Version:
SocratiCode — MCP server for local codebase indexing, semantic search, and code dependency graphs. All private, all local via Docker.
97 lines • 6.63 kB
TypeScript
import type { SymbolGraphFilePayload, SymbolGraphMeta, SymbolRef } from "../types.js";
/** Map a symbol name to its name-index shard key (`a`–`z` or `_`). */
export declare function nameShardKey(name: string): string;
/** All 27 possible name-index shard keys (in stable order). */
export declare function allNameShardKeys(): string[];
/** Map a file path to its reverse-call shard bucket (0..SYMBOL_REVERSE_SHARDS-1). */
export declare function reverseShardKey(filePath: string): number;
/** Map a callee symbol ID (e.g. `path/to/file.ts::symbolName`) to its reverse-call shard bucket. */
export declare function reverseShardKeyForCallee(calleeId: string): number;
/** Format a reverse-shard bucket as a 2-char zero-padded hex string. */
export declare function reverseShardHex(bucket: number): string;
declare function metaPointId(projectId: string): string;
declare function filePointId(projectId: string, relativePath: string, generation?: string): string;
declare function nameShardPointId(projectId: string, shardKey: string, generation?: string): string;
declare function revShardPointId(projectId: string, bucketHex: string, generation?: string): string;
/**
* A single point that cannot be written at all because it alone exceeds the
* server's request ceiling. Thrown rather than skipped: dropping it would leave
* the symbol graph silently missing a file's symbols, which is the failure mode
* this whole area exists to avoid. The message names the offending item and the
* knob that raises the ceiling.
*/
export declare class SymbolGraphPointTooLargeError extends Error {
readonly what: string;
readonly bytes: number;
readonly limit: number;
constructor(what: string, bytes: number, limit?: number);
}
export declare class StorageReadError extends Error {
readonly context?: Record<string, unknown> | undefined;
constructor(message: string, context?: Record<string, unknown> | undefined);
}
/** Raised when a query tries to start against a superseded graph generation. */
export declare class SymbolGraphGenerationChangedError extends StorageReadError {
readonly projectId: string;
readonly generation: string;
readonly activeGeneration?: string | undefined;
constructor(projectId: string, generation: string, activeGeneration?: string | undefined);
}
/** Internal lease/storage key for graphs written before generations existed. */
export declare const LEGACY_SYMBOL_GRAPH_GENERATION = "__legacy_symbol_graph__";
/** Reset readiness cache (testing only). */
export declare function resetSymbolGraphCollectionCache(): void;
/** Ensure all three symbol-graph collections exist for a project. */
export declare function ensureSymbolGraphCollections(projectId: string): Promise<void>;
export declare function saveSymbolGraphMeta(projectId: string, meta: SymbolGraphMeta): Promise<void>;
export declare function loadSymbolGraphMeta(projectId: string): Promise<SymbolGraphMeta | null>;
export declare function saveFilePayload(projectId: string, payload: SymbolGraphFilePayload, generation?: string): Promise<void>;
/**
* Bulk upsert per-file payloads, in requests bounded by size as well as count.
*
* Point ids and payload shape are unchanged, so this writes exactly the same
* data as before; only how it is split across HTTP requests differs.
*/
export declare function saveFilePayloads(projectId: string, payloads: SymbolGraphFilePayload[], generation?: string): Promise<void>;
export declare function loadFilePayload(projectId: string, relativePath: string, generation?: string): Promise<SymbolGraphFilePayload | null>;
export declare function deleteFilePayload(projectId: string, relativePath: string, generation?: string): Promise<void>;
export declare function saveNameShard(projectId: string, shardKey: string, nameToSymbols: Record<string, SymbolRef[]>, generation?: string): Promise<void>;
export declare function loadNameShard(projectId: string, shardKey: string, generation?: string): Promise<Record<string, SymbolRef[]> | null>;
export declare function saveReverseShard(projectId: string, bucket: number, reverseEdges: Record<string, string[]>, generation?: string): Promise<void>;
export declare function loadReverseShard(projectId: string, bucket: number, generation?: string): Promise<Record<string, string[]> | null>;
/** Record the generation named by the project's committed metadata pointer. */
export declare function setActiveSymbolGraphGeneration(projectId: string, generation?: string): void;
/**
* Coordinate staging, activation, and cleanup operations per project.
* Guarantees operations for the same projectId do not interleave concurrently.
*/
export declare function coordinateProject<T>(projectId: string, fn: () => Promise<T>): Promise<T>;
export declare function registerStagingGeneration(projectIdOrGen: string, gen?: string): void;
export declare function unregisterStagingGeneration(projectIdOrGen: string, gen?: string): void;
export declare function getStagingGenerations(projectId: string): string[];
export declare function retainReader(projectId: string, generation?: string, allowSupersededGeneration?: boolean): void;
export declare function releaseReader(projectId: string, generation?: string): void;
export declare function getActiveReaderGenerations(projectId: string): string[];
export declare function hasActiveReaders(projectId: string, generation: string): boolean;
export declare function resetGenerationLifecycleState(): void;
/** Delete all points belonging to a specific generation from file and index collections. */
export declare function deleteGeneration(projectId: string, generation: string): Promise<void>;
/** Find all distinct generation IDs present in storage for a project. */
export declare function listStoredGenerations(projectId: string): Promise<string[]>;
/**
* Remove points belonging to superseded or abandoned generations, keeping activeGeneration,
* generations currently in staging, and generations held by active readers.
*/
export declare function cleanStaleGenerations(projectId: string, activeGeneration: string): Promise<void>;
/** Delete all symbol-graph data for a project (best-effort). */
export declare function deleteSymbolGraphData(projectId: string): Promise<void>;
/** Compute SHA-256 of a string and return hex digest. Used for `contentHash`. */
export declare function contentHashOf(source: string): string;
export declare const _internal: {
metaPointId: typeof metaPointId;
filePointId: typeof filePointId;
nameShardPointId: typeof nameShardPointId;
revShardPointId: typeof revShardPointId;
};
export {};
//# sourceMappingURL=symbol-graph-store.d.ts.map