1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! `Commands::Query` routing — extracted from `command_routing.rs` for CB-040 file health.
//!
//! Owns the full 50-field `Query` dispatch: contract delegations, gaps, asset
//! contracts, and the mainline `handle_query` call.
#![cfg_attr(coverage_nightly, coverage(off))]
use super::CommandDispatcher;
use crate::cli::commands::Commands;
use crate::cli::handlers;
impl CommandDispatcher {
/// Route `Commands::Query` to the appropriate query handler.
pub(super) async fn route_query_command(command: Commands) -> anyhow::Result<()> {
let Commands::Query {
query,
limit,
min_grade,
max_complexity,
language,
path,
project_path,
format,
include_source,
rebuild_index,
exclude_tests,
rank_by,
min_pagerank,
include_project,
churn,
duplicates,
entropy,
faults,
coverage,
uncovered_only,
coverage_diff,
coverage_file,
coverage_gaps,
include_excluded,
definition_type,
summary,
git_history,
regex,
literal,
search_mode,
raw,
case_sensitive,
ignore_case,
exclude,
exclude_file,
files_with_matches,
count,
after_context,
before_context,
context_lines,
ptx_flow,
ptx_diagnostics,
suggest_rename,
apply,
no_docs,
docs_only,
extract_candidates,
max_module_lines,
contracts,
contract_gaps,
min_level,
max_level,
contract_score,
asset_contracts,
} = command
else {
unreachable!("route_query_command called with non-Query variant");
};
// Delegate to pv query for contract searches
if contracts {
return crate::cli::command_dispatcher::contract_query_handlers::handle_pv_query_delegation(&query, limit, &format);
}
// Contract gaps: show functions without bindings
if contract_gaps {
return crate::cli::command_dispatcher::contract_query_handlers::handle_contract_gaps(
&project_path,
limit,
&format,
);
}
// Asset contracts: validate non-code assets
if asset_contracts {
return crate::cli::command_dispatcher::contract_query_handlers::handle_asset_contracts(
&project_path,
&format,
);
}
// min-level/max-level/contract-score require ContractIndex integration
// into the query pipeline — not yet implemented. Error explicitly.
if min_level.is_some() || max_level.is_some() || contract_score {
eprintln!("error: --min-level, --max-level, --contract-score not yet implemented.");
eprintln!(" Use --contract-gaps to find functions without bindings.");
eprintln!(" Use --asset-contracts to check non-code asset compliance.");
eprintln!(" Track at: docs/specifications/components/commit-level-contract-enforcement.md R-6");
std::process::exit(2);
}
// Default is to show code; --summary disables it
let show_code = !summary;
let effective_docs = !no_docs;
handlers::handle_query(
query,
limit,
min_grade,
max_complexity,
language,
path,
project_path,
format,
include_source,
rebuild_index,
exclude_tests,
rank_by,
min_pagerank,
include_project,
churn,
duplicates,
entropy,
faults,
coverage,
uncovered_only,
coverage_diff,
coverage_file,
coverage_gaps,
include_excluded,
definition_type,
show_code,
git_history,
regex,
literal,
search_mode,
raw,
case_sensitive,
ignore_case,
exclude,
exclude_file,
files_with_matches,
count,
after_context,
before_context,
context_lines,
ptx_flow,
ptx_diagnostics,
suggest_rename,
apply,
effective_docs,
docs_only,
extract_candidates,
max_module_lines,
)
.await
}
}