Skip to content

feat(review): devops review score scores saved review sessions against a label file offline and reproduces the S11 and loop baselines #1138

Closed

Description

@dan-petty

Problem

  • Every evaluation from S5 to S21 computed precision, recall and stability by hand.
    • score_recall.py exists only inside docs/SELF_IMPROVEMENT.md:716-765.
    • The loop needed a separate matrix build (972 candidates in 295 clusters) and four analysis passes [measured].
  • The recall scorer counts fixture echoes as hits: 9 raw hits in S14–S20 were echoes or a different defect [measured: loop §6].
  • The baselines exist only as prose: S11 12/51, 11/51 and 4/30; loop 75/441 and 49/441; Jaccard 0.131 and κ 0.444; 38% of the 9 known defects per run.
  • The labels can vanish.
    • Only 111 of 295 clusters carry a machine-readable label (s11_label, prior_label_s10).
    • The loop's 99 new labels and 75 manual partitions exist only as prose.
    • The cluster files sit in another session's gitignored scratch directory, .claude/scratch/loop1221/ [.gitignore:71; measured: c-fidelity].
  • The golden set is not a commit. Golden real_defects is 24 entries with embedded files [code: tests/golden/review_findings.json], so it cannot be reviewed as it stands.
  • A deterministic pipeline gains no statistical power from repeated runs, only from more labelled inputs. Inputs used to tune rules cannot also judge them [inference].

Acceptance criteria

Key questions

Strategic alignment

Update 2026-10-09: re-scope before building (v0.2.30)

An assessor and a challenger checked this item against release/v0.2.30 (edd2578) and the local .data/reviews and .data/review-labels. Most of it is buildable and the label data exists. The amendments below are applied before building; everything else in the body stands.

  1. Drop the reference-coverage tolerance from ai runs check. Nothing records reference coverage today. Move the tolerance to feat(review): each finding group gets a model-written explanation and plan grounded in the rule's documentation at the installed tool version, kept apart from findings, with every quote, citation, version and code block checked #1147, the first item that records received ÷ needed per job, or to feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's P2-2, whose scope already lists it.
  2. Define "cost" as model calls (llm_calls). Its tolerance is --max-calls-increase. The existing prompt-token and duration tolerances apply to score runs too. Do not use cost_usd: it is 0.0 in every recorded session, because the models are self-hosted, so a tolerance on it would always pass.
  3. Identity. For new sessions, identity is the fingerprint_v2 partial fingerprint that admission records in findings.sarif (feat(review): every reported finding is admitted with its producer's anchor and a location that exists in the reviewed commit, the review writes findings.sarif, and review.md shows findings and suppressions #871), whatever algorithm fix(security): each finding keeps its own fingerprint across unrelated edits, and deduplication and correlation give one result in every input order, in devops scan and in reviews #1141 later puts behind it. For S11–S21, it is the loop's clusters, through a committed row map. Persona rows elsewhere match by path, origin page and ±5 lines. Nothing is parsed from titles. This removes the forward dependency on fix(security): each finding keeps its own fingerprint across unrelated edits, and deduplication and correlation give one result in every input order, in devops scan and in reviews #1141 (v0.2.31).
  4. fix(review): location parsing keeps placeholder, prose-laden and truncated locations #788 bullet. Reword it to "the scorer makes stored scanner paths repo-relative when it reads them" and drop fix(review): location parsing keeps placeholder, prose-laden and truncated locations #788 from Depends on. Stored sessions never change, and findings.sarif paths are already relative.
  5. Person-runs.
  6. Documentation. Pin the ADR, VISION item 8 and the KB fix to feat(review): devops review score scores saved review sessions against a label file offline and reproduces the S11 and loop baselines #1138 whatever the merge order. feat(review): every reported finding is admitted with its producer's anchor and a location that exists in the reviewed commit, the review writes findings.sarif, and review.md shows findings and suppressions #871, fix(ai): review calls through the gateway no longer stall for about 190 s on ollama, with the cause measured first #1069 and fix(ai): a failing embedding model pauses rag lookups instead of ending rag for the run, and each embedding model gets its own prompts, cache keys, dimension and bounded chunks #1065 already merged without them. The ADR takes the next free number at merge time (docs(cli): docs/TESTING.md holds the test conventions, ADR 0005 records that tests double only process edges, and AGENTS.md and the contributor docs point to them #1308 also claims 0005).
  7. κ: decided by the owner, below.

Owner decision (2026-10-09): κ uses statsmodels' fleiss_kappa, imported lazily (adds statsmodels, scipy, pandas and patsy). It needs equal ratings per subject, so κ covers the identities every session in an equal-input group reported; the loop's 0.444 (126 clusters, 730 ratings) is not recomputed.

Activity

  1. added
    type/feature
    scope/review
    on Oct 3, 2026
  2. added
    priority/p1-high
    on Oct 3, 2026
  3. added this to the v0.2.30 milestone on Oct 8, 2026
  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.30 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: P1 secret and sandbox-boundary fixes, the review tools lock and its scorer, kube-linter finding identity and a faster gate. Position 11 of 11 in the release's planned merge order. #1138 is the review scorer #1137 places ahead of its P1a items; the owner asked to place it next to #1142 and #1141. Its board Status is set to Ready, so the release-start fill keeps it.

  5. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1472, merged into release/v0.2.30 as 434c976.

    Summary

    Until now, every review evaluation from S5 to S21 worked out precision, recall and stability by hand. The baselines existed only as prose, and the loop study's labels sat in gitignored scratch files. This PR adds devops review score, which scores saved sessions against a committed label file, offline. The seed labels reproduce the published baselines: S11 12/51 lenient, 11/51 strict and 4/30 per distinct defect; the loop 75/441 and 49/441.

    • Scorer (src/devops_cli/review/score.py): devops review score SESSION... --labels FILE [--json] reports, with n beside every ratio:

      • lenient, strict and per-distinct-defect precision, also split by producer;
      • VERIFIED and HIGH/CRITICAL precision;
      • recall against the label file's recall set and against the input's known defects;
      • stability per input digest: the mean pairwise Jaccard, and Fleiss' κ from statsmodels, imported lazily (owner decision 2026-10-09).

      A ratio over a row no label covers reads "not computable", and those rows are listed. A SESSION without a readable findings.json is refused. A session that records no input digest is compared with no other. Each score is recorded as a review-score run, and the run names every figure it could not compute and why.

    • Identity:

      • In S11–S21, a row's identity is its cluster from the committed row map.
      • In any other session, it is the findings.sarif result at the row's cited place: that result's fingerprint_v2, otherwise its tool, rule, path…

    108 file(s) changed.

    How it was verified

    Check runs at bcbf7f7:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • Analyze (actions): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1138-review-score.md:

    • Label rescue: clusters.json, candidates.jsonl and clusters-method.md are in .data/review-labels/ (copied 2026-10-03); the prose labels and partitions are transcribed into tests/fixtures/review_labels/, and test_the_label_file_maps_every_s11_and_loop_row_to_a_label checks all 441 loop rows and all 51 S11 rows.
    • devops review score SESSION... --labels FILE [--json] reports lenient, strict and per-distinct-defect precision split by producer, VERIFIED and HIGH/CRITICAL precision, recall against the recall file and the known-defect list, and stability across sessions of equal input digests, with n beside every ratio: test_the_recorded_slices_reproduce_the_published_precision, test_precision_splits_by_producer, test_every_ratio_carries_its_n_in_the_table_and_the_json and test_recall_counts_the_samples_whose_report_cites_each_finding. A SESSION without a readable findings.json is refused, and a session without an input digest gets no stability: test_a_session_without_a_readable_findings_json_is_refused and test_sessions_without_an_input_digest_are_compared_with_no_other.
    • Unlabelled rows are listed, and a ratio over one reads "not computable", in the report and in devops ai runs check: test_an_unlabelled_row_is_listed_and_every_label_ratio_reads_not_computable, test_a_score_whose_new_rows_are_unlabelled_fails_the_run_check and test_a_score_figure_the_current_run_could_not_compute_fails_the_check.
    • Identity: fingerprint_v2 from findings.sarif for new sessions, the loop's clusters through the committed row map for S11–S21, and persona rows by path, origin page and ±5 lines; two tool findings at one place leave the row unlabelled: test_new_sessions_match_labels_by_fingerprint_loop_key_and_persona_window and test_two_tool_findings_at_one_place_leave_its_rows_unlabelled.
    • A location outside the reviewed tree never matches a label, and a hit whose source page is a fixture is not recall: test_a_row_outside_the_reviewed_tree_counts_as_false_without_a_label, test_a_hit_echoed_from_a_fixture_page_is_not_recall and test_echoed_known_defects_are_not_recall_in_the_slices.
    • Each label holds identity, label, defect id, expected severity, note, labeller and date, and each input is marked tuning or held-out (LabelFile, Label, LabelledInput). The loop evaluation recorded no expected severity per cluster, so 168 of the 169 seed labels leave it null, 19 of the 20 valid ones among them; see the pending seed-label review below.
    • --materialise-golden DIR writes the golden files into a repository with one fixed commit, and lists the accepted recall loss: test_the_golden_set_materialises_as_one_fixed_commit, test_commit_snapshot_makes_the_same_one_commit_of_the_same_files and test_the_committed_golden_input_lists_its_accepted_recall_loss; a DIR that is a file, or a golden file outside DIR or under its .git/, is refused before anything is written: test_materialising_into_a_directory_that_holds_files_or_a_file_is_refused and test_a_golden_set_that_cannot_be_written_is_refused.
    • The recorded slices print 12/51, 11/51 and 4/30, each loop slice its section 2 row, and the slices' Jaccard and κ: test_the_recorded_slices_reproduce_the_published_precision and test_the_loop_slices_pin_their_stability_and_pooled_precision.
    • devops ai runs check has tolerances for precision, stability and cost (model calls): test_score_runs_check_precision_stability_and_calls_at_their_tolerances, test_a_score_figure_the_current_run_could_not_compute_fails_the_check, test_only_a_figure_neither_run_recorded_goes_without_a_verdict and test_cli_runs_check_takes_the_score_tolerances.
    • The reference-coverage tolerance: moved to feat(review): each finding group gets a model-written explanation and plan grounded in the rule's documentation at the installed tool version, kept apart from findings, with every quote, citation, version and code block checked #1147, the first item that records received ÷ needed per job (feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's P2-2 also lists it).
    • Over .data/reviews, devops review score gives S11 12/51 and the loop 75/441 lenient and 49/441 strict, run offline with DEVOPS_CLI_DATA_DIR set to a temporary directory and a config without runs.index_url, so the run stayed on the workstation.
    • The ADR, VISION item 8 and the knowledge-base fix land here; CONTEXT.md's code-review terms are not changed.
    • Producer-split precision replaces feat(review): every reported finding is admitted with its producer's anchor and a location that exists in the reviewed commit, the review writes findings.sarif, and review.md shows findings and suppressions #871's original review stats --by producer.
    • The scorer makes stored scanner paths repo-relative when it reads them: test_stored_scanner_paths_are_made_relative_to_the_input_root.
    • Tests run offline with fakes and recorded tool output: no network, no real scanner, no model.
    • Each test under 1 s: met by every test of this item but one. test_the_loop_slices_pin_their_stability_and_pooled_precision is the only test that computes κ, and it pays statsmodels' import (about 0.85 s alone, 1.1–1.2 s for the test under pytest), the cost of the owner's κ decision (2026-10-09); every other test scores sessions whose inputs have one session each, or none with an identity on every row, so no other test imports statsmodels.
    • changelog.d/1138.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
    • The three tools-only runs of devops review branch --no-persona-review --no-verification on the loop input: moved to feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137's P0 exit, since they wait on fix(review): a branch review leaves the files it deletes out of persona pages and scanners, and a file a scanner cannot read does not mark the scanner failed #1140.
    • The 16 BLE001 rows in the loop's diff hunks: moved to feat(review): ruff and mypy run as review evidence with the project's settings, advisory rules report only on changed lines, and changed functions show complexity before and after #873, since no session holds them until feat(review): ruff and mypy run as review evidence with the project's settings, advisory rules report only on changed lines, and changed functions show complexity before and after #873 admits ruff findings.
    • Pending a person: review the seed labels in tests/fixtures/review_labels/labels.json, above all the 99 new reads of the loop evaluation and the golden input's accepted recall loss, and set expected_severity on the valid-strict and valid-lenient labels (19 of the 20 are null; the loop evaluation recorded none).
    • Pending a person: score golden real_defects once on the current pipeline: uv run devops review score --labels tests/fixtures/review_labels/labels.json --materialise-golden /tmp/golden, then cd /tmp/golden && uv run --project <devops-cli checkout> devops review path . --no-cache, then uv run devops review score <the new session directory> --labels tests/fixtures/review_labels/labels.json; add the session's subject.input digest to the golden input and label each listed unlabelled row with the golden defect id it is.
    • Pending a person: on a host whose load1 is above 20 (uptime), run uv run devops review branch --no-persona-review --no-verification --no-cache; the session's profile.json shows static_analyzers.Semgrep as ran and its static_analyzer_seconds.
    • uv run devops ci passes: the PR's passing checks.
  6. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/reviewtype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions