feat(AST indexing): Implement relationship index #38
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Greptile SummaryImplements AST-aware relationship indexing via a new Key changes:
The implementation follows the project's zero-infra, crash-safe, and incremental indexing principles. All artifacts are properly versioned and validated to prevent mixed-version corruption. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/core/indexer.ts | Added relationships.json generation with reverse import map and symbol export index; properly integrated into staging/active swap and rollback logic |
| src/core/index-meta.ts | Added relationships artifact validation with proper schema checking and version/buildId matching |
| src/tools/detect-circular-dependencies.ts | Updated to prefer relationships sidecar over intelligence.json for graph data with graceful fallback |
| src/tools/search-codebase.ts | Updated to use relationships sidecar for import graph lookups with intelligence.json fallback; improved separation of concerns |
| tests/relationship-sidecar.test.ts | Comprehensive test coverage for relationships.json creation, validation, incremental updates, and rebuild scenarios |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Index Build] --> B{Full Rebuild?}
B -->|Yes| C[Write to .staging/buildId/]
B -->|No| D[Write to .codebase-context/]
C --> E[Generate intelligence.json]
D --> E
E --> F[Extract internalFileGraph]
F --> G[Build relationships.json]
G --> H[Create imports map]
G --> I[Build importedBy reverse map]
G --> J[Build exportedBy symbol index]
H --> K[Write relationships.json with header]
I --> K
J --> K
K --> L{Full Rebuild?}
L -->|Yes| M[Atomic Swap: .staging → active]
L -->|No| N[Direct write to active]
M --> O[Move active → .previous]
O --> P[Move staging → active]
P -->|Success| Q[Cleanup .previous & .staging]
P -->|Failure| R[Rollback: .previous → active]
N --> S[Index Ready]
Q --> S
S --> T[Tools read relationships.json]
T --> U[detect_circular_dependencies]
T --> V[search_codebase]
U --> W{relationships.json exists?}
V --> W
W -->|Yes| X[Use relationships sidecar]
W -->|No| Y[Fallback to intelligence.json]
Last reviewed commit: 5b4dbe4
What / Why
Implements relationship indexing so we have an indexed import graph for files and symbols (AST-aware) and unlocks future tooling capabilities.