import type { KnowledgeChunkKind } from './types.js'; import type { EmbeddingProfileV1, KnowledgeChunk as CompiledKnowledgeChunk, KnowledgeCoverageGap, KnowledgeAnalysisManifest, KnowledgeSourceCatalogEntry, KnowledgeSourceSchema, NormalizedKnowledgePage, ProjectKnowledgeProfile } from '@devflow-tools/sdk'; import type { KnowledgeClaimV1, KnowledgeSourceAggregateV1, KnowledgeSourceTransitionV1 } from './knowledge-source-lifecycle.js'; export interface KnowledgeDocInput { id: string; source: string; url: string; title?: string; version?: string; contentHash?: string; chunkPolicyVersion?: number; fetchedAt?: number; } export interface KnowledgeChunkInput { id: string; docId: string; index: number; headingPath: string; content: string; codeBlocks?: string; tokenCount?: number; kind?: KnowledgeChunkKind; framework?: string; apiIdentifiers?: string[]; sourceUrl?: string; contentHash?: string; } export interface KnowledgeChunkRow { id: string; doc_id: string; chunk_index: number; heading_path: string; content: string; code_blocks: string | null; token_count: number | null; source: string; url: string; version: string | null; document_title: string | null; chunk_policy_version: number; chunk_kind: KnowledgeChunkKind; framework: string | null; api_identifiers: string; source_url: string | null; content_hash: string; page_id: string | null; project_id: string; heading_breadcrumbs: string; embedding_text: string; original_start: number | null; original_end: number | null; entities: string; symbols: string; links: string; oversized_atomic: number; provenance: string; analysis_terms: string; } export interface KnowledgeIndexHealth { chunks: number; vectors: number; vectorCoverage: number; chunkTokens: { p50: number; p95: number; max: number; }; emptyTitleCount: number; } export declare class KnowledgeStore { private readonly embeddingProfile; private readonly projectId?; private db; constructor(dbPath: string, embeddingProfile?: EmbeddingProfileV1, projectId?: string | undefined); private repairLegacyPageReferences; /** Upgrade all project-scoped tables from the pre-project-identity schema. * The old column was a filesystem root; the canonical column is the stable * project id. Rebuilding the affected tables avoids leaving NOT NULL legacy * columns that would make every new canonical write fail. */ private migrateProjectScopedSchemas; private projectTableMigration; private assertCanonicalSchemaOrEmpty; private tableColumns; private hasTable; upsertDoc(doc: KnowledgeDocInput): void; clearChunks(docId: string): void; insertChunk(chunk: KnowledgeChunkInput): void; insertEmbedding(id: string, embedding: Float32Array): void; insertEmbeddingBatch(entries: Array<{ id: string; embedding: Float32Array; }>): void; replaceDocument(input: { doc: KnowledgeDocInput; chunks: KnowledgeChunkInput[]; embeddings: Float32Array[]; }): void; replaceDocumentChunks(input: { doc: KnowledgeDocInput; chunks: KnowledgeChunkInput[]; }): void; deactivateSourceDocuments(source: string, exceptDocumentId: string): number; deactivateDocument(documentId: string): boolean; private normalizeDocumentInput; searchBM25(query: string, limit?: number, sources?: string[]): Array<{ id: string; rank: number; }>; searchVector(embedding: Float32Array, limit?: number, sources?: string[]): Array<{ id: string; distance: number; }>; getEmbeddingProfileState(source?: string): { status: 'ready' | 'backfill_pending' | 'dimension_mismatch'; profileHash: string; generation: number; indexed: number; total: number; }; private putEmbeddingProfile; private deleteEmbeddingProfile; private assertEmbeddingProfile; getChunk(id: string): any; getDocChunks(source: string, limit?: number): any[]; listChunks(options?: { sources?: string[]; limit?: number; afterId?: string; }): KnowledgeChunkRow[]; listMissingEmbeddingChunks(options?: { source?: string; limit?: number; afterId?: string; }): KnowledgeChunkRow[]; countChunks(source?: string): number; countEmbeddings(source?: string): number; getCoverageBySource(): Array<{ source: string; chunks: number; vectors: number; }>; refreshSourceReadiness(expectedVersions?: Record, operationTimestamp?: number): void; getSourceReadiness(): Array<{ source: string; expected_version: string | null; documents: number; chunks: number; vectors: number; coverage: number; last_refresh: number | null; status: string; failure_category: string | null; updated_at: number; }>; getDistinctSources(): string[]; getIndexHealth(): KnowledgeIndexHealth; upsertProjectProfile(profile: ProjectKnowledgeProfile): boolean; getProjectProfile(projectId: string): ProjectKnowledgeProfile | null; upsertSourceSchema(schema: KnowledgeSourceSchema, now?: number): boolean; getSourceSchema(id: string): KnowledgeSourceSchema | null; listSourceSchemas(): KnowledgeSourceSchema[]; activateCatalogEntry(input: { projectId: string; profileHash: string; entry: KnowledgeSourceCatalogEntry; activatedAt?: number; }): { snapshotId: string; changed: boolean; }; listActiveCatalogEntries(projectId: string): KnowledgeSourceCatalogEntry[]; beginRefreshJob(input: { projectId: string; sourceId: string; inputContentHash: string; now?: number; }): { id: string; status: 'compiling' | 'completed'; resumed: boolean; }; completeRefreshJob(id: string, outputSnapshotId: string, now?: number): boolean; failRefreshJob(id: string, error: string, now?: number): boolean; getRefreshJob(id: string): { id: string; project_id: string; source_id: string; input_content_hash: string; previous_snapshot_id: string | null; output_snapshot_id: string | null; status: string; error: string | null; created_at: number; updated_at: number; } | null; recordCoverageGap(gap: KnowledgeCoverageGap): boolean; resolveCoverageGap(id: string, resolvedAt?: number): boolean; listCoverageGaps(projectId: string, options?: { includeResolved?: boolean; }): KnowledgeCoverageGap[]; upsertNormalizedPage(page: NormalizedKnowledgePage): boolean; replaceCompiledPage(page: NormalizedKnowledgePage, chunks: CompiledKnowledgeChunk[], operationTimestamp?: number): void; replaceKnowledgeAnalysisManifest(manifest: KnowledgeAnalysisManifest, quarantined: Array<{ kind: string; value: string; reason: string; }>, operationTimestamp?: number): void; recordImmutableRawSource(input: { projectId: string; sourceId: string; contentHash: string; sourceUri: string; sourceVersion?: string; metadata?: Record; retrievedAt: number; }): boolean; publishCompiledSource(input: { page: NormalizedKnowledgePage; chunks: CompiledKnowledgeChunk[]; manifest: KnowledgeAnalysisManifest; quarantined: Array<{ kind: string; value: string; reason: string; }>; operationTimestamp: number; }): void; getNormalizedPage(id: string): NormalizedKnowledgePage | null; transaction(operation: () => T): T; getSourceAggregate(identityHash: string): KnowledgeSourceAggregateV1 | null; appendSourceTransition(input: { aggregate: KnowledgeSourceAggregateV1; transition: KnowledgeSourceTransitionV1; }): { replayed: boolean; }; insertKnowledgeClaims(claims: KnowledgeClaimV1[]): number; listKnowledgeClaims(sourceId?: string): KnowledgeClaimV1[]; quarantineSourceRevision(input: { projectId: string; sourceId: string; pageId: string; contentHash: string; reason: string; expectedVersion?: string; updatedAt?: number; }): { pagesQuarantined: number; documentsDeactivated: number; catalogSnapshotsDeactivated: number; readinessSourcesDegraded: number; }; recordKnowledgeMaintenanceRun(input: { id: string; manifest: unknown; createdAt: number; }): void; rebuildFullTextIndex(): void; private replacePageLinks; close(): void; } //# sourceMappingURL=knowledge-store.d.ts.map