feat(kernel): R7a C/C++ walker — dual-lang ccpp module, preParse hoist, 7 new blanks, c/cpp default-routed (#1346)

Parity: 0 diffs on redis/git/fmt/protobuf/ALS sweeps; full-init dumps
byte-identical on all five + linux at kernel scale (10.4M dump lines,
same sha256 both arms). Linux 2c/6GB envelope: kernel-arm 19.1min vs
wasm-arm 22.9min (parse 356s vs 435s) on a much richer graph (the new
blanks recover error-swallowed code: git 2x nodes, linux kernel/+mm/ 3x).
Deferral guard corrected by measurement (C/C++ error incidence 9-42%;
--max-deferral flag); defer-reuse memo kills the 3x re-blank/re-parse
cost deferred files paid.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-07-17 16:56:41 -05:00
committed by GitHub
co-authored by Claude Fable 5
parent 44561b6aad
commit 2d72891b59
20 changed files with 3211 additions and 80 deletions
File diff suppressed because it is too large Load Diff
+7 -2
View File
@@ -15,8 +15,8 @@ use tree_sitter::Language;
/// Languages this kernel binary can extract (reported by contractInfo;
/// TS-side routing policy decides what actually routes).
pub const LANGUAGES: [&str; 7] =
["typescript", "tsx", "javascript", "jsx", "java", "python", "go"];
pub const LANGUAGES: [&str; 9] =
["typescript", "tsx", "javascript", "jsx", "java", "python", "go", "c", "cpp"];
pub fn grammar_for(language: &str) -> Option<Language> {
match language {
@@ -26,6 +26,11 @@ pub fn grammar_for(language: &str) -> Option<Language> {
"java" => Some(tree_sitter_java::LANGUAGE.into()),
"python" => Some(tree_sitter_python::LANGUAGE.into()),
"go" => Some(tree_sitter_go::LANGUAGE.into()),
// `.metal`/`.cu`/`.cuh` map to language 'cpp' at detectLanguage, so the
// dialects ride this grammar too (their blanking pre-passes stay
// TS-side — the route point applies preParse before the kernel call).
"c" => Some(tree_sitter_c::LANGUAGE.into()),
"cpp" => Some(tree_sitter_cpp::LANGUAGE.into()),
_ => None,
}
}
+2
View File
@@ -17,6 +17,7 @@
#![deny(clippy::all)]
mod buffers;
mod ccpp;
mod docstring;
mod ids;
mod go;
@@ -103,6 +104,7 @@ pub fn extract_file(file_path: String, content: String, language: String) -> Res
"java" => java::extract(&file_path, &content).map_err(Error::from_reason)?,
"python" => python::extract(&file_path, &content).map_err(Error::from_reason)?,
"go" => go::extract(&file_path, &content).map_err(Error::from_reason)?,
"c" | "cpp" => ccpp::extract(&file_path, &content, &language).map_err(Error::from_reason)?,
_ => tsjs::extract(&file_path, &content, &language).map_err(Error::from_reason)?,
};
Ok(ExtractBuffers {