Module effort_exposure
Expand description
effort-exposure analysis — what fraction of engineering activity
(commits, churn) flows into each code-health band (red / yellow / green).
Answers the hero KPI question: “Are we spending most of our energy improving healthy code, or fighting fires in the red zone?” A team with ≥50% of commits in the red band is in reactive mode; a team with ≥70% in green is proactively maintaining its healthiest files.
§Algorithm
-
Compute code health for every live file at HEAD via
run_code_health_scopedwithHealthScanCtx::head_default(). -
Materialise a session-local
eh_bands_v1(path, band, sloc)temp table from the health result, joining SLOC fromcomplexity_metrics. -
Over the trailing window (
opts.window_daysdays, anchored to the repo’s last commit date — reproducible on old repos), compute per band:files— distinct files in the band (live at HEAD).loc_share_pct— percentage of total SLOC in the band.commit_share_pct— percentage of window commits touching ≥1 file in the band. One commit touching files in multiple bands is counted once per band (percentages across bands can therefore sum > 100%).churn_share_pct— percentage of window LOC churn (added + deleted) in the band.
commit_share_pctandchurn_share_pctare shares of banded activity: both denominators (total_commits,total_churn) joineh_bands_v1, so commits and churn on unscored paths — lockfiles, generated code, docs, anything without a code-health row — are excluded from denominator as well as numerator. Otherwise those paths would inflate the denominator alone, understating every share and making themax_red_effort_pctgate monotonically more permissive on repositories with heavy non-code churn.loc_share_pctis already banded (SLOC comes fromeh_bands_v1). -
Wilson 95% CI on
commit_share(k = commits touching band, n = banded window commits) is appended per row.
Structs§
- Effort
Exposure Row - One row per code-health band in the trailing activity window.
Functions§
- run_
effort_ exposure - Run the effort-exposure analysis.
- run_
effort_ exposure_ decomposed - Run effort-exposure and enrich the
redband row with its improving vs degrading window-churn decomposition — the signal thered_effort_exempt_improvinggate exemption reads. - run_
effort_ exposure_ decomposed_ scan run_effort_exposure_decomposedcomputing the HEAD code-health scan itself — the standalonecodelore analyze effort-exposureentry point, where a repository handle is available and the decomposition columns should carry real values.- run_
effort_ exposure_ with_ health run_effort_exposurewith the code-health rows supplied by the caller.- window_
net_ movement - Per-file net
delta-healthmovement over the trailing window for an arbitrary set of live-at-HEADpaths, sharing the improving-churn exemption’s window-start machinery: HEAD function metrics from the fact store ([head_function_metrics]), the window-start baseline parsed per file ([base_function_metrics]), and the [net_movement] classification. - window_
start_ rev - The revision representing a file’s state entering the trailing window: the
newest commit strictly before the window opened.
Nonewhen the window spans all history (no pre-window commit) — every file is then judged as newly-added, which is also the “history shallower than the window” signal the[new_code]gate skips on.