mvp-ai's picture
|
download
raw
7.1 kB

Scoring Algorithm

scanner.sh emits one JSON record per check with measured_value, optional reference_value, and a raw score. scorer.js coerces those raw scores, applies weights, and produces dimension and total scores.

1. Raw check scores from scanner.sh

scanner.sh produces raw scores on a 0-1 scale in six ways:

Method Checks Raw score rule
Binary pass/fail F1, F2, F3, F4, F5, F6, F7, F9, W1, W2, W3, W4, W5, W6, W7, W8, W11, C2, C3, C4, C5, C6, I5, I7, S1, S3, S4, S5, S6, S7, S8, S9, H4, H6, H8 1 if the condition is met, else 0.
Upper-bound score I2, C1 1 when measured <= reference, else reference / measured.
Average of upper-bound sub-scores I1 Average of 4 keyword scores for IMPORTANT, NEVER, MUST, and CRITICAL, each using the upper-bound rule above.
Ratio score I3, I4, F8, H1, H2, S2 Measured ratio clamped to 0-1. I3 = Don't-with-Because / Don't-total; I4 = action / (action + identity); F8 = uses-globs / total-scoped; H1 = valid-events / total-events; H2 = with-matcher / total; S2 = pinned / total.
Range score I6, I8 1 inside the [low, high] reference range, measured / low below, high / measured above.
Tiered score H3, H5, H7, W9, W10 Discrete levels: H3 = 1 all Stop hooks guarded, 0.5 some unresolvable paths, 0 any unguarded; H5 = 1 deny covers .env + variants or no .env deny, 0.5 .env denied but variants missing; H7 = 1 gate workflow blocks (exit 1), 0 warn-only; W9 = 1 release.yml validates tag↔manifest version, 0.5 tag-only, 0 none; W10 = 1 pyproject has 3+ pytest markers, 0 no Python project (N/A) or no markers.
Extended (opt-in) D1, D2, D3, SS1, SS2, SS3, SS4 Not emitted by scanner.sh. Produced by deep-analyzer.js + AI sub-agent (D1-D3) or session-analyzer.js reading local Claude Code session logs (SS1-SS4). not_run by default — see §3 and §4.

Notes:

  • F4 has a reference value in reference-thresholds.json, but the scanner still scores it as binary: a large directory either has an index or it does not.
  • F5 measures broken reference count, but the score is still binary: any broken reference makes the check score 0.
  • W6 uses static analysis of hook file content (not execution) to estimate hook speed.

2. Score coercion

scorer.js normalizes incoming scores before weighting:

0 <= value <= 1    -> keep as-is
1 < value <= 10    -> divide by 10
10 < value <= 100  -> divide by 100
otherwise          -> 0

This allows scanners to emit 0-1, 0-10, or 0-100 values while the scorer works on a single normalized scale.

3. Dimension scoring

Each dimension score is a weighted average of its checks, then scaled to the dimension maximum (10):

dimension_raw = sum(check_score * check_weight) / sum(check_weight)
dimension_score = round(dimension_raw * 10)

A dimension has a status of run or not_run. A dimension is not_run when no checks for it were emitted by the scanner; its score is then null, not 0. This distinguishes "evidence gathered and scored 0" from "no evidence to score" and is the reason CI totals are honest.

Core dimensions

These run by default from CLI, GitHub Action, and Claude Code /al. Their weights sum to 100%.

Dimension Weight Max
Findability 20% 10
Instructions 25% 10
Workability 18% 10
Continuity 12% 10
Safety 15% 10
Harness 10% 10

Extended dimensions (opt-in)

These require runtime conditions CI cannot provide, so they are not_run by default. They only appear in the total when /al is used with the matching opt-in boxes checked.

Dimension Weight Runtime requirement
Deep 5% (when run) AI sub-agent (Claude Code skill)
Session 5% (when run) Local Claude Code session logs at ~/.claude/projects/

Check weights (all 58 checks — source of truth is standards/weights.json):

ID Weight ID Weight ID Weight ID Weight
F1 3 F2 1 F3 2 F4 1
F5 2 F6 1 F7 2 F8 1
F9 2 I1 1 I2 2 I3 2
I4 1 I5 1 I6 1 I7 2
I8 1 W1 3 W2 1 W3 2
W4 1 W5 2 W6 1 W7 2
W8 1 W9 2 W10 2 W11 2
C1 3 C2 2 C3 1 C4 1
C5 1 C6 1 S1 2 S2 2
S3 1 S4 1 S5 1 S6 3
S7 1 S8 1 S9 2 H1 2
H2 1 H3 2 H4 3 H5 1
H6 1 H7 2 H8 1 D1 1
D2 1 D3 1 SS1 1 SS2 1
SS3 1 SS4 1

This table is kept in sync with standards/weights.json by tests/test-surface-sync.js. See docs/content/checks.md for each check's name, evidence, and fix guidance.

4. Total score and score_scope

The total score is the weighted average of run dimension scores (skipping not_run entirely), scaled to 100:

total_raw = sum((dim.score / dim.max) * dim.weight)  // run dims only
          / sum(dim.weight)                          // run dims only
total_score = round(total_raw * 100)

Not-run dimensions are skipped in both numerator and denominator. They are never treated as 0 — that would pull the total down every time Deep or Session doesn't run, which is almost always in CI.

The scorer emits a companion field score_scope:

score_scope Meaning
core Total reflects the 6 core dimensions only (Deep and Session are both not_run). This is the default and the only value CI ever produces.
core+extended At least one extended dimension ran, so its weight and score are included in the total.

Consumers (terminal reporter, HTML, GitHub Action outputs) display the scope so that 89/100 (core) and 89/100 (core+extended) are clearly different statements, not comparable single numbers.

5. Reference values

Reference values are comparison points used by some checks to turn measurements into scores. They live in standards/reference-thresholds.json and currently include:

  • I1_emphasis: comfortable counts for emphasis keywords.
  • I2_density: comfortable keyword density per 1,000 words.
  • I3_formula_ratio: reference ratio for specific rule structure.
  • I6_length: reference line-count range for entry files.
  • I8_total_lines: reference non-empty-line range for total injected content.
  • C1_freshness_days: reference age for doc freshness.
  • F4_index_threshold: recommended file-count threshold before an index is expected.
  • H1_valid_events: valid Claude Code hook event names.
  • H4_dangerous_patterns: dangerous auto-approve permission patterns.

These values come from empirical sources summarized in standards/evidence.json. They are not pass/fail gates; they are reference points used to measure deviation and support comparison across repos.

Xet Storage Details

Size:
7.1 kB
·
Xet hash:
4c61b45a5d9422ce62c317984b9892d4df2b8dac9c435c82bd7b9eace3499707

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.