Skip to content

fix(recorders): floor func_internal_density's denominator at 12 lines per function (#2705) - #2715

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2705-func-internal-density-floor
Sep 4, 2026
Merged

fix(recorders): floor func_internal_density's denominator at 12 lines per function (#2705)#2715
squid-protocol merged 1 commit into
mainfrom
fix/2705-func-internal-density-floor

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #2705

What

func_internal_density = avg_func_complexity / max(avg_func_loc, FUNC_EVIDENCE_MASS_FLOOR) with FUNC_EVIDENCE_MASS_FLOOR = 12 beside EVIDENCE_MASS_FLOOR = 50 in analysis_lens.ENGINE_CONSTANTS. One constant, one recorder line, one test module, one wiki paragraph.

Why

#2655 floored every per-file density; the recorder-side per-function density was left without one, so it read function length where structure was held equal. keyword-rosetta (the same 13 functions at 46 lengths) measured it at Spearman −0.96 against coding_loc with branch/args/func_start held. In the golden-master scan, five find*.sql files whose functions average one line and one branch each read a flat 1.00 — the densest files in the corpus — for being the tersest.

The floor follows #2655's own derivation: 50 sits at the golden-master median coding_loc (51); 12 sits at the golden-master median avg_func_loc (12.0) and floors the same 49% of the population. Below it the column is an exact rescale of avg_func_complexity (branch structure); at or above it, byte-identical to before. Design pass and decisions on #2705 (options 2 / 4 / separate bug).

Effect: rosetta leak rho −0.96 → 0.000, consistency 54% → 67%, no --gate verdict changes (the cells were already derived). Real code (scan DB): 574 / 2074 files with functions move, median drop 0.060, 72.3% untouched.

Blast radius

Verification

Cross-repo

keyword-rosetta: no manifest changes (the column is a derived measure, not a planted signal); bias-history.yml regenerates the report against engine main after merge and the func_internal_density row should leave the length-leak table. control_flow_ratio stays per #2705 decision 2 (ledger already exists; leak-check label rides with F.3). Label rosetta:rebless-owed not needed.

🤖 Generated with Claude Code

… per function (#2705)

The per-file densities got an evidence-mass floor in #2655; the recorder-side
per-function density did not, so avg_func_complexity / avg_func_loc read
function LENGTH where structure was held equal: the keyword-rosetta corpus
(the same 13 functions at 46 lengths) measured it at Spearman -0.96 against
coding_loc with branch/args/func_start held, and in the golden master five
find*.sql files whose functions average one line and one branch each read a
flat 1.00 -- the densest files in the corpus -- for being the tersest.

FUNC_EVIDENCE_MASS_FLOOR = 12 beside EVIDENCE_MASS_FLOOR = 50, derived the same
way: 50 is the golden-master median coding_loc (51); 12 is the golden-master
median avg_func_loc (12.0), flooring the same 49% of the population. Below the
floor the column is an exact rescale of avg_func_complexity (branch structure);
at or above it, byte-identical to before. Rosetta: leak rho -0.96 -> 0.000,
consistency 54% -> 67%, no --gate verdict changes. Real code: 574/2074 files
with functions move (median drop 0.060), 72.3% untouched.

No ML blast radius: the metric is in neither pre-trained vector, and its only
other consumer (security_auditor's telemetry read) has always seen 0.0 because
signal_processor never writes the key -- filed separately as #2714.

Tests pin the four #2655 properties for the per-function analog (invariance
below the floor, no cliff at it, parity above it, zero with no functions) through
RecordKeeper.record_mission. ruff baseline regenerated for pure line-shifts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit c3ca989 into main Sep 4, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the fix/2705-func-internal-density-floor branch September 4, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

length leaks: func_internal_density, avg_func_loc and control_flow_ratio read file length with content and tier held equal (rosetta F.1 design pass)

1 participant