Repository navigation
fix(rag): preserve the index when document discovery fails - #21
Conversation
ipiton
left a comment
There was a problem hiding this comment.
The problem is real — a temporarily unavailable source must not be pruned as deleted. But failing the whole run on any discovery error breaks the default setup. A configured root that doesn't exist is a normal case today: the shipped preset is docs,README.md,CHANGELOG.md, and T97 coverage reports such roots by name. With this PR a project that simply has no CHANGELOG.md can no longer be indexed at all:
engine.docService.config.IndexDirs = []string{"docs", "README.md", "CHANGELOG.md"} // no CHANGELOG.md on disk
err := engine.IndexDocuments(ctx)
// main: nil
// this PR: failed to collect documents: access configured index source ".../CHANGELOG.md": ... no such file or directoryThe same applies to the watcher path, and to a single unreadable file or a file removed mid-scan inside a large directory.
Suggested direction: let collectDocuments also return the roots/paths it could not scan, and have the pruning step skip indexed files under those prefixes. A missing root that never had files stays harmless (and keeps the T97 report), a temporarily missing one keeps its records, and an unreadable file is left untouched instead of failing the run. Your existing regression tests (preserved chunks/metadata, retry after restore) fit this model as-is; only the "returns an error" assertions would change to "logs + preserves".
|
Thanks — the reworked design is exactly what I had in mind, and the new tests cover the cases well. The missing- #22, #23 and #24 are merged into
Please merge |
|
Updated this branch against current The new regression runs both a plain directory and a configured symlink. It verifies that an unreadable subtree is recorded as
All five upstream GitHub checks passed on |
A temporarily unavailable source should not look like a deletion. Discovery records failures under their logical paths and retains still-included indexed files under those paths. Other paths continue to update. An optional source that has never been indexed, such as a missing
CHANGELOG.md, does not block indexing.The current
mainintegration uses the directory walker from #23. It computes the logical path before handling walk errors and updates the caller to use thedocumentScanresult. New tests cover unreadable subtrees through a configured directory symlink, healthy sibling updates and pruning, and recovery. Explicit exclusions still prune old records, even when a source cannot be read. Adopting a different root cannot relabel unavailable records from the old root. An explicit root replacement removes them.Validation:
make test vet evalgo test -race ./internal/ragThe existing branch incorporates current
mainand retains its published history. The test fixtures use no downloaded model or private documents.