Repository navigation
Description
Fell out of the corpus wave for #2729. It could not be seen before that wave, because no corpus language had both halves at once.
The measurement
galaxyscope.py L2228 adds a file's orphaned_logic to its api when the file is imported. It does not ask whether those functions were already counted as API surface by the language's api rule. So a function that is both declared public and uncalled contributes twice.
keyword-rosetta data/go/a.go, three functions, all three exported (func ProbeGlobals, func ProbeTest, func ProbeSafety), none called in-file, the file imported by main.go:
| column | value |
|---|---|
function_count |
3 |
raw_arch_api (the api rule) |
3 |
raw_state_slop_orphans |
3 |
arch_api (what scoring reads) |
6 |
state_slop_orphans |
0 |
Three functions, six units of public surface. The same three identifiers are counted once as declarations and once as converted orphans.
Why it was invisible until now
Before the #2729 wave the corpus never planted an explicit public surface: raw_arch_api was 0 in 36 of 44 languages, so arch_api was entirely converted orphans and the two terms never overlapped. Now 30 languages declare their probes public and every one of them shows the doubling. Corpus-wide the effect is a bimodal arch_api: 6 where a language can declare visibility, 3 where it cannot but its orphans still convert, 0-1 where neither happens.
Why it matters
_calc_api_exposure and _calc_documentation read the adjusted api. On real code the same overlap is the common case, not the exception: a library's public functions are exactly the ones with no in-repo caller. Every exported-but-not-internally-called function in every imported file is currently scored as two public surfaces, so risk_api_exposure and risk_documentation are inflated most for the codebases that are most library-shaped.
It also lands on the rosetta bias table as 21 unexplained cells (risk_api_exposure in 18 languages, risk_documentation in livecode/ruby/tcl) whose measured input raw_arch_api sits exactly on the median — the deviation enters through a column the corpus cannot see, which is the same structural gap #2729 fixed for the gate.
Fix shape
Convert only the orphans the api rule did not already count. The recorder already has both numbers (raw_arch_api, raw_state_slop_orphans, #2536), so the cheap form is to credit max(0, orphans − rule_hits); the precise form is to exclude, per function, the ones whose declaration the api rule matched — spatial_maps has the api rule's match locations and the function spans are known, which is the same span data #2727 needs.
Either way this is a golden-master change: it moves arch_api on every imported file in the real-world corpus, and risk_api_exposure / risk_documentation with it. Verify the direction on language-crucible before blessing.
Part of #2669. Siblings: #2729 (the gate now asserts the rule, done), #2727 (the orphan census is name recurrence, not a call graph), #2730 (the api rule has no stated contract).
Activity
squid-protocol commentedon Sep 5, 2026
Fixed in #2734 (engine side).
Took the precise form from the fix shape, but keyed on the function name rather than on
span containment: an orphan's name occurs exactly once in the file (that is what the orphan
census itself proves), so a name appearing on a line the
apirule matched can only be its owndeclaration — no false positive is possible, and it needs no new span bookkeeping.
Measured against both candidate forms. Span containment (
hit_vector["api"] > 0) is wrong inboth directions: C's api rule matches every non-
staticlocal declaration, so it suppressed all73 orphans in
c/cpython/ceval.cand all 27 inframeobject.c— files ofstatichelpers thatare not public surface at all — while missing javascript/typescript entirely, where
exportsits outside the slicer's
start_idx. The cheapmax(0, orphans - rule_hits)form over-subtractsfor the same reason the issue notes: a file's api hits also land on public classes, fields and
grouped constants that are not functions.
Direction confirmed on language-crucible before blessing: 61 files move, all downward, zero
increases, total
arch_api−2.13%, and no structural signal other thanapimoves. Onkeyword-rosetta 21 of 46 languages move — 20 of them exactly 6 → 3.
One consequence for the corpus side: #2729's gate pins
api_orphan_creditas its only assertionthat the
main → a → b → cchain resolved, and that credit legitimately becomes 0 wherever theprobes are all declared public.
raw_state_slop_orphans 3withstate_slop_orphans 0stillproves the conversion ran — the swap belongs in the same keyword-rosetta PR that re-blesses the
manifests.
fix(core-engine): the api rule's own declarations are not new orphan …
test(core-engine): the raw/adjusted api split is not a sum (#2729) (#…
fix(core-engine): an export construct that names many functions is st…
api_declared_orphans: test the orphan's real name, not \b\w+\b tokens (…