Skip to main content

Module effort_exposure

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

  1. Compute code health for every live file at HEAD via run_code_health_scoped with HealthScanCtx::head_default().

  2. Materialise a session-local eh_bands_v1(path, band, sloc) temp table from the health result, joining SLOC from complexity_metrics.

  3. Over the trailing window (opts.window_days days, 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_pct and churn_share_pct are shares of banded activity: both denominators (total_commits, total_churn) join eh_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 the max_red_effort_pct gate monotonically more permissive on repositories with heavy non-code churn. loc_share_pct is already banded (SLOC comes from eh_bands_v1).

  4. Wilson 95% CI on commit_share (k = commits touching band, n = banded window commits) is appended per row.

Structs§

EffortExposureRow
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 red band row with its improving vs degrading window-churn decomposition — the signal the red_effort_exempt_improving gate exemption reads.
run_effort_exposure_decomposed_scan
run_effort_exposure_decomposed computing the HEAD code-health scan itself — the standalone codelore analyze effort-exposure entry point, where a repository handle is available and the decomposition columns should carry real values.
run_effort_exposure_with_health
run_effort_exposure with the code-health rows supplied by the caller.
window_net_movement
Per-file net delta-health movement over the trailing window for an arbitrary set of live-at-HEAD paths, 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. None when 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.