Skip to content

Python Client API

This page lists the public API of the bifrost_searchtools package. The distribution name on PyPI is brokk-bifrost-searchtools. The package version is the Bifrost release version (0.12.0 for this page). For a task-oriented introduction, see Python Client.

The package can print its own export list and signatures:

Terminal window
python -c "import bifrost_searchtools; print(sorted(bifrost_searchtools.__all__))"
python -c "import bifrost_searchtools, inspect; print(inspect.signature(bifrost_searchtools.SearchToolsClient.query_code))"
ItemValue
Python version3.12 or later (requires-python = ">=3.12"). The client uses enum.StrEnum.
Wheel tagcp312-abi3. One wheel serves Python 3.12 and every later 3.x release.
Wheel platformsLinux x86_64 and aarch64 (manylinux2014), macOS x86_64 and arm64, Windows x86_64 (amd64).
Other platformsInstall from the sdist. The build needs a Rust toolchain (Rust 1.99 or later) and maturin 1.7 or later.
Python dependenciesNone.
Native modulebifrost_searchtools._native, a compiled extension built with PyO3.

These names are importable from bifrost_searchtools.

NameKindMeaning
SearchToolsClientclassOne in-process analysis session over one project root.
SearchToolsErrorexceptionRaised for every failure inside the native module. Subclass of RuntimeError.
SymbolKindFilterenumDeclaration kind filter for symbol lookups.
MostRelevantFilesRankingModeenumRanking algorithm for most_relevant_files.
tool_descriptorsfunctionReturn the MCP tool descriptors for a toolset.
code_query_variant_inventoryfunctionReturn the CodeQuery vocabulary that the loaded native build emits.
extensions_for_pathsfunctionReturn every file extension for the languages present in a list of paths.
parse_code_query_responsefunctionDecode a query_code JSON payload into a typed response.
Result classesdataclassesListed under Result Classes and CodeQuery Result Types.
Enums for result fieldsenumsListed under Enums.

Some classes exist only in bifrost_searchtools.models and are not exported from the top-level package. Import them from bifrost_searchtools.models. They are marked “models only” in the tables below.

SearchToolsClient(
root: Path | str,
library_path: Path | str | None = None,
render_line_numbers: bool = True,
manual: bool = False,
sources: list[str] | None = None,
revision: str | None = None,
)
ParameterTypeDefaultMeaning
rootPath or strrequiredProject root. The client expands ~ and resolves the path to an absolute path.
library_pathPath, str, or NoneNonePath to a built native library. None imports bifrost_searchtools._native. One process can load only one explicit library path.
render_line_numbersboolTrueWhether rendered text includes line numbers. Structured line fields are present either way.
manualboolFalseTrue starts a session with no file watcher. The caller reports changes through update_paths.
sourceslist[str] or NoneNoneRestricts the session to the named files, directories, or globs. This makes a scoped session.
revisionstr or NoneNoneReads the sources files from this Git revision instead of the working tree. Requires sources.

The constructor loads the native module but does not start the session. The session starts on the first method call, or when a with block starts. Leaving the with block calls close().

Session modes:

ModeHow to select itFile changesIndex build
WatcheddefaultA file watcher applies changes before each query.On first use.
Manualmanual=TrueOnly update_paths(...) and refresh() apply changes.When the session starts.
Scopedsources=[...], optionally revision=...Only update_paths(...) and refresh() apply changes. Scoped sessions are always manual.When the session starts.

All three modes use the repository’s persisted analyzer cache. A scoped session shares stored file facts with the full workspace but keeps its own file list. Cross-file results from a scoped session carry session_subset (a SessionSubset with the field files). session_subset is None when the session covers the whole workspace.

Each sources entry is a project-relative file, directory, or glob. Session start fails with SearchToolsError when a path does not exist, a directory has no analyzer-visible files, or a glob matches no files. With revision, the client reads each selected file from that revision and skips binary files.

Constructor errors:

ConditionException
sources and manual=True togetherValueError
revision without sourcesValueError
Native module cannot be imported or loadedSearchToolsError
A different library_path is already loaded in this processSearchToolsError
MethodReturnsMeaning
close() -> NoneNoneCloses the native session. Later calls raise SearchToolsError("SearchToolsClient is closed"). Calling close() again does nothing.
gc() -> NoneNoneForces a Git-reachability garbage collection of the persisted analyzer cache and waits until it finishes.
refresh() -> RefreshResultRefreshResultRescans the project from disk and re-analyzes it.
update_paths(paths: list[str]) -> RefreshResultRefreshResultRe-analyzes only the given project-relative paths. Use it with a manual or scoped session.
activate_workspace(workspace_path: Path | str) -> WorkspaceResultWorkspaceResultSwitches the session to another project root.
get_active_workspace() -> WorkspaceResultWorkspaceResultReturns the current project root.

Each method calls the Bifrost tool with the same name, unless the Notes column says otherwise. The tool’s own limits and argument rules are listed in the MCP tools reference. Parameters after * are keyword-only. kind_filter and ranking_mode take enum members, not plain strings.

SignatureReturnsNotes
search_symbols(patterns: list[str], *, include_tests: bool = False, limit: int = 20)SearchSymbolsResult
get_symbol_locations(symbols: list[str], *, kind_filter: SymbolKindFilter = SymbolKindFilter.ANY)SymbolLocationsResult
get_symbol_ancestors(symbols: list[str], *, kind_filter: SymbolKindFilter = SymbolKindFilter.CLASS)SymbolAncestorsResultThe default filter is CLASS, not ANY.
get_symbol_sources(symbols: list[str], *, kind_filter: SymbolKindFilter = SymbolKindFilter.ANY)SymbolSourcesResult
get_summaries(targets: list[str])FileSummariesResultDirectory and package targets return entries in listings. A glob that matches too many files is reported in too_broad, and an ambiguous path in ambiguous_paths.
list_symbols(file_patterns: list[str])SkimFilesResultNot exposed to MCP agents.
classify_test_files(file_paths: list[str])dict[str, dict[str, Any]]Maps each resolved path to {"kind": ..., "contains_test_code": bool}. kind is test, test_support, production, or ambiguous. Inputs that do not resolve to exactly one file are left out. Not exposed to MCP agents.
SignatureReturnsNotes
get_declarations_by_location(references: list[dict[str, Any]])list[DeclarationLookupResult]Each reference is {"path": str, "line": int, "column": int}. line and column are 1-based.
get_definitions_by_location(references: list[dict[str, Any]])list[DefinitionLookupResult]Same reference shape.
get_definitions_by_reference(references: list[dict[str, str]])list[DefinitionByReferenceLookupResult]Each reference is {"symbol": str, "context": str, "target": str}: copied source context and the target token.
get_type_by_location(path: str, *, line: int | None = None, column: int | None = None)TypeLookupResultSends one reference and returns its single result.
rename_symbol(path: str, *, new_name: str, line: int, column: int)RenameSymbolResultReturns the edit set. It does not change files. line and column are 1-based and required.
SignatureReturnsNotes
scan_usages_by_reference(symbols: list[str], *, include_tests: bool = False, include_same_owner: bool = False, paths: list[str] | None = None)ScanUsagesResultpaths narrows where usages are searched. include_same_owner lists the same-owner sites (self/this receivers and own-type static calls) that are otherwise only counted in same_owner_sites.
scan_usages_by_location(targets: list[dict[str, Any]], *, include_tests: bool = False, include_same_owner: bool = False, paths: list[str] | None = None)ScanUsagesResultEach target is {"path": str, "line": int, "column": int (optional), "symbol": str (optional)}. include_same_owner is as for scan_usages_by_reference.
usage_graph(*, include_tests: bool = False, paths: list[str] | None = None, depth: int = 1)UsageGraphResultdepth below 1 raises ValueError. Without paths, every declaration is a root.
most_relevant_files(seed_files: list[str], *, limit: int = 20, seed_weights: list[float] | None = None, recency_half_life: float | None = <unset>, ranking_mode: MostRelevantFilesRankingMode = MostRelevantFilesRankingMode.CASCADE)MostRelevantFilesResultSends seed_files as the tool argument seed_file_paths. recency_half_life is a Git recency half-life in commits. Omit it for the default of 250 commits. Pass None for uniform weighting.

With both target and base omitted, the diff runs from the merge base of HEAD and the default branch named by origin/HEAD to the live working tree. An explicit commit target without base compares that commit with its first parent.

SignatureReturnsNotes
analyze_diff(target: str | None = None, *, base: str | None = None, include_tests: bool = True)DiffAnalysisResultThe default for include_tests is True.
blast_radius(target: str | None = None, *, base: str | None = None, max_scopes: int | None = None)BlastRadiusResult
cyclomatic_complexity(target: str | None = None, *, base: str | None = None, include_tests: bool = False)CyclomaticComplexityDiffResult
missing_tests(target: str | None = None, *, base: str | None = None)MissingTestsResult
query_code(
pattern: dict[str, Any] | None = None,
*,
occurrences: dict[str, Any] | None = None,
scopes: dict[str, Any] | None = None,
bindings: dict[str, Any] | None = None,
generation_sites: dict[str, Any] | None = None,
exports: dict[str, Any] | None = None,
dependency_evidence: dict[str, Any] | None = None,
configuration_facts: dict[str, Any] | None = None,
correlate: dict[str, Any] | None = None,
require_both: dict[str, Any] | None = None,
paths: dict[str, Any] | None = None,
union: list[dict[str, Any]] | None = None,
intersect: list[dict[str, Any]] | None = None,
except_: list[dict[str, Any]] | None = None,
query_file: str | None = None,
inside: dict[str, Any] | None = None,
inside_decl: dict[str, Any] | None = None,
not_inside: dict[str, Any] | None = None,
where: list[str] | None = None,
languages: list[str] | None = None,
steps: list[dict[str, Any]] | None = None,
limit: int | None = None,
result_detail: str | None = None,
schema_version: int | None = None,
execution_mode: CodeQueryExecutionMode | None = None,
) -> CodeQueryResponse
ParameterTool fieldMeaning
patternmatchStructural pattern source.
occurrences, scopes, bindings, generation_sites, exports, dependency_evidence, configuration_facts, pathssameRoot source objects. Each takes the filter fields of its source. The Code Query reference lists them.
correlate, require_bothsameCross-domain sources. correlate pairs code and configuration rows through a registered relation. require_both requires both inputs to produce rows, without pairing them.
union, intersect, except_union, intersect, exceptSet sources. Each operand is a complete CodeQuery plan dictionary.
query_filequery_fileWorkspace-relative .rql or .json file that holds the complete query. It is exclusive: pass no other query argument with it.
inside, inside_decl, not_insidesameStructural scope. Valid only with pattern.
wherewhereProject-relative globs or absolute paths inside the workspace. Applies to every source.
languageslanguagesLanguage filter. Not valid with dependency_evidence or configuration_facts, which have no programming-language axis.
stepsstepsSemantic steps that run after the source.
limitlimitMaximum terminal results. The tool default is 100 and the maximum is 1000.
result_detailresult_detail"compact" (tool default) or "full".
schema_versionschema_versionOptional. 1 is the only accepted value.
execution_modeexecution_mode"results" (default), "explain", or "profile".

query_code raises ValueError when:

  • the call gives no query source, or more than one, and no query_file;
  • query_file is given with any other query argument;
  • execution_mode is not "results", "explain", or "profile".

The engine rejects other invalid arguments, such as inside with a non-pattern source or languages with configuration_facts. Those raise ValueError with the engine’s message.

The return type depends on execution_mode: CodeQueryResult for "results", CodeQueryExplain for "explain", and CodeQueryProfile for "profile".

The complete source and step vocabulary is in the Code Query reference.

The taint, typestate, and value_flow steps read results that a host registered in the same process. Only the Rust SearchToolsService can register them (see the Rust API reference). The Python client has no registration method, so from Python these steps always return an unresolved_*_reference diagnostic and no rows.

SignatureReturnsNotes
get_file_contents(file_paths: list[str])GetFileContentsResultPaths are project-relative or absolute inside the workspace.
search_file_contents(patterns: list[str], *, file_path: str | None = None, context_lines: int | None = None, case_insensitive: bool = False)SearchFileContentsResultpatterns are regular expressions. file_path is a glob, or an absolute path or glob inside the workspace.
find_files_containing(patterns: list[str], *, limit: int | None = None, case_insensitive: bool = False)FindFilesContainingResultpatterns are regular expressions.

Every method in this group returns CodeQualityReport. options is a dictionary whose keys are merged into the tool arguments unchanged. The accepted keys for each tool are listed in the MCP tools reference.

SignatureNotes
compute_cyclomatic_complexity(file_paths: list[str], *, threshold: int | None = None)Per-function cyclomatic complexity. Flags functions above threshold.
compute_cognitive_complexity(file_paths: list[str], *, threshold: int | None = None)Per-function cognitive complexity. Flags functions above threshold.
report_comment_density_for_code_unit(fq_name: str, *, max_lines: int | None = None)Comment density for one symbol, named by fully qualified name.
report_comment_density_for_files(file_paths: list[str], *, max_top_level_rows: int | None = None, max_files: int | None = None)Comment density tables for files.
report_exception_handling_smells(file_paths: list[str], *, min_score: int | None = None, max_findings: int | None = None, options: dict[str, Any] | None = None)Generic, empty, or log-only exception handlers.
report_test_assertion_smells(file_paths: list[str], *, min_score: int | None = None, max_findings: int | None = None, options: dict[str, Any] | None = None)Weak or brittle test assertions.
report_structural_clone_smells(file_paths: list[str], *, min_score: int | None = None, max_findings: int | None = None, options: dict[str, Any] | None = None)Structural clones.
report_long_method_and_god_object_smells(file_paths: list[str], *, max_findings: int | None = None, max_files: int | None = None, options: dict[str, Any] | None = None)Oversized functions, classes, and modules.
report_dead_code_and_unused_abstraction_smells(*, file_paths: list[str] | None = None, fq_names: list[str] | None = None, min_score: int | None = None, max_findings: int | None = None, options: dict[str, Any] | None = None)Likely dead declarations and single-use abstractions. With no file_paths, the client sends an empty list and the tool finds candidates itself.
report_secret_like_code(*, max_findings: int | None = None, max_commits: int | None = None, include_history_only: bool = False, include_low_confidence: bool = False)Secret-like strings in current files and Git history. Values are redacted.
analyze_git_hotspots(*, since_days: int | None = None, since_iso: str | None = None, until_iso: str | None = None, max_commits: int | None = None, max_files: int | None = None)Commit churn combined with complexity. since_iso overrides since_days.

The client has no general-purpose tool call. These MCP tools have no Python method:

MCP toolUse instead
score_diffThe CLI (bifrost --tool score_diff), MCP, or Rust SearchToolsService.
list_policiesThe CLI (bifrost --list-policies or bifrost --tool list_policies), MCP, or Rust.
run_policyThe CLI (bifrost --policy ... or bifrost --tool run_policy), MCP, or Rust.
explain_policyThe CLI (bifrost --tool explain_policy), MCP, or Rust.

These Python methods have no MCP tool in the default toolsets:

Python methodAvailability
list_symbolsCLI --tool, Rust, and Python only. MCP uses it internally to shorten oversized get_summaries responses.
classify_test_filesCLI --tool, Rust, and Python only.
update_pathsCLI --tool, Rust, and Python only.
get_definitions_by_reference, scan_usages_by_referenceMCP advertises these only when the server runs with --no-line-numbers, in place of get_definitions_by_location, get_declarations_by_location, and scan_usages_by_location.
SignatureReturnsMeaning
tool_descriptors(toolset: str = "core", *, render_line_numbers: bool = True, library_path: Path | str | None = None)list[dict[str, Any]]The MCP tool descriptors (name, description, input schema) for toolset. Valid toolsets are core, searchtools, symbol, workspace, diff, extended, text, slopcop, and |-joined combinations such as "symbol|text". An unknown toolset raises ValueError.
code_query_variant_inventory(*, library_path: Path | str | None = None)dict[str, list[str]]The keys are result_types, diagnostic_codes, diagnostic_impacts, and completion_kinds. Each list is read from the loaded native build. Compare it with the Python models to detect a client that is older than the engine.
extensions_for_paths(paths: list[str], *, library_path: Path | str | None = None)list[str]Every file extension of every language present in paths, including extensions that the language reads for references only (for example .vue and .svelte for TypeScript). Sorted. Opens no workspace. Use it to build sources for a scoped session.
parse_code_query_response(data: dict[str, Any], rendered_text: str | None = None)CodeQueryResponseDecodes a query_code structured payload. Returns CodeQueryExplain or CodeQueryProfile when data["format"] names one of them, and CodeQueryResult otherwise.
ExceptionWhen
SearchToolsErrorEvery failure inside the native module except invalid arguments: unknown tools, deadlines, internal errors, session start failures, cache collection failures, and calls after close(). The message is the engine’s message.
ValueErrorArgument checks in the Python client: the constructor rules, the query_code rules, usage_graph(depth < 1), and an unknown toolset in tool_descriptors. Also invalid tool arguments that the engine rejects, and stale workspace generations. The message is the engine’s message.
AttributeErrorA plain string passed as kind_filter or ranking_mode. Pass the enum member.

All enums are StrEnum subclasses, so each member compares equal to its string value.

EnumValues
SymbolKindFilterANY = "any", CLASS = "class", FUNCTION = "function", FIELD = "field", MODULE = "module"
MostRelevantFilesRankingModeCASCADE = "cascade", HISTORY_IMPORTS = "history_imports", USAGE_GRAPH = "usage_graph", USAGE_GRAPH_EXACT = "usage_graph_exact". See the table below.
NavigationOperationdeclaration, definition
ContainerKinddirectory, package
CodeQueryDiagnosticImpactadvisory, declared_non_exhaustive, incomplete, invalid
CodeQueryCompletionKindcomplete, proven_subset, incomplete, cancelled, invalid
CodeQueryDiagnosticCode99 diagnostic codes. The list and meanings are in the Code Query reference. code_query_variant_inventory()["diagnostic_codes"] prints the live list.
CodeQuerySemanticProofproven, unproven
CodeQuerySemanticCompletenesscomplete, partial
CodeQueryFlowCertaintyexact, may
CodeQueryFlowStatuscomplete, partial, ambiguous, unknown, unproven, unsupported, semantic_budget_exhausted, solver_budget_exhausted, semantic_cancelled, solver_cancelled, query_cancelled
CodeQueryFlowReachabilityreached, not_reached, inconclusive
CodeQueryAbsentMemberWitnessStatusavailable, truncated, unavailable
CodeQueryClassSetStatusknown, partial, no_information, inconclusive
CodeQueryTypestateCertaintymay, must, inconclusive
CodeQueryTypestateFindingKindTypeerror_transition, terminal_expectation
CodeQueryTypestateUncertaintyambiguous_dispatch, unknown_call, external_call, escape, incomplete_analysis, unmatched_event
CodeQueryTypestateWitnessStepKindTypeseed, edge, end_summary_gap
CodeQueryProgramPointBoundaryentry, normal_exit, exceptional_exit
CodeQueryLogicalOperationKindseed, step, set, limit
CodeQueryPhysicalOperatorseed_scan, pipeline_step, sequential_union, parallel_union, sequential_intersection, sequential_except, limit
CodeQuerySchedulingPolicyauto
CodeQuerySelectedSchedulingsequential, parallel
CodeQueryOperatorDispositioncompleted, skipped, cancelled
CodeQueryOperatorTerminationcancellation_before_work, cancellation_during_work, dependency_cancelled, dependency_pipeline_halted, terminal_cap, result_limit, execution_budget, pipeline_budget, import_graph_budget, analysis_limit, unsupported_analysis, analysis_incomplete
CodeQueryCacheLayerKindseed_result, seed_structural_facts, inbound_reference, outbound_reference, incoming_call, outgoing_call, import_forward, import_reverse, direct_import_topology
CodeQueryCacheMetricsKindcomplete_value, structural_facts

MostRelevantFilesRankingMode values:

ValueRanking
cascadeDefault. Priority tiers over test and source mirrors, shared base names, Git co-edits, directory membership, and import adjacency. Works in a repository with no usable Git history.
history_importsGit co-edit history first, then import adjacency fills the remaining slots.
usage_graphPageRank over the fast structured file graph. The history_imports ranking fills the remaining slots.
usage_graph_exactRanking over the exact symbol-level caller-to-callee graph. The history_imports ranking fills the remaining slots.

If a usage graph build is cancelled or exceeds the interactive time budget, the result has complete=False, an incomplete_reason, and the history_imports ranking.

Some result fields use a Literal type instead of an enum:

Type alias (in bifrost_searchtools.models)Values
CodeQueryExecutionMode (exported)results, explain, profile
MostRelevantFilesIncompleteReasonValuecancelled, time_budget
SymbolSourcesIncompleteReasonValuecancelled
DefinitionLookupIncompleteReasonValue (models only)cancelled, time_budget, resolution_budget, analysis_failure, structure_unavailable, navigation_targets
TooBroadMatchValue (models only)files, declarations
TestFileKindValuetest, test_support, production, ambiguous
FileGraphCompletionValuecomplete, incomplete
BlastRadiusBaseRecoveryValuenot_needed, complete, cancelled
BlastRadiusIncompleteReasonValuetarget_graph_cancelled, base_graph_cancelled, compilation_scope_unresolved, unresolved_changed_paths, unresolved_base_paths
BlastRadiusCallableChangeValueedited, introduced, deleted, moved, signature_changed
BlastRadiusScopeKindValuefile, directory
MissingTestsModeValue (exported)file_imports_then_exact_usages, file_graph_narrowed_binding_reachability
MissingTestsIncompleteReasonValue (exported)target_graph_cancelled, compilation_scope_unresolved, unresolved_changed_path, changed_function_unresolved, usage_cancelled, usage_time_budget, usage_candidate_files, usage_source_bytes, usage_callsites, usage_response_budget, usage_resolution_candidates, usage_target_not_found, usage_target_ambiguous, usage_analysis_failure, usage_analysis_incomplete, unproven_references, usage_site_without_enclosing_declaration, unresolved_changed_target, open_binding_frontier, unsupported_binding_boundary, unproven_binding_edge, reference_graph_cancelled, reference_graph_stale
CyclomaticComplexityChangeValue (exported)introduced, edited
MostRelevantFilesRankingModeValuecascade, history_imports, usage_graph, usage_graph_exact

All result classes are frozen dataclasses. A class with render_text() returns readable text. When the engine rendered the text, render_text() returns that text unchanged. A class with a count property returns the number of items in its main list.

ClassReturned byrender_text()Fields
RefreshResultrefresh, update_pathsyeslanguages: list[str], analyzed_files: int, declarations: int
WorkspaceResultactivate_workspace, get_active_workspaceyesworkspace_path: str, session_subset: SessionSubset | None
SearchSymbolsResultsearch_symbolsyes, countpatterns: list[str], truncated: bool, total_files: int, files: list[SearchSymbolsFile], session_subset: SessionSubset | None
SymbolLocationsResultget_symbol_locationsyes, countlocations: list[SymbolLocation], not_found: list[str]
SymbolAncestorsResultget_symbol_ancestorsyes, countancestors: list[SymbolAncestors], not_found: list[str], ambiguous: list[AmbiguousSymbol]
SymbolSourcesResultget_symbol_sourcesyes, countsources: list[SourceBlock], not_found: list[str], ambiguous: list[AmbiguousSymbol], complete: bool, incomplete: list[SymbolSourcesIncomplete]
FileSummariesResult (alias of SymbolSummariesResult)get_summariesyes, countsummaries: list[SummaryBlock], listings: list[ContainerListing], compact_symbols: SkimFilesResult | None, not_found: list[str], ambiguous: list[AmbiguousSymbol], ambiguous_paths: list[AmbiguousPath], too_broad: list[TooBroadScope]
SkimFilesResultlist_symbolsyes, counttruncated: bool, total_files: int, files: list[SkimFile]
DeclarationLookupResultget_declarations_by_location (one per reference)yesquery: dict, operation: NavigationOperation, status: str, complete: bool, incomplete_reason: DefinitionLookupIncompleteReasonValue | None, reference: DefinitionReferenceSite | None, declarations: list[DefinitionCandidate], diagnostics: list[DefinitionDiagnostic]
DefinitionLookupResultget_definitions_by_location (one per reference)yesquery: dict, operation: NavigationOperation, status: str, complete: bool, incomplete_reason: DefinitionLookupIncompleteReasonValue | None, reference: DefinitionReferenceSite | None, definitions: list[DefinitionCandidate], diagnostics: list[DefinitionDiagnostic]
DefinitionByReferenceLookupResultget_definitions_by_reference (one per reference)yesquery: dict, status: str, complete: bool, incomplete_reason: DefinitionLookupIncompleteReasonValue | None, definitions: list[DefinitionCandidate], diagnostics: list[DefinitionDiagnostic]
TypeLookupResultget_type_by_locationyesquery: dict, status: str, reference: DefinitionReferenceSite | None, types: list[TypeLookupCandidate], diagnostics: list[DefinitionDiagnostic]
RenameSymbolResultrename_symbolyesquery: dict, status: str, target: RenameSymbolTarget | None, old_name: str | None, edits: list[RenameFileEdits], diagnostics: list[DefinitionDiagnostic]
ScanUsagesResultscan_usages_by_reference, scan_usages_by_locationyesstructured: dict, the tool’s JSON result without a typed model. rendered_text: str | None.
UsageGraphResultusage_graphyesnodes: list[UsageGraphNode], edges: list[UsageGraphEdge], truncated_symbols: list[UsageGraphTruncatedSymbol], session_subset: SessionSubset | None
MostRelevantFilesResultmost_relevant_filesyes, countfiles: list[MostRelevantFile], not_found: list[str], duplicates: list[str], complete: bool, ranking_mode_used: str, incomplete_reason: str | None (cancelled or time_budget), session_subset: SessionSubset | None
DiffAnalysisResultanalyze_diffnoendpoints: DiffEndpoints, file_changes: list[FileChange], patch_symbols: PatchSymbols, dependency_symbols: list[CommitSymbol], import_changes: list[ImportChange], unattributed_call_edge_changes: list[CallEdgeChange], large_callsite_symbols: list[LargeCallsiteSymbol]
BlastRadiusResultblast_radiusyesendpoints: DiffEndpoints, analysis: BlastRadiusAnalysis, changed_callables: list[ChangedCallable], test_scopes: list[TestScope]
CyclomaticComplexityDiffResultcyclomatic_complexityyesendpoints: DiffEndpoints, summary: CyclomaticComplexitySummary, functions: list[CyclomaticComplexityChange], analysis: CyclomaticComplexityAnalysis
MissingTestsResultmissing_testsyesendpoints: DiffEndpoints, analysis: MissingTestsAnalysis, missing_functions: list[MissingTestFunction], indeterminate_functions: list[MissingTestFunction]
GetFileContentsResultget_file_contentsno, countfiles: list[FileContent], not_found: list[str], ambiguous_paths: list[AmbiguousPath]
SearchFileContentsResultsearch_file_contentsno, countmatches: list[FileMatchGroup], truncated: bool, invalid_patterns: list[str], ambiguous_paths: list[AmbiguousPath]
FindFilesContainingResultfind_files_containingno, countfiles: list[str], truncated: bool, invalid_patterns: list[str]
CodeQualityReportall code-quality methodsyesreport: str (the engine’s rendered report), truncated: bool, ambiguous_paths: list[AmbiguousPath]. str(report) returns report.

Result classes that hold a rendered-text field also carry rendered_text: str | None. Classes that render line numbers also carry render_line_numbers: bool. These two fields are omitted from the table.

complete is False only when the engine reports the lookup as incomplete, and incomplete_reason then names the cause. Read status and diagnostics for detail.

Fields that the Rust result reports but the Python model drops:

  • FileSummariesResult.compact_symbols is always None for Python callers. Only the MCP server replaces oversized summaries with a compact symbol list.

status on the navigation results is an open string set. Current values are resolved, no_definition, no_declaration, unresolvable_import_boundary, ambiguous, unsupported_language, invalid_location, not_found, incomplete, cancelled, and exceeded_budget.

ClassFields
SessionSubsetfiles: int, the number of files in the scoped session.
AmbiguousSymboltarget: str, matches: list[str]
AmbiguousPathinput: str, matches: list[str]
TooBroadScopetarget: str, matched: int, cap: int, matched_kind: str (files or declarations), sample: list[str], note: str
SearchSymbolsFilepath: str, loc: int, classes, functions, fields, modules (each list[SearchSymbolHit])
SearchSymbolHitsymbol: str, signature: str, line: int
SymbolLocationsymbol: str, path: str, loc: int, start_line: int, end_line: int
SymbolAncestorssymbol: str, ancestors: list[str]
SymbolSourcesIncompletetarget: str, reason: str (cancelled)
SourceBlocklabel: str, path: str, start_line: int, end_line: int, text: str
SummaryBlocklabel: str, path: str, preamble: str, elements: list[SummaryElement]
SummaryElementpath: str, symbol: str, kind: str, start_line: int, end_line: int, text: str, parent_symbol: str | None
ContainerListingtarget: str, kind: ContainerKind, languages: list[str], entries: list[ContainerListingEntry], total_entries: int, truncated: bool
ContainerListingEntryUnion of the four entry classes below. Each has a class attribute kind.
DirectoryListingEntrykind = "directory". name: str, path: str
FileListingEntrykind = "file". name: str, path: str
PackageListingEntrykind = "package". name: str, qualified_name: str, languages: list[str]
TypeListingEntrykind = "type". name: str, symbol: str, language: str, path: str, start_line: int, end_line: int
SkimFilepath: str, loc: int, lines: list[str]
DefinitionReferenceSitepath: str, target: str
DefinitionCandidatename: str, fqn: str | None, path: str, start_line: int, start_column: int | None, end_line: int, end_column: int | None, kind: str, signature: str | None, language: str
DefinitionDiagnostickind: str, message: str
TypeLookupCandidatefqn: str, kind: str | None, language: str | None, definitions: list[DefinitionCandidate]
RenameSymbolTargetsymbol: str, kind: str, path: str
RenameFileEditspath: str, edits: list[RenameTextEdit]
RenameTextEditold_text: str, start_line: int, start_column: int, end_line: int, end_column: int, new_text: str
UsageGraphNodefqn: str, language: str, path: str, start_line: int, kind: str, signature: str | None
UsageGraphEdgefrom_fqn: str, to_fqn: str, language: str, weight: int, sites: list[UsageGraphCallSite]. len(sites) == weight.
UsageGraphCallSitepath: str, line: int
UsageGraphTruncatedSymbolfqn: str, language: str, total_callsites: int, limit: int
MostRelevantFilepath: str, test: str (test, test_support, production, or ambiguous)
DiffEndpointsbase: str, target: str
FileChangeold_path: str | None, path: str | None, status: str, insertions: int, deletions: int, is_binary: bool, is_test: bool, is_parseable: bool
PatchSymbolsedited: list[EditedSymbolPair], introduced: list[IntroducedSymbol], deleted: list[DeletedSymbol], moved: list[MovedSymbol], signature_changes: list[SignatureChange]
CommitSymbolfqn: str, name: str, kind: str, signature: str, path: str, start_line: int, end_line: int, language: str, is_test: bool
EditedSymbolPairbefore: CommitSymbol, after: CommitSymbol, touched_old_lines: list[int], touched_new_lines: list[int], added_calls: list[CalleeChange], removed_calls: list[CalleeChange]
IntroducedSymbolafter: CommitSymbol, touched_new_lines: list[int], calls: list[CalleeChange]
DeletedSymbolbefore: CommitSymbol, touched_old_lines: list[int], called: list[CalleeChange]
MovedSymbolbefore: CommitSymbol, after: CommitSymbol, added_calls: list[CalleeChange], removed_calls: list[CalleeChange]
SignatureChangebefore: CommitSymbol, after: CommitSymbol
CalleeChangeto_fqn: str, language: str, weight: int, sites: list[UsageGraphCallSite]
CallEdgeChangechange: str, from_fqn: str, to_fqn: str, language: str, weight: int, sites: list[UsageGraphCallSite]
ImportChangepath: str, added: list[str], removed: list[str]
LargeCallsiteSymbolfqn: str, language: str, total_callsites: int, limit: int
BlastRadiusAnalysismode: str (file_imports), graph_completion: str, base_recovery: str, reached_test_file_count: int, paths_outside_file_graph: list[str], analyzer_changed_test_paths: list[str], unresolved_changed_paths: list[str], unavailable_removed_test_count: int, incomplete_reasons: list[str]
ChangedCallablebefore: BlastRadiusCallableSymbol | None, after: BlastRadiusCallableSymbol | None, changes: list[str]
BlastRadiusCallableSymbolfqn: str, name: str, kind: str, signature: str, path: str, start_line: int, end_line: int, language: str, in_test_context: bool
TestScopepath: str, kind: str (file or directory), reached_file_count: int, covered_analyzable_file_count: int, minimum_dependency_distance: int, maximum_dependency_distance: int, sample_reached_files: list[str]
CyclomaticComplexitySummaryintroduced: int, edited: int, increased: int, decreased: int, unchanged: int
CyclomaticComplexityChangechange: str (introduced or edited), before: CyclomaticComplexityFunction | None, after: CyclomaticComplexityFunction, delta: int | None
CyclomaticComplexityFunctionfqn: str, name: str, signature: str, path: str, start_line: int, end_line: int, language: str, is_test: bool, complexity: int
CyclomaticComplexityAnalysispaths_outside_analysis: list[str], unresolved_changed_paths: list[str]
MissingTestsAnalysismode: str, file_graph_completion: str, exact_usage_completion: str, candidate_function_count: int, reached_function_count: int, missing_function_count: int, indeterminate_function_count: int, paths_outside_file_graph: list[str], unresolved_changed_paths: list[str], incomplete_reasons: list[str]
MissingTestFunctionbefore: BlastRadiusCallableSymbol | None, after: BlastRadiusCallableSymbol, changes: list[str], incomplete_reasons: list[str]
FileContentpath: str, content: str, truncated: bool, total_lines: int | None, head_lines: int | None, tail_lines: int | None
FileMatchGrouppath: str, matches: list[LineMatch], truncated: bool
LineMatchline: int, text: str, before: list[str], after: list[str]
JqFileResultpath: str, matches: list[str], truncated: bool, error: str | None
XmlSelectFilepath: str, matches: list[str], error: str | None
XmlSkimFilepath: str, elements: list[XmlSkimElement], error: str | None
XmlSkimElementtag: str, depth: int, attribute_count: int

JqFileResult, XmlSelectFile, XmlSkimFile, and XmlSkimElement are exported, but no current client method returns them.

ClassReturned forFields
CodeQueryResultexecution_mode="results"results: list[CodeQueryResultItem], diagnostics: list[CodeQueryDiagnostic], truncated: bool, session_subset: SessionSubset | None, rendered_text: str | None
CodeQueryExplainexecution_mode="explain"format: str, query_schema_version: int, parsed_query, logical_plan: CodeQueryLogicalPlan, physical_plan, scheduling: CodeQueryExplainScheduling, rendered_text, extra: dict
CodeQueryProfileexecution_mode="profile"format: str, result: CodeQueryResult, explain: CodeQueryExplain, timings_ns, work, cache_layers: list, access_path: CodeQueryAccessPathProfile, scheduling, operators: list[CodeQueryOperatorObservation], rendered_text, extra: dict
CodeQueryDiagnosticinside every resultcode: CodeQueryDiagnosticCode, impact: CodeQueryDiagnosticImpact, message: str, language: str, branch: list[int], exhausted_roots: list

CodeQueryResponse is the type alias CodeQueryResult | CodeQueryExplain | CodeQueryProfile. CodeQueryResultItem is the union of the 75 row classes in the next table. The profile and explain report formats are described in Explain and Profile CodeQuery.

Each row in CodeQueryResult.results is an instance of the class that matches its result_type. The mapping comes from bifrost_searchtools._generated_query_models.CODE_QUERY_RESULT_ITEM_TYPES. The fields of each row type are listed in the Code Query reference. In Python, dataclasses.fields(cls) lists them for any class.

“Top level” means from bifrost_searchtools import <class> works. “Models only” means you must import the class from bifrost_searchtools.models.

result_typePython classImport
structural_matchCodeQueryMatch (alias of CodeQueryStructuralMatch)top level
declarationCodeQueryDeclarationtop level
procedureCodeQueryProceduretop level
program_pointCodeQueryProgramPointtop level
control_edgeCodeQueryControlEdgetop level
typestate_findingCodeQueryTypestateFindingtop level
typestate_witnessCodeQueryTypestateWitnesstop level
flow_endpointCodeQueryFlowEndpointtop level
flow_witnessCodeQueryFlowWitnesstop level
class_set_rowCodeQueryClassSetRowtop level
absent_member_findingCodeQueryAbsentMemberFindingtop level
absent_member_witnessCodeQueryAbsentMemberWitnesstop level
taint_findingCodeQueryTaintFindingtop level
fileCodeQueryFiletop level
configuration_factCodeQueryConfigurationFacttop level
reference_siteCodeQueryReferenceSitetop level
call_siteCodeQueryCallSitetop level
expression_siteCodeQueryExpressionSitetop level
jsx_attribute_valueCodeQueryJsxAttributeValuetop level
receiver_analysisCodeQueryReceiverAnalysistop level
member_target_analysisCodeQueryMemberTargetAnalysistop level
receiver_outcomeCodeQueryReceiverOutcometop level
receiver_evidenceCodeQueryReceiverEvidencetop level
field_write_valueCodeQueryFieldWriteValuetop level
keyed_read_valueCodeQueryRuntimeKeyedReadValue (alias of CodeQueryKeyedReadValue)top level
call_shapeCodeQueryCallShapetop level
call_resultCodeQueryCallResulttop level
call_argument_groupCodeQueryCallArgumentGrouptop level
call_argumentCodeQueryCallShapeArgumenttop level
call_bindingCodeQueryCallBindingtop level
call_effectCodeQueryCallEffecttop level
call_result_contractCodeQueryCallResultContracttop level
call_result_obligationCodeQueryCallResultObligationtop level
result_subject_useCodeQueryResultSubjectUsetop level
result_contract_useCodeQueryResultContractUsetop level
result_contract_failure_useCodeQueryResultContractFailureUsetop level
nilness_operationCodeQueryNilnessOperationtop level
switch_coverageCodeQuerySwitchCoveragetop level
assignment_relationCodeQueryAssignmentRelationtop level
detached_task_transferCodeQueryDetachedTaskTransfertop level
procedure_effectCodeQueryProcedureEffecttop level
callable_signatureCodeQueryCallableSignaturetop level
signature_parameterCodeQuerySignatureParametertop level
decorated_parameterCodeQueryDecoratedParametertop level
callable_applicabilityCodeQueryCallableApplicabilitytop level
overload_selectionCodeQueryOverloadSelectiontop level
member_selectionCodeQueryMemberSelectiontop level
dispatch_outcomeCodeQueryDispatchOutcometop level
dispatch_targetCodeQueryDispatchTargettop level
member_familyCodeQueryMemberFamilytop level
member_family_edgeCodeQueryMemberFamilyEdgetop level
occurrenceCodeQueryOccurrencetop level
lexical_scopeCodeQueryLexicalScopetop level
bindingCodeQueryBindingtop level
resolution_candidateCodeQueryResolutionCandidatetop level
candidate_hopCodeQueryCandidateHoptop level
generation_siteCodeQueryGenerationSitetop level
exportCodeQueryExporttop level
declaration_stateCodeQueryDeclarationStatetop level
reference_edgeCodeQueryReferenceEdgetop level
state_eventCodeQueryStateEventtop level
flow_relationCodeQueryFlowRelationtop level
control_relationCodeQueryControlRelationtop level
branch_relationCodeQueryBranchRelationtop level
loop_relationCodeQueryLoopRelationtop level
failure_handler_stateCodeQueryFailureHandlerStatetop level
statement_reachabilityCodeQueryStatementReachabilitytop level
guardCodeQueryGuardtop level
rewrite_pathCodeQueryRewritePathtop level
qualified_pathCodeQueryQualifiedPathtop level
path_segmentCodeQueryPathSegmenttop level
source_setCodeQuerySourceSettop level
build_targetCodeQueryBuildTargettop level
topology_edgeCodeQueryTopologyEdgetop level

code_query_variant_inventory()["result_types"] returns the same 75 labels from the loaded native build. If the engine emits a result_type that the Python models do not know, decoding raises ValueError.