fix: harden daemon and large-index recovery paths (#1562)

* fix: harden indexing recovery and daemon liveness

* test: cover daemon and recovery review gaps

* test: pin that a failure marker never blocks a later successful parse (#1557 retry-discard guard)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
Co-authored-by: Colby McHenry <me@colbymchenry.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniil
2026-08-20 12:53:49 -05:00
committed by GitHub
co-authored by Claude Fable 5 danusha2345 Colby McHenry
parent d8f2eeaddf
commit 81e1f4a92f
20 changed files with 680 additions and 83 deletions
+35
View File
@@ -120,6 +120,41 @@ describe('CodeGraph Foundation', () => {
cg.close();
});
it('restores every secondary index after a crash inside bulk parse load (#1556)', () => {
const dbPath = getDatabasePath(tempDir);
const first = DatabaseConnection.initialize(dbPath);
const before = (first.getDb()
.prepare("SELECT name FROM sqlite_master WHERE type = 'index' ORDER BY name")
.all() as Array<{ name: string }>).map((r) => r.name);
first.beginBulkParseLoad();
first.close();
const reopened = DatabaseConnection.open(dbPath);
const after = (reopened.getDb()
.prepare("SELECT name FROM sqlite_master WHERE type = 'index' ORDER BY name")
.all() as Array<{ name: string }>).map((r) => r.name);
reopened.close();
expect(after).toEqual(before);
});
it('skips secondary-index DDL when the schema is already healthy', () => {
const dbPath = getDatabasePath(tempDir);
const connection = DatabaseConnection.initialize(dbPath);
const db = connection.getDb();
const originalExec = db.exec.bind(db);
let execCalls = 0;
db.exec = (sql: string) => {
execCalls++;
originalExec(sql);
};
(connection as any).healBulkSecondaryIndexes();
connection.close();
expect(execCalls).toBe(0);
});
it('should return correct database size', () => {
const cg = CodeGraph.initSync(tempDir);
const stats = cg.getStats();