Skip to main content

Module audit_focus

Module audit_focus 

Source
Expand description

Weighted focus map (stage 4): the composite attention score per review unit plus the no-skip labels, confidence flags, and escape hatch. Public so the schema-emit binary can derive the FocusMap types. Weighted focus map (stage 4): a COMPOSITE attention score per review unit that ranks where scarce reviewer attention goes.

A 40-file diff becomes a handful of review-here pieces plus an enumerable not-prioritized remainder. The free tier RANKS but NEVER says “skip” (safe explicit-skip is paid, runtime-backed only); each unit carries a human reason; a per-unit confidence flag protects dynamically-wired / re-export-heavy code from a silent static-reachability de-prioritization; and the deprioritized escape-hatch list makes EVERY de-prioritized piece reachable.

§The composite score (deterministic, no runtime input)

score = fan_io + security_taint + risk_zone + change_shape, an integer sum (no floats, matching the partition + order engine’s determinism posture) of four deterministic signals, each derived from data the brief already retains:

  1. fan-in / fan-out (graph blast): from engine-owned focus fact helpers.
  2. security taint touch: a source -> sink taint trace touches the unit (reuse SecurityFinding.trace). Built as a pure function of a security- finding slice; the brief path carries an EMPTY slice today (security is the opt-in fallow security command, not the bare dead-code analysis), so this contributes 0 until a future epic threads a security pass. The seam is wired and tested; no taint engine runs here.
  3. risk zone: boundary / public-API / security-sensitive.
  4. change shape: new export / widened visibility / signature change (the coordination-gap proxy, ADR-001 syntactic).

§The runtime layer (paid, built)

When FocusInputs::runtime is Some (the paid --runtime-coverage path), a hot file adds an invocation-bucketed runtime component to its score so it amplifies the blast and outranks an otherwise-equal cold unit, and a unit the runtime proves cold AND that carries no deterministic signal earns the SAFE explicit-skip label (FocusLabel::Skip). When runtime is None (free mode) the layer contributes nothing: the runtime component is 0, no unit can reach the Skip arm, and the output is byte-identical to the no-runtime baseline. The free tier ranks but never skips; safe-skip is runtime-backed only.

Structs§

BoundaryZoneFile
A boundary-zone signal for a unit: the unit’s file introduced a new cross-zone edge (it is the from_file of an introduced boundary edge).
FocusInputs
Everything the focus extractor needs, gathered from the assembled brief data. All path-spaces are root-relative + forward-slashed (the brief’s canonical space), so signal joins are byte-exact.
FocusMap
The weighted focus map: the ranked review-here units plus the FULL deprioritized escape-hatch list, so nothing is hidden.
FocusScore
The composite attention score, with the deterministic component sub-scores kept on the wire so the runtime layer adds its weight without recomputing the signals.
FocusUnit
One review unit on the focus map: its file, composite score, label, human reason, and any confidence flags.
RuntimeFocus
Per-file runtime evidence for the paid weighting layer, built from the runtime-coverage health report at the brief path. None in free mode; when present it adds the runtime score component and enables the safe explicit-skip label. The two lists are disjoint by construction (a hot file is never cold).
RuntimeHotFile
A runtime-hot file: a changed file with a runtime hot path, paired with the file’s peak invocation count (the max over the file’s hot functions).

Enums§

ConfidenceFlag
A per-unit confidence flag. The EXACT panel-decided strings: a dynamically- wired or re-export-heavy unit carries one so its static-reachability signal is not trusted as complete (the anti-silent-de-prioritization guard). The flag NEVER lowers the score; it is advisory provenance.
FocusLabel
The focus label for a review unit. Skip is the SAFE explicit-skip label and is runtime-backed ONLY: it is producible solely on the paid runtime path and solely for a unit runtime-proves cold with zero risk signals. Free mode (no runtime evidence) emits only ReviewHere / NotPrioritized, never Skip (the build-focus-map labeller cannot reach the Skip arm without runtime input), so the free-tier “rank but never skip” stance holds by construction.

Functions§

build_focus_map
Build the weighted focus map from the assembled brief inputs: score each unit, label it (review-here / not-prioritized, NEVER skip), attach the reason and confidence flags, then partition into the ranked review_here list and the FULL deprioritized escape-hatch list.