feat(kernel): R7b Swift walker — swift module, tree-sitter-swift 0.7.3 bump, swift default-routed (#1381)

Fifth R7b batch-3 port, checklist-first recipe
(docs/design/swift-kernel-port-checklist.md, 1,056 lines — the largest of the
arc, with a built-extractor-validated emission pin and a childForFieldName
truth table).

Grammar bump first, validated standalone: tree-sitter-wasms ^0.4.0 (ABI 13) →
crate 0.7.3 — with a provenance twist: the wasm is built from the CRATE
TARBALL's src/ (alex-pinkus keeps generated files off main and the
0.7.3-with-generated-files tag ships an older ABI-14 generation that can never
sha-match; grammar.json rules are JSON-equal; the tarball is byte-for-byte
what the kernel's cargo build compiles — table identity by construction).
Older crates evaluated and rejected: clean-parse shapes are byte-identical on
0.7.3 (53-line CST battery diff, all inert), so an older pin buys nothing and
loses the macro-era wins. Delta = error-set membership (63 old-error files
parse clean: swift-testing #expect, #Preview/#GET macros, package access,
typed throws — vapor 23.1%→9.3%; 21 NEW-only regressions in 3 probed
construct classes) + two gate-found categories: docstring boundaries near #if
directives (7 clean files, docstring-field-only — verified mechanically) and
array-literal-callee call refs (2 refs, 1 file). Every hunk classified via
the error-union rule + parked-ref↔edge ripple pairing.

Walker (the arc's biggest) centers on the #1020 DEDICATED property branch:
computed properties → property nodes with the getter walked under the
property (SwiftUI body), static let/var → constant/variable, stored → field,
decorator/type-annotation/@Siblings-attr-arg refs all attached to the
ENCLOSING TYPE, stored initializer calls attributed to the class. Preserved
bug-for-bug: the never-resolving 'parameter' field (zero param type refs,
zero signatures), present-false isAsync, open→internal visibility,
everything-is-extends inheritance (first type_identifier per specifier), no
instantiates refs ever, subscript reads as `calls arr`, `defer` as `calls
defer`, multi-case enum entries minting only the first case, /** */ block
docs ignored AND chain-breaking, init/deinit/subscript minting no nodes with
visitNode-routed bodies (calls → class, static reads → nothing), multi-
segment extension resolveName, sugar extension names, the #selector shapes,
and the value_argument label-forward skip. ONE fix found by the sweep (then
pinned in the fixture + checklist): the shared `assignment` shadow-prune case
is swift-live — declared-then-assigned `let X: T` prunes X as a value-ref
target.

Gates: sweeps 0-diff Alamofire 89/98, vapor 224/247, swift-nio 407/554
(--max-deferral 0.3 — swift error incidence is 9–27% on BOTH arms,
structural; every deferral count matches the survey's table exactly);
full-init dumps byte-identical ×3 (31.9k/20.7k/126.3k lines); the Alamofire
census reproduces property=348 (the #1020 number) on the kernel arm;
kernel-swift-parity suite (206-line torture + CRLF + the #if-between-enum-
cases defer fixture) + swift grammar-parity row; full suite 2,626 green ×2
under CODEGRAPH_KERNEL_EXPECT=1. DEFAULT_ROUTED += swift (14 langs).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-07-20 17:09:12 -05:00
committed by GitHub
co-authored by Claude Fable 5
parent a6c62d77df
commit 09e301bbfa
16 changed files with 4185 additions and 6 deletions
+11
View File
@@ -62,6 +62,7 @@ dependencies = [
"tree-sitter-python",
"tree-sitter-ruby",
"tree-sitter-rust",
"tree-sitter-swift",
"tree-sitter-typescript",
]
@@ -594,6 +595,16 @@ dependencies = [
"tree-sitter-language",
]
[[package]]
name = "tree-sitter-swift"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe36052155b9dd69ca82b3b8f1b4ccfb2d867125ac1a4db1dd7331829242668c"
dependencies = [
"cc",
"tree-sitter-language",
]
[[package]]
name = "tree-sitter-typescript"
version = "0.23.2"
+5
View File
@@ -41,6 +41,11 @@ tree-sitter-ruby = "=0.23.1"
# php: the walker calls LANGUAGE_PHP (the full HTML-interleaving variant the
# wasm ships) — NEVER LANGUAGE_PHP_ONLY, which errors on leading HTML.
tree-sitter-php = "=0.24.2"
# swift: the vendored wasm is built from THIS crate's tarball src/ (the tag's
# checked-in parser.c is an older ABI-14 generation that can never sha-match;
# grammar.json rules are JSON-equal — swift checklist header). parser.c is
# ~20MB generated — expect slow compiles.
tree-sitter-swift = "=0.7.3"
[build-dependencies]
napi-build = "2"
+5 -2
View File
@@ -15,9 +15,9 @@ 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; 13] = [
pub const LANGUAGES: [&str; 14] = [
"typescript", "tsx", "javascript", "jsx", "java", "python", "go", "c", "cpp", "rust",
"csharp", "ruby", "php",
"csharp", "ruby", "php", "swift",
];
pub fn grammar_for(language: &str) -> Option<Language> {
@@ -44,6 +44,9 @@ pub fn grammar_for(language: &str) -> Option<Language> {
// R7b: v0.24.2, the full HTML-interleaving variant — LANGUAGE_PHP,
// NEVER LANGUAGE_PHP_ONLY (which errors on leading HTML).
"php" => Some(tree_sitter_php::LANGUAGE_PHP.into()),
// R7b: crate 0.7.3 — the vendored wasm is built from this crate's own
// tarball src/ (table identity by construction; see grammars.ts).
"swift" => Some(tree_sitter_swift::LANGUAGE.into()),
_ => None,
}
}
+2
View File
@@ -28,6 +28,7 @@ mod langs;
mod php;
mod ruby;
mod rustlang;
mod swift;
mod textutil;
mod python;
mod tsjs;
@@ -219,6 +220,7 @@ pub fn extract_file(file_path: String, content: String, language: String) -> Res
"csharp" => csharp::extract(&file_path, &content).map_err(Error::from_reason)?,
"ruby" => ruby::extract(&file_path, &content).map_err(Error::from_reason)?,
"php" => php::extract(&file_path, &content).map_err(Error::from_reason)?,
"swift" => swift::extract(&file_path, &content).map_err(Error::from_reason)?,
_ => tsjs::extract(&file_path, &content, &language).map_err(Error::from_reason)?,
};
Ok(ExtractBuffers {
File diff suppressed because it is too large Load Diff