Expand description
The metric catalog, read from metrics/builtin.toml: [categories.*],
[ast.*] (tier-1 measured), [fields.*] (derived, each a formula_cel), and
the [report] view section (+ [report.stats] aggregate formulas).
The crate root re-exports the accessors below; the tier-1 input types
(MetricInputs / FunctionUnit) come from code-ranker-plugin-api.
Wire encoding:
- the executable
formula_celis internal; the emittedAttributeSpeccarriesformula(fromformula_pretty) andcalc(fromformula_js); name/shortfall back tolabel(a field only spells out what differs);\nin a description (TOML multiline) is encoded as<br>on the wire;- the
statsblock is produced bycrate::stats::compute_statsover the keys whose[report.stats]entry is a plain mean (agg('<k>','avg','not_empty')); the richer aggregate formulas are parsed and available but not yet wired into the built-in stats.
Structs§
- Views
- The canonical view orders read from
builtin.toml.columnsandfeaturedare flat ordered lists (they may include non-field tokens likekind,cycleand coupling keys);default_sortis the signed-rank list.
Functions§
- aggregate_
formulas - All
[report.stats]formulas (output key → graph-scope CEL). Parsed and available for the future graph-scope aggregate engine; not yet driving the built-instatsblock (seestat_keys). - coupling_
specs - The coupling/cycle attribute dictionary (
fan_in/fan_out/fan_out_external/cycle) + thecouplinggroup, read frombuiltin.toml[coupling.*]. The VALUES are computed post-walk byannotate_coupling/annotate_cycles; these are the display specs only (incl. thedescription=whyandremediation=fixshown bycheck). The orchestrator merges them into each level’snode_attributes/ groups. (hk’s spec ships with the derived[fields.*]viametric_specs.) - cycle_
specs - The cycle-kind diagnostic vocabulary (
mutual/chain) frombuiltin.toml[cycles.*]— label +description(why) +remediation(fix). The orchestrator overlays these onto each level’scycle_kinds. - metric_
specs - The metric attribute dictionary + category groups, read from
builtin.toml. Includes the emitted measured metrics ([ast.*]entries that carry a display spec, i.e. have alabel) and every derived[fields.*]metric. Pure AST inputs (nolabel) are excluded — they are formula inputs, not emitted. - prompt_
template - The Prompt-Generator scaffolding prose, parsed from
metrics/prompt.md— the language-neutral framing carried in the snapshot so the CLIpromptformat and the HTML viewer render the same text. Each## <field>section maps to aPromptTemplatefield;## taskkeeps one entry per non-blank line (verbatim, including the leading-), the rest join their body into one line. - prompt_
template_ from - Parse caller-supplied prompt-scaffolding Markdown (same
## <field>shape as the built-inmetrics/prompt.md) into aPromptTemplate— the hook a[templates] prompt = "…"config override flows through. - stat_
keys - The metric keys aggregated into the per-graph
statsblock via the mean (compute_stats). Derived from[report.stats]: the keys whose formula is a plain mean of their own metric overnot_empty(agg('<k>', 'avg', 'not_empty')). The richer aggregate formulas (percentiles,allpopulation, …) are parsed but not yet wired into the built-in stats. - views
- The canonical view orders (table columns + default sort, card metrics, map
size/filter), all from the single
[report]section ofbuiltin.toml. - write_
derived - Compute the graph-derived built-in metrics ([
GRAPH_DERIVED], e.g.hk) ontonode, AFTER the coupling pass has writtenfan_in/fan_out. Reads the node’s own (already-rounded) numeric attributes — exactly the values the former Rusthkread viaattr_f64— so emitted values are unchanged. Pre-graph fields (volume/mi/…) are NOT recomputed here: they are written bywrite_metricsfrom the raw, unrounded tier-1 counts and must not be re-derived from the rounded node attributes. Each value is dropped at itsomit_at. No-op when no[fields.*]is graph-derived. - write_
metrics - Write the per-unit built-in metrics onto
node: the tier-1 measured values (the LOC block is emitted only whensloc > 0) plus the pre-graph derived metrics ([DERIVED]) computed from the raw tier-1 counts. Graph-derived fields (e.g.hk) are written later bywrite_derived, once the coupling pass has run. Each value is dropped at itsomit_at.