Repository navigation
fix(worker): make Jira repo selection smart via code evidence - #42
Merged
Merged
Conversation
CPM-7881 (a generic "override Tailwind tracking-tighter token" ticket) was
mis-routed to fitness-club-daily-schedule instead of speedboat. Root cause:
select_repo fed the LLM only each repo's name/description/top-level-dirs and
asked it to guess — a generic ticket has no repo hint in its prose, so the
guess was arbitrary.
Now selection is grounded in CODE EVIDENCE: extract the ticket's distinctive
identifiers (filenames, kebab/camel/Pascal/snake_case) and search each candidate
repo for them. The repo that actually contains `tracking-tighter` / `ClassRow`
is almost always the right one.
- extract_ticket_search_terms(): regex-extracts code-like identifiers, capped.
- select_repo(): probes up to 4 terms across candidate repos (repos<=10), tallies
matches, and either short-circuits to a uniquely-strong match or feeds the
evidence into the LLM prompt ("prefer the repo with concrete matches").
Hardening from adversarial review:
- Resolve each repo's DEFAULT branch instead of passing "HEAD" — "HEAD" 404s the
snapshot ref lookup and silently falls back to the rate-limited Code Search API
(would 403 after ~10 of up to 40 probes and corrupt the evidence).
- Short-circuit requires >=2 distinct identifiers agreeing on one repo; a single
generic token is too weak to bypass the LLM (could re-trigger the mis-route).
- Log search errors and drop the evidence entirely if searches fail systemically,
rather than presenting "no matches" as fact.
Test: extract_ticket_search_terms catches CPM-7881's (tracking-tighter,
letter-spacing) and CPM-7838's (ClassRow, GroupCard) identifiers, and yields
nothing for a prose-only ticket (clean LLM fallback).
Follow-up: selection downloads candidate-repo tarballs to snapshot-search; an
org-scoped Code Search would avoid the per-triage downloads (tracked separately).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TICKET-7881 ("override Tailwind
tracking-tightertoken") mis-routed tofitness-club-daily-scheduleinstead of web-app. Root cause:select_repofed the LLM only each repo's name / description / top-level dirs and asked it to guess — a generic ticket has no repo hint in its prose, so the pick was arbitrary. (A hardCPM→web-appmapping was rejected as a bandaid; the selector itself needs to be smart.)Fix — ground selection in code evidence
The repo that actually contains the ticket's identifiers is almost always the right one.
extract_ticket_search_terms()— regex-extracts distinctive identifiers (filenames, kebab/camel/Pascal/snake_case), deduped and capped.select_repo()— probes up to 4 terms across the candidate repos (repos ≤ 10), tallies matches per repo, and either short-circuits to a uniquely-strong match or feeds the evidence into the LLM prompt ("STRONGLY prefer the repo with concrete matches").Hardening (from adversarial review)
"HEAD"—"HEAD"404s the snapshot ref lookup and silently falls back to the rate-limited Code Search API (up to 40 probes/triage → 403 after ~10 → corrupted evidence). This was a HIGH bug that would've silently defeated the feature.Verification
cargo clippy -p worker --all-targets -D warnings— cleancargo fmt --check— cleancargo test -p worker— new test: extractor catches TICKET-7881 (tracking-tighter,letter-spacing) and TICKET-7838 (ClassRow,GroupCard) identifiers; yields nothing for a prose-only ticket (clean LLM fallback)Follow-up (tracked, not in this PR)
Selection snapshot-searches each candidate repo (downloads tarballs during triage). An org-scoped Code Search (
org:qualifier, one call per term) would avoid the per-triage downloads. Memory: therepos ≤ 10fan-out holds several snapshots; fine for normal repos, bounded by the tarball cap + API fallback for outliers.