Skip to content

Support indexed hidden-file searches while preserving ignore rules - #158

Merged
Shengyu Fu (shengyfu) merged 3 commits into
mainfrom
shengyfu-indexed-hidden-files
Sep 12, 2026
Merged

Shengyu Fu (shengyfu) merged 3 commits into
mainfrom
shengyfu-indexed-hidden-files

Conversation

@shengyfu

Copy link
Copy Markdown
Member

Summary

Make index and serve include hidden, non-ignored files by default, while ordinary searches continue to apply ripgrep-compatible hidden-file filtering. serve --hidden is accepted as a redundant flag; no new server startup flag is required.

This fixes the indexed-search performance regression for Copilot's existing arguments, including --index-path <index> --files-with-matches --hidden --glob !.git --with-filename -- needle <root>. Content, filename-only, count, JSON, and --files queries can use compatible local indexes or the server without dropping hidden matches or disabling ignore rules.

  • Apply shared visibility before candidate limits/counts/output selection, respecting explicitly requested hidden roots and Windows hidden attributes without per-candidate filesystem probes.
  • Carry the broader corpus through builds, resumed checkpoints, reloads, incremental publication, native watching, polling, and startup reconciliation. Discover and update ignore rules inside hidden directories; preserve .gitignore/.ignore and other existing ignore semantics.
  • Exclude the actual configured index directory and its staging/retired generations, including custom storage inside the source tree. Preserve existing Windows generation retirement and rollback handling.
  • Reconcile descendants when a native directory rename/removal reports only the directory, so old content/cache and filename entries do not survive.

Compatibility and migration

Legacy, incomplete, or mismatched coverage metadata falls back to a filesystem scan. A current server reconciles older indexes and publishes hidden coverage only when it has established the eligible corpus; older servers must explicitly confirm support before a new client renders indexed results.

The new file-table format prevents older local readers from silently exposing hidden results by ignoring visibility metadata. Filename-only membership is published atomically with its visibility and file-table identity, including coherent startup hydration after interrupted publication. New readers retain legacy-format migration support. Downgrading to an older binary requires rebuilding its index, preferably at a separate --index-path.

--hidden never implies --no-ignore. Positive glob overrides intentionally scan because they can reinclude ignored files absent from the default index; negative-only globs such as !.git remain indexed. Other unsupported corpus-widening flags retain their scan fallback. README and agent guidance document these boundaries.

No package version bump, runtime-repository change, tag, or release is included.

Validation

  • Workspace unit tests: 261 CLI passed, 1 existing ignored; 257 core passed.
  • Related integration tests: 362 passed — ripgrep_compat 230, ripgrep_parity 102, indexed_hidden 8, indexed_files 4, concurrent_search 7, memory_cap 1, watcher_dot_ignore 2, watcher_watch_registration 6, warm_start_gitignore 1, and serve_max_filesize 1. The final committed eight-test indexed_hidden target was rerun successfully.
  • Focused regressions cover real Copilot arguments and backend diagnostics, ordinary visibility, ignored hidden files, legacy/incomplete coverage and migration, custom storage, Windows attributes, hidden updates/ignore transitions/restarts, interrupted filename publication/startup hydration, native directory rename, and retained publication rollback assertions.
  • cargo clippy --workspace --benches --locked --quiet -- -D warnings, cargo build --workspace --benches --locked --quiet, cargo fmt --all -- --check, and Git whitespace checks passed.
  • Independent acceptance against the frozen binary: 82 parity/lifecycle cases (including native directory creation/rename/deletion with an active watcher) and 10 exact v1.0.8 reverse-client local/server cases, all passed. Parent acceptance checked content/-l/-c routing and --files parity; Rust regressions separately assert filename backend diagnostics.

Copilot AI balanced review requested due to automatic review settings September 11, 2026 22:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Interrupted publication can incorrectly restore complete coverage from stale metadata and serve incomplete indexed results.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 High severity

Open findings (1)
What changed in this PR

Adds indexed hidden-file searches while preserving ignore rules and ordinary visibility.

Changes:

  • Adds hidden-path visibility metadata and versioned index formats.
  • Updates local/server routing, watcher reconciliation, and glob handling.
  • Adds extensive compatibility and lifecycle tests plus documentation.
File Description
tgrep-core/​src/​walker.rs Collects hidden visibility and excludes storage paths.
tgrep-core/​src/​visibility.rs Implements query-time hidden-path filtering.
tgrep-core/​src/​reader.rs Tracks file-table identity.
tgrep-core/​src/​path_index.rs Adds visibility-aware filename sidecars.
tgrep-core/​src/​ondisk.rs Versions the file-table format.
tgrep-core/​src/​meta.rs Stores coverage, visibility, and table identity.
tgrep-core/​src/​lib.rs Exports the visibility module.
tgrep-core/​src/​gitignore.rs Extends ignore matching into hidden trees.
tgrep-core/​src/​builder.rs Builds hidden-inclusive indexes and coverage metadata.
tgrep-cli/​tests/​ripgrep_parity.rs Updates legacy coverage fallback tests.
tgrep-cli/​tests/​ripgrep_compat.rs Tests indexed hidden-search compatibility.
tgrep-cli/​tests/​indexed_hidden.rs Adds comprehensive hidden-index integration coverage.
tgrep-cli/​src/​status.rs Reports hidden coverage status.
tgrep-cli/​src/​serve/​poll_tests.rs Updates polling coverage assertions.
tgrep-cli/​src/​serve/​hidden_tests.rs Tests server visibility and publication behavior.
tgrep-cli/​src/​serve.rs Integrates visibility across serving and watching.
tgrep-cli/​src/​search.rs Routes compatible hidden searches through indexes.
tgrep-cli/​src/​main.rs Makes builder --hidden redundant.
tgrep-cli/​src/​glob_filter.rs Uses shared ripgrep-style overrides.
README.md Documents hidden-index behavior and migration.
AGENTS.md Updates agent usage guidance.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tgrep-core/src/path_index.rs
Copilot AI review requested due to automatic review settings September 11, 2026 23:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Filesystem fallbacks can expose custom index storage, and status can report coverage that query routes reject.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 1 Medium severity

Open findings (2)
Resolved findings (1)

Comment thread tgrep-cli/src/search.rs Outdated
Comment thread tgrep-cli/src/status.rs Outdated
Copilot AI review requested due to automatic review settings September 12, 2026 00:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Glob post-filtering incorrectly prevents later positive overrides from re-including descendants of excluded directories.

Review tier: Balanced
Findings: None

Resolved findings (2)
Previously missed findings (1)

In code that hasn't changed since last review

Medium severity Preserve ordered glob re-inclusion beneath excluded directories

tgrep-cli/​src/​glob_filter.rs:74

This unconditional ancestor rejection breaks OverrideBuilder's last-match-wins semantics. For example, --glob '!foo' --glob 'foo/keep.txt' allows the walk to descend for the later whitelist, but passes_filters calls this method and drops foo/keep.txt as soon as it sees the excluded foo ancestor. Preserve rule ordering across ancestor and file matches so later positive overrides can re-include descendants.

@shengyfu
Shengyu Fu (shengyfu) merged commit b1d0fc2 into main Sep 12, 2026
10 checks passed
@shengyfu
Shengyu Fu (shengyfu) deleted the shengyfu-indexed-hidden-files branch September 12, 2026 00:20
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.

2 participants