Skip to content

Commit 636f0bc

Browse files
Your Nameclaude
andcommitted
fix(core,server): resolve D4 post-push CI failures (fitness-check crash + clippy + fmt)
Root-caused and fixed everything CI flagged red after D4 (7672f52) landed: - indexer/parser.rs: walk_calls fed an immediately-invoked closure's whole multi-line body to split_receiver_callee/selected_callee_byte_span as if it were a simple dotted callee expression. The naive last-`.`/`::` scan latched onto an unrelated nested call and derived a byte span that collided with that call's own correctly-walked RawCall, tripping D4's new UNIQUE call_sites identity index and crashing fitness-check on a real repo. Now guarded to only run that logic on single-line fn_node text. - scip/ingest.rs, scip/parse.rs, lsp/overlay.rs, lsp/provider.rs, tools/recover.rs: clippy fixes (type_complexity via a CallEdgeRow alias, needless_borrow, needless_update, map_flatten, too_many_arguments, assertions_on_constants, collapsible_if) across every feature-combo CI actually lints with, including one only visible under lsp-overlay/ all-languages and one masked by the fmt-check step short-circuiting first. - embedding.rs: pre-existing (non-D4) cargo fmt violations. Verified: all 6 CI clippy invocations + fmt --check clean locally, fresh index of a real repo no longer hits the UNIQUE constraint, and two clean full `cargo test --workspace --all-features` runs both pass (937 tests, 0 failed) with no competing background processes -- including watcher_reindexes_add_and_delete and coordinator_refuses_phase_three_commit_after_a_newer_baseline_is_queued, each of which flaked once earlier under this session's own resource contention (stacked calm serve daemons + concurrent builds) but passed cleanly in isolation and in the final clean run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 7672f52 commit 636f0bc

7 files changed

Lines changed: 54 additions & 41 deletions

File tree

crates/calm-core/src/embedding.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,13 @@ mod imp {
360360
}
361361
let model = model
362362
.into_optimized()
363-
.map_err(|e| anyhow::anyhow!("optimize onnx model at {}: {e}", onnx_path.display()))?
363+
.map_err(|e| {
364+
anyhow::anyhow!("optimize onnx model at {}: {e}", onnx_path.display())
365+
})?
364366
.into_runnable()
365-
.map_err(|e| anyhow::anyhow!("compile onnx model at {}: {e}", onnx_path.display()))?;
367+
.map_err(|e| {
368+
anyhow::anyhow!("compile onnx model at {}: {e}", onnx_path.display())
369+
})?;
366370

367371
let mut this = Self {
368372
model,
@@ -397,8 +401,11 @@ mod imp {
397401
.encode(text, true)
398402
.map_err(|e| anyhow::anyhow!("tokenize: {e}"))?;
399403
let mut ids: Vec<i64> = encoding.get_ids().iter().map(|&x| x as i64).collect();
400-
let mut mask: Vec<i64> =
401-
encoding.get_attention_mask().iter().map(|&x| x as i64).collect();
404+
let mut mask: Vec<i64> = encoding
405+
.get_attention_mask()
406+
.iter()
407+
.map(|&x| x as i64)
408+
.collect();
402409
ids.truncate(ONNX_MAX_SEQ_LEN);
403410
mask.truncate(ONNX_MAX_SEQ_LEN);
404411
while ids.len() < ONNX_MAX_SEQ_LEN {

crates/calm-core/src/indexer/parser.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,18 @@ fn walk_calls(
17261726
None
17271727
}
17281728
})
1729+
// A legitimate callee expression (`a.b.method`, `Type::method`) is
1730+
// always single-line/single-expression text in every currently
1731+
// supported grammar. Reject a multi-line `fn_node` here -- e.g. an
1732+
// immediately-invoked closure `(|| { ...multi-statement body... })()`
1733+
// resolves its "function" field to the WHOLE closure body, and
1734+
// `split_receiver_callee`'s naive last-`.`/`::` scan then silently
1735+
// latches onto some unrelated call buried inside that body (found
1736+
// via a real UNIQUE-constraint collision on a real repo: an
1737+
// IIFE-shaped `(|| {...})()` produced a phantom RawCall whose
1738+
// `rfind`-derived byte span landed on the SAME bytes as the real,
1739+
// separately-walked call a few lines later).
1740+
&& !source[fn_node.byte_range()].contains('\n')
17291741
&& let Some((mut receiver, callee, mut receiver_is_type_path)) =
17301742
split_receiver_callee(&source[fn_node.byte_range()])
17311743
&& let Some((callee_start_byte, callee_end_byte)) =

crates/calm-core/src/lsp/overlay.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ enum PhaseThreeOutcome {
497497
/// Leader-only portion of an LSP refresh. The coordinator guarantees that no
498498
/// same-baseline peer starts another server, and its cancellation token fences
499499
/// a superseded generation before it can write evidence in phase 3.
500+
#[allow(clippy::too_many_arguments)]
500501
fn run_lsp_overlay_prepared(
501502
conn: &Connection,
502503
root: &Path,

crates/calm-core/src/lsp/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ mod tests {
355355
(CLANGD.client_profile.language_id)(Path::new("x.cpp")),
356356
"cpp"
357357
);
358-
assert!(RUST_ANALYZER.client_profile.include_workspace_folder);
358+
const { assert!(RUST_ANALYZER.client_profile.include_workspace_folder) };
359359
}
360360

361361
#[test]

crates/calm-core/src/scip/ingest.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ use super::parse::ScipOccurrence;
1111

1212
type ExactCallSiteKey = (String, i64, i64, String);
1313
type DefinitionSite = (String, i64);
14+
/// One joined `call_edges`/`call_sites`/`file_index`/`symbols` row used by
15+
/// both the upgrade pass and `exact_sibling_rule_out_ids`: (edge id,
16+
/// call_site id, exact CallSite key, target def path, target def line,
17+
/// edge_confidence, formal_source, ruled_out_by_scip).
18+
type CallEdgeRow = (
19+
i64,
20+
i64,
21+
ExactCallSiteKey,
22+
String,
23+
i64,
24+
String,
25+
Option<String>,
26+
bool,
27+
);
1428

1529
/// Outcome of one `ingest_occurrences` pass.
1630
///
@@ -185,16 +199,7 @@ pub fn ingest_occurrences_with_proof_context(
185199
}
186200
}
187201

188-
let rows: Vec<(
189-
i64,
190-
i64,
191-
ExactCallSiteKey,
192-
String,
193-
i64,
194-
String,
195-
Option<String>,
196-
bool,
197-
)> = {
202+
let rows: Vec<CallEdgeRow> = {
198203
let mut stmt = conn.prepare(
199204
"SELECT ce.id, ce.call_site_id, cs.from_path, cs.callee_start_byte,
200205
cs.callee_end_byte, fi.hash, s.path, s.line_start, ce.edge_confidence,
@@ -227,7 +232,7 @@ pub fn ingest_occurrences_with_proof_context(
227232
let mut newly_upgraded = 0;
228233
let mut satisfied = HashSet::new();
229234
for (edge_id, _, key, def_path, def_line, confidence, formal_source, _) in &rows {
230-
let agrees = ref_targets.get(&key).is_some_and(|targets| {
235+
let agrees = ref_targets.get(key).is_some_and(|targets| {
231236
targets
232237
.iter()
233238
.any(|(path, line)| path == def_path && *line == *def_line)
@@ -290,21 +295,11 @@ pub fn ingest_occurrences_with_proof_context(
290295
} else {
291296
satisfied.len() as f64 / ref_targets.len() as f64
292297
},
293-
..IngestStats::default()
294298
})
295299
}
296300

297301
fn exact_sibling_rule_out_ids(
298-
rows: &[(
299-
i64,
300-
i64,
301-
ExactCallSiteKey,
302-
String,
303-
i64,
304-
String,
305-
Option<String>,
306-
bool,
307-
)],
302+
rows: &[CallEdgeRow],
308303
ref_targets: &HashMap<ExactCallSiteKey, Vec<DefinitionSite>>,
309304
) -> Vec<i64> {
310305
let mut groups: HashMap<i64, Vec<_>> = HashMap::new();

crates/calm-core/src/scip/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn parse_index(
6363
line: (start_line as usize) + 1,
6464
start_byte: byte_range.map(|(start, _)| start),
6565
end_byte: byte_range.map(|(_, end)| end),
66-
source_file_hash: byte_range.as_ref().map(|_| source_hash.clone()).flatten(),
66+
source_file_hash: byte_range.as_ref().and_then(|_| source_hash.clone()),
6767
symbol: occ.symbol.clone(),
6868
is_def,
6969
is_local: occ.symbol.starts_with("local "),

crates/calm-server/src/tools/recover.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,17 @@ impl CalmServer {
4747
let mut external_proofs = ExternalProofStatusOutput::default();
4848
if let Ok(mut stmt) = conn.prepare(
4949
"SELECT status, COUNT(*) FROM external_proofs GROUP BY status",
50-
) {
51-
if let Ok(rows) = stmt.query_map([], |row| {
52-
Ok((row.get::<_, String>(0)?, row.get::<_, u64>(1)?))
53-
}) {
54-
for row in rows.flatten() {
55-
match row.0.as_str() {
56-
"fresh" => external_proofs.fresh = row.1,
57-
"stale" => external_proofs.stale = row.1,
58-
"legacy" => external_proofs.legacy = row.1,
59-
"unverified" => external_proofs.unverified = row.1,
60-
"rejected" => external_proofs.rejected = row.1,
61-
_ => {}
62-
}
50+
) && let Ok(rows) = stmt.query_map([], |row| {
51+
Ok((row.get::<_, String>(0)?, row.get::<_, u64>(1)?))
52+
}) {
53+
for row in rows.flatten() {
54+
match row.0.as_str() {
55+
"fresh" => external_proofs.fresh = row.1,
56+
"stale" => external_proofs.stale = row.1,
57+
"legacy" => external_proofs.legacy = row.1,
58+
"unverified" => external_proofs.unverified = row.1,
59+
"rejected" => external_proofs.rejected = row.1,
60+
_ => {}
6361
}
6462
}
6563
}

0 commit comments

Comments
 (0)