Skip to content

fix(roadmap): a slow git grep stops the refine context collection #4878

Closed

Description

@dan-petty

Problem Description

Refine collects the context of an item with git grep -n -F -w -e <identifier> <sha> -- over the whole tree at the pinned commit (_collect_identifiers in src/devops_cli/roadmap/refine/refine.py). git_result runs it with timeout=15. When the grep takes longer, subprocess.TimeoutExpired escapes from refine_one_item, and plan_refine stops with it. Refine does not record the item as a failed model call, so the item gets no failure class and no wait.

Reproduction Steps

  1. Run refine for test(k8s): verify the RAG ingest CronJob schedule #4135 (body names crawl4ai) on a loaded workstation: uv run devops roadmap refine --item 4135.
  2. Time the same grep: git grep -n -F -w -e crawl4ai HEAD -- | wc -l gave 438 lines in 12.0 s on 2026-11-12.

Expected vs Actual Behavior

  • Expected: a slow grep cuts the context of the item, and refine goes on with the other parts of the context.
  • Actual: TimeoutExpired: Command '['git', '-C', '<checkout>', 'grep', '-n', '-F', '-w', '-e', 'crawl4ai', '<sha>', '--']' timed out after 15 seconds stops the plan of the item.

Proposed Solution

  • Limit the grep to the paths that hold code and documents (for example a pathspec that leaves out openspec/changes/archive/ and tests/fixtures/), or use --max-count.
  • Treat a timeout of one grep as no result for that identifier, and log it.
  • Open PR feat(roadmap): find symbol definitions with tree-sitter #4820 changes the symbol search of refine; check that it does not already cover this.

Existing Tool Considered

git grep is the tool. The change is a pathspec and the handling of a timeout. Cost: about 20,000 tokens and 30 minutes.

Acceptance Criteria

  • A test with a git fake that times out on one grep shows that refine plans the item with the other context.

Source: the read-only replay of #4798 on 2026-11-12.

Source: #4874

Alternatives check of 2026-11-14: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  2. removed
    effort/low
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The bug stops one item's refine plan under load, but it does not corrupt data or block all items.
    • Value: Medium. It keeps refine running for the affected item instead of losing the whole plan on a slow grep.
    • Effort: Low. The fix is a pathspec or max-count limit plus a timeout handler, estimated at about 30 minutes.
    • Related: feat(roadmap): the stage context holds the callers and tests of each cited symbol #3012, which asks for a different change. Both work on refine context collection, but #3012 adds callers and tests to the context while this item fixes a crash when the existing grep times out.
  4. added
    effort/low
    on Nov 12, 2026
  5. added
    priority/p2-medium
    and removed
    effort/low
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. A slow grep stops the plan of one item, but the other items and the poll cycle continue.
    • Value: Medium. Refine keeps the other parts of the context and no longer loses the plan of an item.
    • Effort: Low. The change adds a pathspec and a timeout handler, with one test that uses a git fake.
    • Related: feat(roadmap): the stage context holds the callers and tests of each cited symbol #3012, which asks for a different change. Both items change how refine collects the context of cited identifiers. #3012 adds the callers and tests of each symbol, and the candidate limits the grep paths and treats a timeout as no result.
  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The need is an in-repo change to refine's context collection: narrow the git grep pathspec (or cap matches) and turn a grep TimeoutExpired into a logged empty result so the item keeps its other context. The searches returned only generic Git and timeout reference pages and no tool or library that provides this timeout-tolerant grep behavior for refine, so no external tool covers the need.

    Tool: none found

    Lacks:

    • A pathspec or --max-count limit that keeps git grep inside code and document paths and out of openspec/changes/archive/ and tests/fixtures/
    • A handler that turns one grep timeout into a logged empty result for that identifier instead of letting TimeoutExpired escape refine_one_item
    • A git fake test that times out on one grep and shows refine plans the item with the remaining context
    • The item failure class and wait that refine records for failed model calls

    Searches run:

    • python library fast git grep with timeout and pathspec code search, results: 5
    • ripgrep vs git grep performance large repository pathspec, results: 5
    • git grep --max-count pathspec exclude directory documentation, results: 5
    • ripgrep github BurntSushi ripgrep repository, results: 5
    • ripgrep recursive search tool, results: 5
    • subprocess TimeoutExpired handling git command python best practice, results: 5
    • open source code search index tool that handles repository grep timeouts, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  8. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 15, 2026
  9. added
    status/in-review
    and removed
    status/in-progress
    on Nov 15, 2026
  10. removed
    status/in-review
    owner/agent
    on Nov 15, 2026
  11. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-15 23:51 UTC

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

    priority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions