Skip to content

Wave 4 / Search: standalone --ast resolves matches to the WRONG files (FileId→path ordering skew) #373

Description

@dean0x

Wave: wave4-search-followups

flowchart LR
  T372["1. #372 lexical AND-intersect"]
  T373["2. #373 FileId skew"]
  T374["3. #374 AST verify gate"]
  T375["4. #375 remove index positional"]
  T377["5. #377 weights notice"]
  T380["6. #380 binarize + positional"]
  T376["7. #376 CRC marker"]
  T379["8. #379 worktree staleness"]
  T378["9. #378 risk volume weighting"]
  T381["10. #381 index-location docs"]
  T372 --> T373 --> T374 --> T375 --> T377 --> T380 --> T376 --> T379 --> T378 --> T381
  T373 -. requires .-> T374
  T373 -. requires .-> T380
  T380 -. requires .-> T376
  T375 -. requires .-> T377
  classDef cur fill:#dcffe4,stroke:#1a7f37,stroke-width:3px;
  class T373 cur;
Loading

Solid arrows = integration order into wave/wave4-search-followups. Dotted = hard dependency. One branch per ticket; this ticket highlighted.

Found via dog-fooding round 2 (2026-06-27, branch wave/wave4-search), tracked under #174 Wave 4. Priority: P0.

Problem: Standalone --ast prints the wrong file paths for matches — results include files that cannot contain the pattern. Acting on these sends an agent to the wrong file (worse than an empty result).

Evidence:

$ skim search --ast "for_expression > block" --limit 40
   ... crates/rskim-contract/Cargo.toml
   ... crates/rskim-contract/clippy.toml
   ... crates/rskim-core/README.md      # none can contain a Rust for-loop

Reproduced decisively in an isolated 2-file repo: function_item > block returned foo.rs (no function) instead of foo/bar.rs (the only file with a function).

Root cause: FileIds are assigned in PathBuf order at index time (walk.rs:428) but resolved through a String/BTreeMap-ordered path list (manifest.sorted_paths) at query time. Path-separator vs string-collation ordering differ, so the Nth match resolves to a different file's path.

Best fix: make FileId assignment and path resolution use the same canonical ordering (pick byte-wise string order, apply on both sides). Add a round-trip test asserting resolve(assign(path)) == path over a corpus with nested directories.

Refs: #174.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsearchCode search featurewave-4Wave 4: Compound queries

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions