mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 18:30:09 +00:00
AddDocumentWithEmbedding upserted a file's _files row with the NEW hash on the first chunk stored (the chunks FK requires the row to exist), and indexFile deleted old chunks before the expensive embedding calls ran. An interruption mid-file (crash, timeout, process exit) left a file that looked fully indexed (hash matched) but had missing/zero chunks, permanently skipped on every future resume. Replace per-chunk persistence with one atomic transaction per file via vectorStoreDB.ReplaceFileDocuments: delete the file's row/chunks, insert the row with the final hash, insert all new chunks, commit. indexFile now calls this once, only after every model call for the file has succeeded. A file is therefore always either fully indexed (old or new version) or absent - never half-written. AddDocumentWithEmbedding and SetFileMetadata are removed from the vectorStoreDB interface (no other callers). Also treat a files row with zero recorded chunks as not-indexed in loadExistingHashes, to self-heal rows left behind by the pre-fix binary.