fix(recorders): floor func_internal_density's denominator at 12 lines per function (#2705) - #2715
Merged
Merged
Conversation
… 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>
Contributor
27 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2705
What
func_internal_density = avg_func_complexity / max(avg_func_loc, FUNC_EVIDENCE_MASS_FLOOR)withFUNC_EVIDENCE_MASS_FLOOR = 12besideEVIDENCE_MASS_FLOOR = 50inanalysis_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_locwithbranch/args/func_startheld. In the golden-master scan, fivefind*.sqlfiles 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 medianavg_func_loc(12.0) and floors the same 49% of the population. Below it the column is an exact rescale ofavg_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
--gateverdict changes (the cells were alreadyderived). Real code (scan DB): 574 / 2074 files with functions move, median drop 0.060, 72.3% untouched.Blast radius
raw_vector), so no Remove AST-dependent Security & Vulnerability metrics (Injection, RCE, Memory) #1020-style archetype drift.security_auditor.py:385takes the key fromtelemetry_payload, whichsignal_processornever writes. Filed as security_auditor reads func_internal_density from telemetry, but signal_processor never writes it — a permanently-zero feature in the security frame #2714, deliberately not fixed here — populating a security-frame input is a different blast-radius question and must not share a PR with this.crucible_check.pypasses in both venvs: the audit fixtures carryRaw Cognitive Densitybut not this recorder column, so the 574-row figure in the design pass (measured onfile_data) never reachestests/golden_master_*.json.Verification
tests/tools_recorders/test_func_internal_density_floor.pypins the four UEF small-file normalization isn't achieving its intent — redesign scoring so identical intent scores identically regardless of file size (design pass for Fable) #2655 properties for the per-function analog throughRecordKeeper.record_mission: invariance below the floor, no cliff at it, parity withavg_comp / avg_locabove it, zero with no functions; plus the motivating one-line-one-branch shape and the 12/50 derivation pin.audit_check.pyall clear (ruff baseline regenerated for pure line-shifts; mypy clean viacast).crucible_check.py: full_precision PASS, zero_dependency PASS.Cross-repo
keyword-rosetta: no manifest changes (the column is a derived measure, not a planted signal);
bias-history.ymlregenerates the report against engine main after merge and thefunc_internal_densityrow should leave the length-leak table.control_flow_ratiostays per #2705 decision 2 (ledger already exists; leak-check label rides with F.3). Labelrosetta:rebless-owednot needed.🤖 Generated with Claude Code