Skip to content

DOOM-rosetta callgraph oracle: a bare macro misparsed as a definition named if no longer swallows the file (Part of #6266) - #6645

Merged
squid-shepherd[bot] merged 3 commits into
mainfrom
churn/6266-20261025T1340Z
Oct 25, 2026
Merged

squid-shepherd[bot] merged 3 commits into
mainfrom
churn/6266-20261025T1340Z

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Part of #6266 (Track D: finish the DOOM call-graph study).

What changed

The largest scored shape class was an oracle bug, not an engine one. A bare macro statement with no semicolon (srb2's NOHUD / INLEVEL / NOSPAWNNULL) followed by if (...) parses in tree-sitter as a K&R function_definition named if, and its head can run to the end of the file. That had two effects:

  1. The outer function's body walk collected the whole file's calls. lua_baselib.c:955 lib_pInsideANonSolidFFloor produced 479 "unparsed" misses.
  2. definition_at matched later functions to the bogus node. That produced 879 "statement" misses and ~617 false "absent" engine-only edges, e.g. lib_gAddGametype -> luaL_error. The engine is right on all of them.

tests/tools/doom_speedrun/callgraph_oracle.py:

  • definition_at never returns a definition whose name is a C keyword (_keyword_named).
  • A keyword-named nested definition marks the body broken.
  • A broken body also takes the brace-matched text fallback when the braces end earlier than the node. The exception is when the braces contain whole real nested definitions: a broken DE_PIMPL(X) { methods } macro class, whose method calls belong to the methods. Without that exception doomsday misses rose by 1734. The same rule fixes the MSVC __asm early close (doom3-bfg win_cpu.cpp:134 HasCPUID) and edge-classic's EDGE_QSORT(...) run-over (r_image.cc:1087 GetUserSprites).

Moves (goldens re-blessed with doom_rosetta_check.py --update --yes under golden-lock.sh; callgraph_baseline.json regenerated over all 23 licensed C/C++ ports):

port misses scored engine-only recall precision
srb2 1358 -> 2 640 -> 21 0.9318 -> 0.9999 0.9639 -> 0.9961
doomsday 1713 -> 1567 2602 -> 2601 0.9754 -> 0.9774 =
edge-classic 38 -> 4 12 -> 11 0.9964 -> 0.9996 0.9867 -> 0.9868
doom3-bfg 19 -> 3 = 0.9996 -> 0.9999 =
odamex, gzdoom = = = unscored -2 / -3

The 16 vanilla-lineage / Boom-family ports only gain a few text-fallback functions (calls unchanged), and the consensus is unchanged (holes 321, engine missed 2). No port reaches 0/0, so manifest.csv expected_fails is unchanged. The 9 newly scored rows the fix exposes are text-fallback noise on two ports (srb2 RecordExceptionInfo -> __except, doomsday initializer-list new Impl) or real calls the engine misses (doomsdayapp.cpp:1039 changeGame -> currentGameChanged).

The merge of main also re-blesses gzdoom for #6639: two template-header function-name hashes (TWeightedList<T>::AddEntry, vectors.h). #6639 re-blessed doom3-bfg and doomsday but not gzdoom; a second rescan confirmed it is stable.

Step 1 and Step 2

The per-shape breakdown of all 9 ports is posted on #6266 as one comment: #6266 (comment). melek's #3784 / #6454 moved no port: all 11 ports matched their goldens at f958d5a64. #6639 merged during this run and moved only function names, not callgraph numbers.

The three "regressions" are not regressions, so there was nothing to bisect:

Owner decisions

Owner OK (2026-10-25): Track D as above; copy this line into the PR body under ## Owner decisions.

Checklist

Checklist: done [c:a1f0d74e]
Checklist: partial [c:9e7fe6a3] -- the bare-macro if misparse class (oracle) is fixed; the engine classes listed under Remaining slices are left
Checklist: partial [c:0254d813] -- callgraph is still expected_fail on all 9 ports (srb2 now 2 misses / 21 scored engine-only); the nightly is unchanged
Checklist: partial [c:84996f5e] -- no port changed PERFECT status in this PR

Class / Sibling gaps

Class: a statement tree-sitter misparses as a function definition, whose node runs past the real function's braces, so the oracle credits the wrong calls to the outer function and to every later function. Siblings by misparse trigger:

  • Bare macro + if (keyword-named): fixed (srb2, plus the synthetic test).
  • Non-keyword macro call misparse (EDGE_QSORT(const Image *, ...)): fixed by the earlier-braces rule, edge-classic.
  • MSVC __asm { }: fixed, doom3-bfg.
  • Macro classes (DE_PIMPL / DE_GUI_PIMPL / DE_PIMPL_NOREF / DE_OBSERVES): deliberately left on the node. 1085 doomsday misses still sit in them, and those are ENGINE-side (it reads the macro class as one function).
  • SEH __try / __except: open (srb2 win_dbg.c:384, 2 rows).

Remaining slices

ENGINE classes, all measured in the #6266 comment:

  • doomsday DE_PIMPL macro classes (1085 misses).
  • "Absent" engine edges (doomsday 2581, gzdoom 517, odamex 203, eternity 73, doom3-bfg 57), in three sub-classes:
    • constructor -> base class from the initializer list (XIConstantEffect -> XIBaseEffect, FStringCVar -> FBaseCVar, idGameError -> idException);
    • a member read as a call in inline class bodies (gltextureunit.h:53 Unmanaged -> filter);
    • a member type read as the callee (OpenALSoundStream -> Source).
  • Calls behind function-like macros (gzdoom IFVIRTUALPTRNAME -> VMCall 84 + 26; eternity MOODYCAMEL_CONSTEXPR_IF; odamex AGOBJECT_FOREACH_CHILD).
  • odamex tokenizer-style nesting (wi_interlevel.cpp 26 misses).
  • helion C# calls inside interpolated-string holes (59).
  • kocoa-doom Kotlin trailing-lambda-only calls (14).

Gates

  • pr_gates.py --fast 7/7 and --ratchets 9/9, both run via heavy-run.sh.
  • Tree-wide guards plus all of tests/tools/: pass.
  • test_callgraph_oracle.py passes (14 tests, 0.22 s, run via plain pytest from /tmp).
  • git merge-tree against origin/main: clean.

Lessons for agents

  • doom_speedrun.py scan keys scans by HEAD sha: a WIP commit mid-run splits the scans across two dirs. With no gitgalaxy/ diff between the two shas, symlink one set into the other and pass --sha to callgraph_oracle.py.
  • A widened tree-sitter fallback rule must be checked port by port for NEW scored rows, not just net totals: "braces end earlier" alone added 1734 doomsday misses (macro classes) while removing 2000 in srb2.

🤖 Generated with Claude Code

squid-protocol and others added 3 commits October 25, 2026 10:00
…med `if` no longer swallows the file (Part of #6266)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the oracle fix (Part of #6266)

srb2 misses 1358 -> 2, scored engine-only 640 -> 21; doom3-bfg misses 19 -> 3; edge-classic 38 -> 4;
doomsday 1713 -> 1567. No engine change: the oracle stopped matching a bare-macro `if` misparse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ged engine (Part of #6266)

doom3-bfg / doomsday: #6639's function names plus this branch's oracle numbers. gzdoom: #6639's class-template
member names in vectors.h / weightedlist.h (#6639 did not re-bless gzdoom); rescan confirmed stable.

Co-Authored-By: Claude Opus 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 25, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review October 25, 2026 14:32
@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) October 25, 2026 14:34
@squid-shepherd
squid-shepherd Bot merged commit d33f819 into main Oct 25, 2026
70 checks passed
@squid-shepherd
squid-shepherd Bot deleted the churn/6266-20261025T1340Z branch October 25, 2026 14:42
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