Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/grepturbo
/benchcmd
.grepturbo/
.grepturbo-go/
Binary file removed benchcmd
Binary file not shown.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions docs/DEEPENING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Deepening Opportunities

This document tracks identified architectural friction and proposed refactors to improve **depth**, **leverage**, and **locality** in GrepTurbo.

## 1. Unified Index Module
- **Files**: `internal/index/reader.go`, `internal/index/sync.go`, `internal/query/search.go`
- **Problem**: The `Search` function is **shallow** because it manually orchestrates **Baseline** lookup, **Overlay** lookup, and **Tombstone** filtering. This leaks internal index layering into the query engine.
- **Solution**: Deepen the `internal/index` module by introducing a unified interface that provides a single `Candidates(trigrams []uint32) ([]string, error)` method.
- **Benefits**:
- **Locality**: Concentrates knowledge of multi-layer merging in one place.
- **Leverage**: Simplifies the query engine by hiding sync and filtering complexity.
- **Testability**: Enables testing candidate selection logic in isolation.

## 2. Search Pipeline Module
- **Files**: `internal/query/search.go`, `internal/query/decompose.go`
- **Problem**: `Search` is a procedural, monolithic function mixing regex decomposition, index coordination, and file I/O.
- **Solution**: Create a **Deep** search module that encapsulates the pipeline, using `QueryableIndex` and a `Matcher` as **Adapters**.
- **Benefits**:
- **Locality**: Isolates the "rules" of the search process.
- **Leverage**: Provides a simple `Execute(pattern)` interface.

## 3. Overlay as LiveIndex
- **Files**: `internal/index/sync.go`
- **Problem**: `Sync()` returns a **shallow** "bag of data" (`Overlay` struct) that callers must know how to interpret.
- **Solution**: Turn `Overlay` into a `LiveIndex` module that satisfies the same interface as the **Baseline** index, allowing for polymorphic treatment.
- **Benefits**:
- **Depth**: Leverages polymorphism to simplify the merging logic.
- **Locality**: Isolates dirty-file indexing from query logic.
File renamed without changes.
Loading