Skip to content

feat(terraphim_grep): failover to fff-search enhanced grep when KG is not configured#4

Closed
AlexMikhalev wants to merge 2 commits into
mainfrom
task/55-grep-kg-failover
Closed

feat(terraphim_grep): failover to fff-search enhanced grep when KG is not configured#4
AlexMikhalev wants to merge 2 commits into
mainfrom
task/55-grep-kg-failover

Conversation

@AlexMikhalev

Copy link
Copy Markdown
Contributor

Summary

Makes terraphim-grep usable without a knowledge-graph thesaurus by falling back to fff-search enhanced grep mode. Also bumps the workspace version to 1.21.0.

Changes

  • crates/terraphim_grep/Cargo.toml: make code-search a default feature.
  • crates/terraphim_grep/src/main.rs: add resolve_thesaurus() helper that returns an empty Thesaurus when no project thesaurus is found.
  • crates/terraphim_grep/src/lib.rs: add unit test for empty-thesaurus search.
  • crates/terraphim_grep/tests/no_thesaurus_cli.rs: add integration test for CLI invocation without --thesaurus.
  • Cargo.toml / crates/terraphim_grep/Cargo.toml: bump workspace version to 1.21.0 and align terraphim_service dependency.

Verification

  • cargo test -p terraphim_grep passes.
  • cargo clippy -p terraphim_grep -- -D warnings passes.
  • Installed terraphim-grep --version reports 1.21.0.
  • Manual test: terraphim-grep works in a directory with no .terraphim config.

Related

  • Refs terraphim/terraphim-clients#55
  • Refs terraphim/terraphim-ai#2995

… not configured

- Make code-search a default feature so fff-search is always available.
- Add resolve_thesaurus() helper that returns an empty Thesaurus when no
  project thesaurus is found instead of failing the CLI.
- Log an info message when running in fff-search-only mode.
- Add unit test for empty-thesaurus search and integration test for the
  CLI invocation without --thesaurus.

Refs #55
- Bump workspace.package.version from 1.20.5 to 1.21.0.
- Align terraphim_grep's terraphim_service dependency with the current
  registry patch (1.20.5).

Refs #55
Refs #2995
@AlexMikhalev

Copy link
Copy Markdown
Contributor Author

Summary

This PR makes terraphim-grep usable without a knowledge-graph thesaurus by falling back to fff-search enhanced grep mode. It also bumps the workspace version to 1.21.0 so installed binaries align with the latest terraphim-ai release.

Key changes:

  • crates/terraphim_grep/Cargo.toml: Moves code-search into default features so the fff-search backend is always available.
  • crates/terraphim_grep/src/main.rs: Introduces resolve_thesaurus() which returns an empty Thesaurus when no explicit/default thesaurus exists, instead of failing the CLI.
  • crates/terraphim_grep/src/lib.rs: Adds search_without_thesaurus_uses_fff_mode unit test.
  • crates/terraphim_grep/tests/no_thesaurus_cli.rs: Adds an integration test that runs the compiled binary without --thesaurus and asserts valid JSON with empty concepts and at least one chunk.
  • Workspace version: Bumps to 1.21.0 and aligns the terraphim_service dependency version.

What was done well:

  • The failover is automatic and transparent — no new CLI flags required.
  • Existing KG-boosted behaviour is preserved when a thesaurus is present.
  • Both unit and integration tests cover the new path.
  • All tests, clippy, and pre-commit checks pass.

What remains to consider:

  • None. The change is additive and the integration test exercises the real binary.

Confidence Score: 5/5

  • Safe to merge with minimal risk.
  • Zero P0/P1 findings. The failover path reuses existing fff-search integration and an empty Thesaurus constructor that already had test coverage. Version bump is mechanical.
  • No files require special attention.

Important Files Changed

Filename Overview
crates/terraphim_grep/src/main.rs Replaces hard thesaurus error with resolve_thesaurus() fallback. Clean additive change.
crates/terraphim_grep/Cargo.toml Adds code-search to default features; bumps terraphim_service version.
crates/terraphim_grep/src/lib.rs Unit test for empty-thesaurus search.
crates/terraphim_grep/tests/no_thesaurus_cli.rs Integration test invoking the real binary without a thesaurus.
Cargo.toml Workspace version bump to 1.21.0.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[terraphim-grep query] --> B{--thesaurus or default?}
    B -->|Yes| C[Load Thesaurus]
    B -->|No| D[Empty Thesaurus]
    C --> E[HybridSearcher]
    D --> E
    E --> F{KG search}
    F -->|Concepts found| G[Boost chunks with KG]
    F -->|No concepts| H[fff-search only]
    G --> I[GrepResult]
    H --> I
    style D fill:#d4edda,stroke:#28a745
    style H fill:#d4edda,stroke:#28a745
Loading

Inline Findings

No findings. The implementation matches the design and the integration test provides end-to-end evidence.

Footer

Last reviewed commit: a15f49e | Reviews (1)

@AlexMikhalev

Copy link
Copy Markdown
Contributor Author

Closing in favour of the canonical Gitea PR: https://git.terraphim.cloud/terraphim/terraphim-clients/pulls/56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant