What Triggers a Full Code Analysis Rebuild in Egonex-AI?
Egonex-AI triggers a full code analysis rebuild when either more than 30 structural files change or when structural changes exceed 50% of the total project files, as determined by the classifyUpdate function in change-classifier.ts.
The Understand-Anything engine optimizes performance by avoiding unnecessary knowledge graph reconstructions. According to the Egonex-AI source code, the system analyzes the magnitude of structural changes to determine when a complete re-analysis—including architecture and tour generation—is truly required.
The Two Triggers for a Full Rebuild
The decision logic resides in packages/core/src/change-classifier.ts. The classifyUpdate function evaluates the scope of changes and returns an UpdateDecision with action: "FULL_UPDATE" when either of two quantitative thresholds is breached.
The 30-File Threshold
When the total count of structural changes exceeds 30 files, the system initiates a full rebuild. This condition is expressed as:
structuralCount > 30
The 50-Percent Project Threshold
Alternatively, if structural changes affect more than half of the entire project, a full rebuild is triggered. This calculation requires:
totalFilesInGraph > 0 && structuralCount / totalFilesInGraph > 0.5
How Structural Changes Are Calculated
The structuralCount variable aggregates all file modifications that impact code structure. As implemented in change-classifier.ts, the calculation includes:
const structuralCount = structurallyChangedFiles.length + newFiles.length + deletedFiles.length;
Structural files encompass new files, deleted files, and files with structural changes—excluding cosmetic-only edits. The cosmeticOnlyFiles array tracks superficial modifications that do not trigger rebuilds.
Implementation Details and Testing
The classification logic is validated by unit tests in packages/core/src/__tests__/change-classifier.test.ts. These tests verify that both the 30-file threshold (lines 124-132) and the 50-percent threshold (lines 136-146) correctly return FULL_UPDATE decisions.
The type definitions supporting this analysis are defined in packages/core/src/fingerprint.ts, which exports the ChangeAnalysis interface consumed by classifyUpdate.
Practical Code Examples
The following examples demonstrate how the classifier behaves when thresholds are crossed:
Example 1: Exceeding 30 Structural Files
import { classifyUpdate } from "./change-classifier.js";
import type { ChangeAnalysis } from "./fingerprint.js";
const manyChanges: ChangeAnalysis = {
newFiles: [],
deletedFiles: [],
structurallyChangedFiles: Array.from({ length: 35 }, (_, i) => `src/file${i}.ts`),
cosmeticOnlyFiles: [],
unchangedFiles: [],
fileChanges: [],
};
const decision = classifyUpdate(manyChanges, 100);
console.log(decision.action); // "FULL_UPDATE"
Example 2: Exceeding 50% Project Changes
const halfChanges: ChangeAnalysis = {
newFiles: [],
deletedFiles: [],
structurallyChangedFiles: [
"src/a.ts", "src/b.ts", "src/c.ts",
"src/d.ts", "src/e.ts", "src/f.ts"
],
cosmeticOnlyFiles: [],
unchangedFiles: [],
fileChanges: [],
};
const decision = classifyUpdate(halfChanges, 10);
console.log(decision.action); // "FULL_UPDATE"
Summary
- Egonex-AI triggers a full rebuild (
FULL_UPDATE) only when structural changes exceed specific magnitude thresholds. - The 30-file threshold triggers a rebuild when more than 30 structural files are modified, added, or deleted.
- The 50-percent threshold triggers a rebuild when structural changes affect the majority of the project.
- The calculation excludes cosmetic-only changes, focusing strictly on structural modifications to
newFiles,deletedFiles, andstructurallyChangedFiles. - All logic is implemented in
packages/core/src/change-classifier.tsand verified bychange-classifier.test.ts.
Frequently Asked Questions
What counts as a structural file change in Egonex-AI?
The system classifies new files, deleted files, and files with structural changes as structural modifications. Cosmetic-only edits that do not affect the code structure are tracked separately in cosmeticOnlyFiles and do not count toward the rebuild thresholds.
What happens when a full code analysis rebuild is triggered?
When classifyUpdate returns an UpdateDecision with action: "FULL_UPDATE", the Understand-Anything engine performs a complete re-analysis of the knowledge graph. This includes rebuilding the architecture analysis and regenerating code tours from scratch.
Where are the rebuild thresholds defined and tested?
The threshold logic is implemented in packages/core/src/change-classifier.ts within the classifyUpdate function. The unit tests verifying these triggers are located in packages/core/src/__tests__/change-classifier.test.ts, specifically testing the 30-file boundary (lines 124-132) and the 50-percent ratio (lines 136-146).
Can the thresholds for triggering a full rebuild be configured?
Based on the current source code analysis, the thresholds (30 files and 50 percent) appear to be hardcoded constants within the change-classifier.ts logic. There is no evidence of external configuration options in the provided codebase.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →