Skip to content

tools: DOOM speedrun libclang subset oracle, --clang PORTS (Part of #5468) - #5533

Merged
squid-protocol merged 2 commits into
mainfrom
tools/5468-doom-libclang-oracle
Oct 18, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
tools/5468-doom-libclang-oracle

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #5468 (slice 3 of 4).

What

doom_speedrun.py score|run --clang PORTS (or all) adds a libclang function-definition count beside ctags and tree-sitter, on a subset of ports. libclang runs the preprocessor first, so macro-generated functions count (#5461). Never scored. New doom_clang.py: flags from compile_commands.json (or build/) when it lists the file, else -I on the file's dir, repo root and every header dir (cap 300); counts definitions located in the file itself. libclang (PyPI wheel, bundles the .so) is imported lazily: without it the columns stay empty and details.json says so. New CSV columns only with --clang: clang_files, clang_files_with_errors, clang_compile_commands_files, clang_functions, clang_gg_functions, clang_delta_pct.

Also fixed: treesitter_counts returned a plain {} without tree_sitter, so --oracle raised KeyError; it returns a Counter now.

Real output (existing scans at engine 41777e5f4, libclang 18.1.1)

port engine fn ctags clang fn (same files) engine vs clang files with parse errors
linuxdoom 778 778 735 (737) +0.3% 89/129
doomgeneric 1191 1190 1157 (1191) +2.9% 167/189
chocolate-doom 5168 5124 4822 (5026) +4.2% 475/552
doomretro 2236 2236 2146 (2236) +4.2% 165/187

Gaps are in platform code behind an inactive #ifdef (e.g. i_winmusic.c: engine 51, clang 0); libclang counts only the active configuration. None of the 39 pinned repos ships a compile_commands.json, so the guessed include path is what ran. Agreement or disagreement is not correctness (README blind spots).

Class sweep

Class: oracles for the function count. ctags (slice 1), tree-sitter (slice 1), libclang (this PR): covered. libclang covers C/C++ only. Sibling gaps: none beyond the class (no compiler-grade oracle exists for the other languages in the manifest; Roslyn/javac/rustc are out of scope). Remaining slice: 4/4, PR body results table / docs.

Files (5 hand-written): doom_clang.py (new), doom_scorer.py, doom_speedrun.py, README.md, tests/tools/test_doom_speedrun.py. Branched off main, not off #5529 (slice 2): doom_speedrun.py, README.md and the test file will conflict textually with it; whichever merges second merges main.

Gates

pr_gates --fast 6/6; tree-wide guards + test_doom_speedrun.py 196 passed 1 skipped locally; with libclang on PYTHONPATH all 18 doom tests pass (the clang test importorskips, so CI skips it: no libclang in CI deps). Time ratchet 0 over. --ratchets not run: tool-only, no parsing logic touched.

Lessons for agents

  • tree_sitter_language_pack absent made doom_scorer.treesitter_counts return a plain dict and --oracle crash; use Counter for count maps that are summed by key.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits October 18, 2026 16:44
…5468)

doom_clang.py counts function definitions with libclang (preprocessor first, so
macro-defined functions count) over a subset of ports, beside ctags and
tree-sitter, never scored. Flags from compile_commands.json when present, else a
guessed include path. Lazy import: without the libclang wheel the columns stay
empty. Also: treesitter_counts returns a Counter when tree_sitter is absent
(--oracle raised KeyError).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 18, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol marked this pull request as ready for review October 18, 2026 20:49
@squid-protocol
squid-protocol enabled auto-merge (squash) October 18, 2026 20:51
@squid-protocol
squid-protocol merged commit bd8098d into main Oct 18, 2026
44 checks passed
@squid-protocol
squid-protocol deleted the tools/5468-doom-libclang-oracle branch October 18, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant