Repository navigation
Description
Found while working #2669 Batch D (the shape-descriptor design pass, #2689).
What happens
detector.py's slicer synthesizes a __global_context__ bucket to hold a file's top-level
statements when they sit outside any function. That bucket is then counted as a function: it
lands in function_data and in functions_found.
On the keyword-rosetta control corpus, where exactly 13 probe functions are planted per language,
five languages report 16:
matlab | 3 synthetic lua | 3 synthetic shell | 3 synthetic
ruby | 3 synthetic livecode | 3 synthetic
SELECT f.func_name, f.loc FROM function_data f JOIN file_data fd ON f.file_id = fd.id
WHERE fd.file_path LIKE 'matlab/%';
-- __global_context__ | 6
-- __global_context__ | 6
-- __global_context__ | 9
-- entry | 6 ... plus the 13 real probespython for contrast returns exactly the 13 real probes and no bucket.
Why it matters
Every per-function descriptor divides by functions_found, so all of them are diluted by roughly
3/16 for these five languages — the average is taken over three things that are not functions:
avg_func_complexity,avg_func_loc,avg_func_args,max_func_complexityfunc_complexity_gini,func_internal_density- and downstream,
cog_rawandstructural_mass
This is measurable cross-language bias with a purely internal cause: identical planted intent, but
a denominator that counts synthetic buckets in some languages and not others. It is not a corpus
artifact — any real repository with top-level code gets the same dilution.
Precedent
#2547 is the same family, one consequence over: synthetic slicer bucket names were being counted as
orphans, and the fix taught the orphan/duplicate checks to skip them via
_is_synthetic_satellite_name. That helper already exists and already knows what a synthetic name
looks like — the per-function denominators were simply never given the same treatment.
Fix shape
Exclude synthetic satellite names from functions_found and from every per-function aggregate,
reusing _is_synthetic_satellite_name rather than a second list. The bucket itself should keep
existing (its signals are real code and must still be counted at file level) — it is only its
membership in the function population that is wrong.
Open question for whoever takes it: whether functions_found should drop them silently or report
them separately (functions_found vs slices_found), since a file that is entirely top-level code
would then report 0 functions while still carrying signals.
Blast radius
Golden masters will move for any repo with top-level code in these languages: the per-function
descriptors above, plus cog_raw/structural_mass downstream. No signal counts should change --
the bucket keeps contributing its hits, it just stops being counted as a function.
Corpus-side: keyword-rosetta's functions_found goes 16 -> 13 for matlab/lua/shell/ruby/livecode,
which is the planted value, so this closes rather than opens corpus deviations.
Activity
fix(core-engine): narrow the uncountable-slice set -- "Main" is a rea…
test(golden-master): re-bless for the function-population fixes (#2691,
fix(core-engine): the function population is real functions only (#2691…
fix(core-engine): the orphan census counts references, not name repet…
fix(detector): Mode E statement buckets leave the function population (…
risk_documentation becomes the per-unit coverage ratio (#2908 Phase 3) (
Python: record module-level calls (`app = FastAPI()`, `@app.post(...)…
Call graph: decorator edges (Python) — a decorated function → each de…
Call graph: reference edges (Python) — functions used as values; nest…
docs: call-graph edge kinds, and what the call graph adds to a parser…
fix(#4110): one shared definition of "a function" for counting and li…