v2-refactor-temp/docs/knowledge/knowledge-schema.md
This document records the current V2 knowledge target schema, migration constraints, and temporary scope boundaries.
video items are out of scope for V2 knowledge data migration and should be skipped.memory items belong to the memory module, not the knowledge module, and should be skipped in knowledge migration.knowledge_baseidnamegroupIddimensionsembeddingModelIdstatuserrorrerankModelIdfileProcessorIdchunkSizechunkOverlapthresholddocumentCountcreatedAtupdatedAtknowledge_itemidbaseIdgroupIdtypedatastatuserrorcreatedAtupdatedAtid.video is not a target knowledge_item.type.memory is not a target knowledge_item.type.sitemap is not a target knowledge_item.type; legacy sitemap entries are migrated as url items.uniqueIduniqueIdsprocessingProgressretryCountisPreprocessedremark is not part of the V2 SQLite schema.sourceUrl is not a standalone knowledge_item column:
data.sourceUrldata payloadgroupId.groupId Semanticsknowledge_item is modeled as a flat same-base item collection.groupId is an optional stable grouping key inside one knowledge base.
groupId = containerItem.id(baseId, groupId) must reference (baseId, id) in knowledge_itemGET /knowledge-bases/:id/items for flat item listingtype, groupIdKnowledgeService IPC, not DataApi endpoints:
groupId = nulltype / data Integrity Boundaryknowledge_item.type and knowledge_item.data are intended to stay aligned by controlled UI flows.data against the stored type on every write.type and data aligneddata against the stored type before persisting changestype + data pair as a trusted contract produced by the app's controlled write path.knowledge_group table.uniqueId-based status rule below.video or memory into V2 knowledge tables.dimensions Resolution Ruledimensions is treated as a required field for target V2 knowledge_base.dimensions as the source of truth.dimensions from the legacy vector database by inspecting:
vectors tabledimensions.processingStatus is treated as runtime state and is not used as the migration source of truth.knowledge_item.status from legacy uniqueId:
uniqueId -> completedidleknowledge_item.status and knowledge_item.error remain part of the official V2 business schema.p-queue based pipeline in KnowledgeRuntimeService.status set is:
idlepreparingprocessingreadingembeddingcompletedfaileddeletingpreparing while a directory root or nested directory is being expandedreading while a leaf item is reading source documentsembedding while a leaf item is embedding / writing vectorsprocessing while a container has active descendants but is not itself expandingcompleted after successful leaf indexing, or when a container has no active childrenfailed on runtime failure, interrupt cleanup failure, or shutdown interruptionfileProcessorId is persisted in base config, but it does not participate in runtime execution yet.status is business lifecycle and coarse runtime progresssrc/main/services/knowledge/runtime/KnowledgeRuntimeService.tsknowledge_item.type values:
file -> file reader by extensionurl -> fetch markdown through Jina Readernote -> inline note contentdirectory -> currently treated as a container placeholder and returns no documentssitemap is no longer a valid persisted V2 knowledge_item.type. Legacy v1 sitemap items are mapped to url during migration and indexed through the URL path.knowledge_item rows and enqueue index-leafdirectory payloads create root rows and enqueue prepare-rootprepare-root expands a directory owner inside the runtime queue, creates child rows, and enqueues concrete leaf children as index-leaf.directory items under another item. Nested directory rows may still be created internally by directory expansion to preserve filesystem hierarchy.knowledge_base.embeddingModelId in providerId::modelId format and only supports ollama as the active provider.video and memory items are skipped during migration.groupId, but migration from official v1 data still writes it as null.groupId = ownerItem.id; there is no standalone group table in the current phase.dimensions resolution failure skips the entire base and all nested items, with warnings recorded in migration output.uniqueId instead of processingStatus.KnowledgeRuntimeService, not the old KnowledgeService name used in earlier notes.PQueue({ concurrency: 5 }) shared across knowledge bases; there is no per-base serial queue yet.prepare-root and index-leaf; preparation and leaf indexing share interrupt / wait / shutdown cleanup semantics.