lab build: ambiguous repo name resolves to wrong repo (shortest-name tie-break) #312

Open
opened 2026-06-04 12:08:59 +00:00 by rawan · 0 comments
Member

Problem

lab build shrimp clones and builds thabeta/qwenshrimp instead of the intended lhumina_code/hero_shrimp.

Root cause

In ensure_local (crates/lab/src/repo/api.rs), a search term with no exact local hit falls through to a Forge q= search, then RepoFilter::best() (crates/lab/src/repo/find.rs) picks a winner:

  1. Exact basename match wins — neither qwenshrimp nor hero_shrimp equals shrimp, so this does not fire.
  2. Fallback: shortest full_name via min_by_key(|e| e.full_name.len()).

q=shrimp returns two repos:

18  thabeta/qwenshrimp
24  lhumina_code/hero_shrimp

Both contain the substring shrimp, so both pass the filter. The shortest-full_name tie-break then silently picks the unrelated thabeta/qwenshrimp.

Impact

  • An ambiguous partial name silently resolves to a wrong, unrelated repo and clones/builds it (here into $PATH_CODE/qwenshrimp).
  • No warning that multiple candidates matched.

Suggested fixes (any/combination)

  • When >1 candidate matches and none is an exact basename match, error out and list the candidates instead of silently picking the shortest.
  • Prefer a smarter tie-break (e.g. prefix/word-boundary match, or closest length to the query) over raw shortest full_name.
  • Optionally weight repos in the same org as the current checkout.

Workarounds

  • lab build hero_shrimp ... (more specific term)
  • lab build lhumina_code/hero_shrimp ... (org-qualified)
  • cd <repo> && lab build (builds cwd, skips Forge resolution)
## Problem `lab build shrimp` clones and builds `thabeta/qwenshrimp` instead of the intended `lhumina_code/hero_shrimp`. ## Root cause In `ensure_local` (`crates/lab/src/repo/api.rs`), a search term with no exact local hit falls through to a Forge `q=` search, then `RepoFilter::best()` (`crates/lab/src/repo/find.rs`) picks a winner: 1. **Exact basename match wins** — neither `qwenshrimp` nor `hero_shrimp` equals `shrimp`, so this does not fire. 2. **Fallback: shortest `full_name`** via `min_by_key(|e| e.full_name.len())`. `q=shrimp` returns two repos: ``` 18 thabeta/qwenshrimp 24 lhumina_code/hero_shrimp ``` Both contain the substring `shrimp`, so both pass the filter. The shortest-`full_name` tie-break then silently picks the unrelated `thabeta/qwenshrimp`. ## Impact - An ambiguous partial name silently resolves to a wrong, unrelated repo and clones/builds it (here into `$PATH_CODE/qwenshrimp`). - No warning that multiple candidates matched. ## Suggested fixes (any/combination) - When >1 candidate matches and none is an exact basename match, **error out and list the candidates** instead of silently picking the shortest. - Prefer a smarter tie-break (e.g. prefix/word-boundary match, or closest length to the query) over raw shortest `full_name`. - Optionally weight repos in the same org as the current checkout. ## Workarounds - `lab build hero_shrimp ...` (more specific term) - `lab build lhumina_code/hero_shrimp ...` (org-qualified) - `cd <repo> && lab build` (builds cwd, skips Forge resolution)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_skills#312
No description provided.