Output

For source searches, terminal output lists matching and uncertain locations. For example:

src/users.py:20-56    92% match
src/actions.py:4-12   uncertain (model chose uncertain)
src/client.py:20-45   uncertain (model chose no_match; confidence 0.5 < 0.8)

The percentage is the model's probability for match. It is not the probability that a review is correct. Source nonmatches are omitted. State mode prints every answer, including no_match. Counts and errors go to stderr.

Use --sort score to put higher match probabilities first. Results wait until the search finishes; errors remain immediate. Sorting preserves the model's scores and keeps uncertain results. It makes no extra model requests.

--min-confidence controls routing (default 0.8). An answer below that confidence routes to uncertain, even if the model chose match or no_match. An explicit uncertain choice stays uncertain at any threshold. Terminal output shows which case occurred. JSON preserves the original answer and records the routing separately.

JSON Lines

ev-grep 'Hides a database failure' src/ --json > results.jsonl

Every record has schema_version: 2, type, and data. A result has this shape (illustrative scores; request metadata omitted):

{
  "schema_version": 2,
  "type": "result",
  "data": {
    "file": "src/users.py",
    "range": {
      "start": { "line": 19, "column": 0 },
      "end": { "line": 20, "column": 0 },
      "byteOffset": { "start": 380, "end": 394 }
    },
    "text": "    return []\n",
    "assessment": {
      "choice": "match",
      "confidence": 0.76,
      "probabilities": { "match": 0.92, "no_match": 0.03, "uncertain": 0.05 },
      "model": "typesafe/jev-1.13-20260917",
      "input_tokens": 280,
      "output_tokens": 12
    },
    "routing": { "outcome": "uncertain", "reason": "low_confidence" }
  }
}

Positions count from zero; columns count Unicode characters. The end is exclusive. Optional byteOffset counts UTF-8 bytes. file is null for stdin. Optional context carries the complete original file used to assess a range. supporting contains any supplied source entries, each with file, range, and text; it is omitted when empty. Optional metaVariables retains ast-grep selection metadata; it is not part of the model's candidate search input. Results contain source text; store them as carefully as the source itself.

probabilities answers one question with three alternatives. Low match probability alone cannot distinguish a clear negative from missing context. confidence is the provider's separate confidence measure. The raw assessment is unchanged by --min-confidence. Its optional request metadata includes the prompt_id used for the request. The ID is a SHA-256 fingerprint of the prompt contents; the executable version is reported separately.

routing.outcome controls terminal inclusion, summary counts, and the exit code. An uncertain outcome has one of two reasons: model_uncertain for an explicit uncertain choice, or low_confidence for a choice below the threshold. Other outcomes omit reason. These reasons describe routing; the classifier does not return a free-text explanation.

TypeData
beginquery, executable version, prompt_id, provider, requested model, model_validated (false for an unvalidated model), confidence threshold, dry-run flag, strict flag, max_candidates (null when unset), jobs, sort order
selectedDry run: candidate fields, including optional context, supporting, and metaVariables, and combined source bytes
resultCandidate fields, raw assessment, and routing
selected_stateState dry run: state, content-derived input_id, and input bytes
assessmentState answer: state, input_id, bytes, raw assessment, and routing
skippedFile, optional requested lines, and reason: binary; symlink for a symbolic link that a directory search did not follow; or too_large for a file over 64 KiB, with its bytes
errorFile or input identifier, optional requested lines, kind, and message
summarySelected, evaluated, match, no-match, uncertain, skipped, and error counts; dry-run flag. skipped includes files over 64 KiB

An error's kind names the failure, so scripts can branch on it without parsing the message:

KindFailure
configurationInvalid settings, such as conflicting arguments, an invalid glob, an unsupported model, or a missing API key
ioAn input could not be read, such as a missing file, or output could not be written
unsupported_fileA symbolic link, a special file, or a directory given a line range
too_largeAn input over a size limit, or a selection over --max-candidates; nothing was truncated
invalid_inputMalformed input, such as invalid UTF-8, an empty query, a line range outside its file, or invalid JSON
timeoutAn attempt or the 15-second request budget timed out, or the provider answered HTTP 408
connectNo connection to the provider was made
tlsThe TLS handshake failed
transportThe connection failed while the request was sent or the response was read
rate_limitedThe provider answered HTTP 429, or its rate limit outlasts the assessment's 15-second budget
unavailableThe provider or its gateway answered HTTP 500, 502, 503, 504, 520, 522, or 524
moderationThe provider answered HTTP 403 and named moderation reasons
credential_rejectedThe provider answered HTTP 401 or an ordinary 403 and rejected the key
budget_busyOpenRouter funds are temporarily committed to other requests
insufficient_creditsAvailable OpenRouter credits cannot cover this request
key_budget_exceededThe child key exhausted its provider-enforced spending limit
payment_requiredOpenRouter answered HTTP 402 without a recognized budget source
spending_budget_exceededA configured OpenRouter workspace or guardrail spending budget is exhausted
rejectedThe provider answered another HTTP error, such as 400 or 404
invalid_responseThe response failed validation, such as probabilities that do not sum to one
model_mismatchThe response names a different model than the one requested
response_too_largeThe response exceeds 64 KiB

A credential_rejected error stops the search, because every later request would fail the same way. Its record has no file. No request starts after it, and requests already in flight are cancelled. Results that arrived earlier remain.

Results arrive as requests finish, or in descending match probability with --sort score. All successful assessments appear, including nonmatches. Completed runs end with one summary. Interrupted runs may not. Argument parsing errors print usage and exit 2 before starting the stream. Sorted runs buffer results, so interruption may leave only configuration, errors, and skips.

State assessments

With --state, the begin record adds mode: "state". Its query and executable version describe the run, and prompt_id identifies the context classifier prompt.

The selected_state and assessment records retain the parsed JSON value as state. Large integers and decimal precision are preserved without floating-point rounding. input_id has the form sha256:… and hashes the serialized parsed value; input whitespace does not affect it. bytes counts the original input bytes. These records have no candidate file or range, and state fields that look like paths are never opened.

An assessment record includes the same raw answer, token usage, request metadata, and separate routing as a source result. The label answers the supplied question; it does not establish a broader review conclusion. Completed state runs end with a summary and use the same exit codes as source searches. A valid state dry run exits 0.

Select by score

Keep candidates with at least 90% match probability:

jq -c 'select(.type == "result" and .data.assessment.probabilities.match >= 0.9) | .data' results.jsonl

For review, keep everything except confident negative answers:

jq -c 'select(.type == "result") | .data
  | select(.assessment.choice != "no_match" or .assessment.confidence < 0.9)' results.jsonl

These records can feed --candidates. Check the original exit status and summary before filtering: jq cannot recover an error record you discarded. A score cutoff is a caller policy, not a completeness guarantee.

To keep the same candidates as terminal output at the run's threshold, filter on routing instead:

jq -c 'select(.type == "result" and .data.routing.outcome != "no_match") | .data' results.jsonl

Exit codes

The first matching row wins:

CodeMeaning
2An execution or argument error, or with --strict a file skipped as over 64 KiB; earlier results may still be available
3At least one answer routes to uncertain
0At least one match, with no errors or uncertainty
1No matches, with no errors or uncertainty; includes empty selections

Skipped files, including files over 64 KiB, do not change the exit code unless --strict is set. Dry runs return 0 for eligible text or a valid state value, 1 for an empty candidate selection, and 2 for errors. They need no key and make no requests.

Traces

ev-grep 'Hides a database failure' src/ --json --trace trace.jsonl

Each line of a --trace file is one JSON object with timestamp, level, target, and fields. The first record's fields.event is trace.started. It names trace_schema_version, currently 2, the binary's version, the Git revision it was built from (unknown outside a Git checkout), and the environment. The environment is the --trace-environment value, or ci when the CI variable is set and local otherwise.

A span writes one record when it closes: fields.message is close, fields.time.busy and fields.time.idle give its durations, and span holds its name and fields. Every other record lists its enclosing spans in spans, outermost first. Traces are not sampled, and they keep only ev-grep's own records.

SpanFields
ev_grep.searchexit_code
ev_grep.filepath as output names it; bytes of the candidate with its supporting sources, or of a file over 64 KiB; outcome, the record it produced (result, skipped, or error); skip reason; error kind
provider.requestprovider, model, and body_bytes, the encoded request size
provider.waitreason: permit for a concurrency slot, cooldown for a shared rate limit, or backoff before a retry
provider.attemptattempt, counted from 1, and hedge

Each attempt that receives an answer or fails writes a provider.attempt_finished event with elapsed_ms. An attempt cancelled in flight, such as the slower of a hedged pair, writes none, but its span still closes. Each request ends with a provider.request_finished event with its attempts, hedges, and elapsed_ms. A failure adds its kind, HTTP status, and retry_after_ms; a failed attempt also adds the provider's request_id and cf_ray. Error kinds in traces use snake_case, such as credential_rejected and rate_limited. Trace schema version 1 used Rust names, such as CredentialRejected and RateLimited, for provider events.