Let’s add support to the code graph for .net/c#
- User
Let’s add support to the code graph for .net/c#
Assistant· claude-opus-4-8
I'll start by understanding how the code graph currently works and what languages it supports. Let me explore the relevant code.
Assistant· claude-opus-4-8
Now let me find the survey crate and how languages are wired in.
Assistant· claude-opus-4-8
Now the model (Lang enum) and queries file:
Assistant· claude-opus-4-8
Let me find every place the
Langvariants are referenced so I capture all touch points, and check the workspace Cargo.toml for dependency declarations.Assistant· claude-opus-4-8
tree-sitter-c-sharp = "0.23.5"matches the 0.23 grammar series. Let me check the README and DESIGN language references.Assistant· claude-opus-4-8
D55 explicitly scopes survey to Rust/TS/JS/Python/Go and defers "long-tail languages." Adding C# touches that recorded decision, so this needs the proper process. Let me read the orchestration contract.
Assistant· claude-opus-4-8
I've now got the full picture. Here's what I found and how I'd approach it.
What adding C#/.NET involves
The code graph lives in
derrick-survey. Adding a language is a well-bounded change touching:Cargo.toml(workspace) +crates/derrick-survey/Cargo.toml— addtree-sitter-c-sharp = "0.23.5"(matches the existing 0.23 grammar line).model.rs—Lang::CSharpvariant,.csextension infrom_path,as_str→"csharp".parse/mod.rs— addCSharpto theQUERIESlist, plusts_language/symbols_query_src/ arms.
Assistant· claude-opus-4-8
Authorized on both. Let me look at the exact insertion points and then make the changes.
Assistant· claude-opus-4-8
Now let me make all the edits. Starting with the workspace Cargo.toml and the crate Cargo.toml:
Assistant· claude-opus-4-8
Now
model.rs— theLangenum,from_path, andas_str:Assistant· claude-opus-4-8
Now
parse/mod.rs— add toQUERIESlist and the three match arms:Assistant· claude-opus-4-8
Now the C# queries in
queries.rs:Assistant· claude-opus-4-8
Now add a test mirroring the existing per-language tests:
Assistant· claude-opus-4-8
Now let me build and test to verify the queries compile against the actual grammar:
Assistant· claude-opus-4-8
The C# grammar at 0.23.5 emits tree-sitter ABI 15, but the
tree-sitterruntime at 0.24 only supports up to ABI 14. I need an earlier C# grammar release built with a compatible ABI. Let me check available versions.Assistant· claude-opus-4-8
Good question — yes, there is. The blocker is the runtime version, not the grammar.
tree-sitter0.24 caps at ABI 14;tree-sitter0.25 supports ABI 15, which is exactly what the latest C# grammar (0.23.5) emits. And the 0.25 runtime is backward-compatible (accepts ABI 13–15), so the existing Rust/Python/Go/JS/TS grammars keep working untouched.That's the cleaner path than pinning C# back to the older 0.23.1 (ABI 14) grammar. Let me check the latest 0.25 runtime and try the bump.
Assistant· claude-opus-4-8
tree-sitter0.26.9 is current. To minimize API churn from the 0.24 the code was written against, I'll step to the latest 0.25.x (supports ABI 13–15, covers every grammar). Let me find it and apply the bump.Assistant· claude-opus-4-8
Good — the runtime bump worked: queries compile against the C# grammar and 5/6 pass. The one failure is a bug in my test, not the code: the interface also declares a
Greet()method, so there are twoGreetsymbols andposition()finds the interface's (line 2) rather than the class's (line 4) where the call lives. Let me make the names unique.Assistant· claude-opus-4-8
All 10 survey tests pass. The
tree-sitter0.25 bump is workspace-wide, so let me confirm the whole workspace still builds cleanly.Assistant· claude-opus-4-8
Workspace builds clean on 0.25. You want 0.26 instead — let me bump to the latest 0.26.9 and verify it compiles (0.26 may have minor API changes).
Assistant· claude-opus-4-8
0.26.9 works with no code changes — all survey tests pass. Let me confirm the full workspace still builds on 0.26.
Assistant· claude-opus-4-8
All green:
tree-sitter0.26.9 runtime +tree-sitter-c-sharp0.23.5 grammar, full workspace builds, 10 survey tests pass. Now the docs and the D58 decision entry.Assistant· claude-opus-4-8
Now let me check the README MSRV/tokens references and the DESIGN.md config languages list at line 1760, then record D58. Let me look at the end of the decision log and the §9.B.8 config:
Assistant· claude-opus-4-8
Now let me look at the end of the decision log to append D58:
Assistant· claude-opus-4-8
Let me read the decision-log rows D54–D57 to match format and find the insertion point:
Assistant· claude-opus-4-8
The grep output is being mangled by the proxy. Let me read the decision-log region directly:
Assistant· claude-opus-4-8
Now I'll append D58 after D57:
Assistant· claude-opus-4-8
The log is ascending (D55, D56, D57) — D58 must go after D57, not before. Let me fix the ordering.
Assistant· claude-opus-4-8
Let me check for any other supported-language lists or tree-sitter version references in README/DESIGN that should stay consistent:
Assistant· claude-opus-4-8
Let me add a forward-pointer on D55 so readers of the original scope decision find D58:
Assistant· claude-opus-4-8
Now let me run the full survey test suite plus clippy and an end-to-end check to confirm nothing regressed, and verify a real
.csfile gets indexed end-to-end:Assistant· claude-opus-4-8
Core passes clean. Let me run a real end-to-end smoke — build an index over a temp C# file and query it through the CLI — to confirm the full walk→parse→db→query path works for
.cs:Assistant· claude-opus-4-8
The CLI works on cwd, not
--repo. Let me run it from inside the temp dir via a subshell:Assistant· claude-opus-4-8
Done and verified end-to-end. C#/.NET is now a first-class language in the code graph.
What changed
Dependencies
- Workspace
tree-sitterruntime bumped 0.24 → 0.26.9. This was the real enabler: the current C# grammar (tree-sitter-c-sharp0.23.5) emits ABI 15, which the 0.24 runtime (max ABI 14) rejected. The 0.26 runtime accepts ABI 13–15, so the existing Rust/Python/Go/JS/TS grammars keep working untouched — no grammar-crate or survey API changes needed.
- Workspace
- User
Still at 80% coverage?
Assistant· claude-opus-4-8
Let me check what the coverage target is and how it's measured here, then run it for the survey crate.
Assistant· claude-opus-4-8
No coverage gate is documented in the repo (no "80%" reference in CONTRIBUTING/AGENTS/DESIGN or CI) — that figure must be your own benchmark.
cargo-llvm-covis installed, so let me measure the survey crate as it stands now.Assistant· claude-opus-4-8
That run was
-p derrick-surveybut tarpaulin printed every workspace file (untested crates show 0/N, which is why the headline 40% is workspace-wide noise). Isolating just the survey crate's files:File Covered build.rs 70/72 db.rs 49/53 lib.rs 52/54 mcp.rs 19/63 model.rs 30/37 parse/mod.rs 120/129 query.rs 107/116 walk.rs 28/28 watch.rs 0/23 Total 475/575 = 82.6% Yes — still above 80% (~83%). The C# additions didn't move the needle much:
parse/queries.rsis pure const strings (no executable lines), andparse/mod.rs(120/129) is well-covered because the new test exercises the query/parse path.- User
Fix both caveats
Assistant· claude-opus-4-8
Test work — the routing table puts this with
test-engineer, but you've asked me directly and authorized direct work on this change, so I'll do it. Let me read the three files and the existing test harness to see what's testable.Assistant· claude-opus-4-8
Good — I now understand the harness.
mcp.rsalready testslist_tools+ search; the gap is the other three tools, the staleness-banner path, andget_info. Let me write all three sets of tests. Starting withmodel.rs(simplest), then extendingmcp.rs, then awatch.rsintegration test.First, the
model.rsdetection tests — let me confirm the file's end:Assistant· claude-opus-4-8
Now extend the
mcp.rstests to cover the remaining three tools and the staleness banner. Let me replace the single test with a broader set, reusing the existing harness:Assistant· claude-opus-4-8
I used the
json!macro — let me add the import to the test module:Assistant· claude-opus-4-8
Now the
watch.rsintegration test. It drives the real watcher: build an index, spawnwatch_loop, write a new file, and poll until the rebuild picks it up (proving event → dirty → debounce → rebuild end-to-end).Assistant· claude-opus-4-8
Let me compile and run the survey tests:
Assistant· claude-opus-4-8
16 of 17 pass (the mcp
peer_infoand model tests all work). Only the watcher test failed — it didn't observe a rebuild in 15s. Let me check the relevance filter, since a macOS tempdir path is the prime suspect:Assistant· claude-opus-4-8
The filter is fine. The likely cause is a classic FSEvents race: the watcher stream can take longer than 200 ms to arm, so the single write is missed and no further events ever fire. Let me make the test re-touch the file each poll iteration so it keeps generating events until one lands.
Assistant· claude-opus-4-8
Still failing — and I see my mistake: re-touching every 300 ms is shorter than the 500 ms debounce, so the drain loop keeps resetting the timer and the rebuild never fires. But before fixing that, let me isolate whether build+search even works without the watcher, to be sure I'm debugging the right layer:
Assistant· claude-opus-4-8
Let me fix the debounce starvation — touch then wait longer than the 500 ms debounce so a quiet window lets the rebuild fire:
Assistant· claude-opus-4-8
Passes in 2.67s now. Let me run the full survey suite and then re-measure coverage:
Assistant· claude-opus-4-8
All 18 pass, clippy clean. Now re-measure coverage:
Assistant· claude-opus-4-8
Both caveats fixed. Here's the before/after for the survey crate:
File Before After Δ model.rs 30/37 37/37 +19% (C# arms now tested) watch.rs 0/23 20/23 +87% mcp.rs 19/63 - User
Is this pushed to main?
Assistant· claude-opus-4-8
No — nothing is committed or pushed. All the C# work is sitting as uncommitted modifications in your working tree on
main:- Modified (the C# change):
Cargo.toml,Cargo.lock,crates/derrick-survey/Cargo.toml,model.rs,parse/mod.rs,parse/queries.rs,watch.rs,mcp.rs, plus docs (DESIGN.md,README.md,docs/survey.md). mainis level withorigin/main— zero unpushed commits.- The untracked
.specify/,.claude/skills/speckit-*,.derrick/,derrick.yamlentries are pre-existing (they were in the repo's initial status, not from this work).
So nothing has gone anywhere — it's purely local and uncommitted. I haven't run
git add,commit, orpushat any point, per the rule to only do that when you ask.Want me to commit it? If so, the cleanest move given the orchestration contract is a branch + PR rather than a direct push to :
- Modified (the C# change):
- User
Straight to main for this project
Assistant· claude-opus-4-8
Committing the C# work straight to
main— staging only the files from this change (leaving the pre-existing untracked.specify//.derrick//derrick.yamlalone).Assistant· claude-opus-4-8
The
cargo fmtpre-commit hook reformatted some long lines — the commit was aborted. Let me apply the formatting, re-stage, and retry.Assistant· claude-opus-4-8
Formatting applied and re-staged. Now retry the commit and push: