Repository navigation
feat(metrics): evidence-mass floor replaces the UEF's six small-file guards (#2655) - #2667
Merged
Merged
Conversation
…guards (#2655) Every per-file density equation now divides by max(coding_loc, 50) instead of raw LOC. Below the floor a file is scored on its counts, so identical planted intent scores identically at any length; from 51 LOC up the density regime is byte-identical to before (the +20 pads and paddings stay on top of the floor). This one mechanism replaces the <15-LOC cognitive-load cliff, the loc/15 bureaucracy dampener, the unbounded irc/loc floor and api's max(total_loc, 10). Consistency rules that ride along: zero measured evidence scores zero in every tier (irc corrects risk, never creates it) for documentation and cognitive load; a branchless file carries no cognitive load at any length (was: only >50 LOC, with a 5.0 floor <15); spec alignment is 0 when there is nothing to specify. Telemetry gains evidence_mass / mass_floored. Evidence: on the keyword-rosetta corpus, groups of languages with identical formula inputs now have 0.00 output range on all seven affected metrics (was up to 77 points). New tests/core_engine/test_uef_length_invariance.py pins invariance, continuity at the floor, parity at 51 LOC against origin/main, and tier ordering; tests/tools/audit_length_invariance.py is the length-axis twin of audit_risk_equations.py. Wiki 08-03/05/08/09/14/16 updated (08-14 now documents the formula the code actually ships). Co-Authored-By: Claude Fable 5.1 <[email protected]>
…2655) Both fixtures regenerated via crucible_check.py --update --yes. Scoped diff over the per-file records: 1,324 files under the 50-LOC floor moved (count regime); at >=50 LOC only the approved zero-evidence rules moved (documentation -> 0 in 402 files with no API surface, spec -> 0 in 146 files with no entities) plus the branchless cognitive-load rule at exactly 50 LOC (3 files). 1,065 files are byte-identical; 0 unexplained movements in either fixture. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contributor
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.
Resolves #2655
Problem
Every per-file risk score is a density (
hits / LOC) pushed through a sigmoid. On the keyword-rosetta control corpus (identical planted intent in 46 languages, files of 3–29 coding LOC) one planted hit is 3–33% density and lands on the sigmoid ceiling, so file length, not content, decided the score. Six independent small-file guards had accreted to soften this, each firing on a different LOC range with a different shape, and they fought each other:if safe_loc < 15: return 5.0_calc_cog_loadloc + 20Laplace padbureaucracy_dampener = min(loc/15, 1)irc / safe_loc+ircin doc/debtmax(total_loc, 10)safe_mass_floor = 50The corpus was rescanned (46 languages, 184 files) and every equation re-invoked directly from the scan DB's raw signals; the harness reproduces every stored score to 0.000, so the attributions in #2655 could be checked exactly. Two of them are not what they looked like: the config/DSL tech-debt swing is orphan/duplicate synthesis in main/b files (every c file scored exactly 100 in all 45 languages), and fortran's state-flux "inversion" is two saturated files averaged (one mutation in a 10-line c.f90 scores 87). Both are length saturation on top of §2 effects, not a formula inversion.
Root cause
There was no single small-file mechanism; density was being estimated from files far too short to estimate a density from, and each patch addressed one symptom on one LOC range.
Fix: the evidence-mass floor
One shared denominator,
_mass_loc(loc) = max(coding_loc, ENGINE_CONSTANTS["EVIDENCE_MASS_FLOOR"] = 50), in every per-file density equation. Below the floor a file is scored on its counts — a 2-hit file is a 2-hit file whether it is 5 or 49 lines long — so identical intent scores identically at any length. From 51 lines up the density regime is byte-identical to before (the+20pads and paddings are kept on top of the floor for exactly that reason).maxis continuous, so there is no cliff. This is the per-file analog of the mass-weighted averaging the directory scope already applies, and it generalises graveyard's existingsafe_mass_floor.Two consistency rules ride along, both approved in the design pass:
Irccorrects measured risk; it never creates it. Documentation returns 0 when there is no API surface and no load-bearing undocumented block (safety, tech debt, concurrency and state flux already followed this convention); cognitive load returns 0 for a branchless file at any length (was: only above 50 LOC, with a flat 5.0 below 15 — a cliff at 15 and a discontinuity at 50/51 for the same file). Spec alignment returns 0 for a file with no functions or classes (was a flat 100 hidden by the dampener).bureaucracy_dampeneris removed. The floor is now the only small-file mechanism.Files below the floor carry
mass_floored: trueand theirevidence_massin telemetry (option 1's flag, without option 1's neutral tier).Why 50: it is the engine's existing unit of mass (
file_impact = loc/50, graveyard's floor, theloc > 50cog rule), every corpus file sits under it with 21 lines of headroom, and it splits the golden-master corpus at its median (1,299 of 2,624 scored files are under 50 coding LOC).Options 2 (shrinkage — what safety/doc already did, 2.4× residual) and 3 (Wilson lower bound — still scales with 1/n; 2 hits give 0.057 at n=10 vs 0.014 at n=40, a wider swing) were evaluated and rejected; option 4 (density-scale Irc) is subsumed by the floor bounding
irc/locand is otherwise #2653's remit.Evidence
tests/tools/audit_length_invariance.py, new): the SPEC's four planted vectors × 3 tiers × LOC 3..300. Identical below the floor, no jump > 2.5 at the boundary (the steepest legitimate step is tech debt's 1.2), unchanged at 51/100/300 against the pre-change engine.PATH_MODIFIERS"config" regex matches the corpus directory namesdata/jcl/anddata/makefile/, applying cog ×0.70 to those two folders — a bias source outside both the registry and the formulas, to be ledgered in keyword-rosetta.Tests and audits
tests/core_engine/test_uef_length_invariance.py(new): invariance below the floor, continuity at it, parity at 51 LOC against values pinned from origin/main, tier ordering preserved in the count regime, zero-evidence rules, spec-needs-entities.test_signal_processor_small_file_floor_still_applies(pinned the removed 5.0 floor) rewritten as..._small_file_scores_on_countsplus..._branchless_file_zero_cog_at_any_length.tests/tools/audit_length_invariance.py(new): the length-axis twin ofaudit_risk_equations.py. Both audits pass;audit_check.pyclean (ruff baseline regenerated for pure line shifts only).crucible_check.py --update --yes, both modes. A scoped diff over the per-file records (2,624 scored files, identical shape in both fixtures): 1,324 files under the floor moved (count regime, including 25 zero-coding-LOC files that were scored as 1 line); the only ≥50-LOC movements are the approved zero-evidence rules (documentation → 0 in 402 files with no API surface, spec → 0 in 146 files with no functions or classes) and the branchless cognitive-load rule at exactly 50 LOC (3 files); every other ≥50-LOC exposure is byte-identical (1,065 files untouched). 0 violations.Docs
docs/wiki/08-03gains the fifth UEF principle ("Evidence-Mass Floor"); 08-05, 08-08, 08-09, 08-16 formulas updated to the floored denominator; 08-14 rewritten to what_calc_api_exposureactually computes (the page described a 40/60 ratio-plus-volume blend the code never shipped; theapi_exposuretuning keys are unread).Cross-repo
rosetta-auditstays green andKEYWORD_ROSETTA_REFdoes not move. After this merges, regeneratedocs/bias_report.md(§3 rows re-baseline as described above) and ledger thedata/jcl//data/makefile/path-modifier finding. Engine merges first; the corpus report is a pure regeneration.🤖 Generated with Claude Code