Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ The comprehensive Value vs. Effort Prioritization Matrix, phased milestone deliv
| | `devops review verify [OPTIONS] <session>` | Record a person's or an agent's verdict on a review finding or candidate. |
| | `devops review stats [OPTIONS]` | Compute and display review accuracy statistics across saved sessions. |
| | `devops review benchmark [OPTIONS] <targets>` | Review the same files several times and report median time, LLM calls, tokens and backend busy share per stage. |
| | `devops review score [OPTIONS] <sessions>` | Score saved review sessions against a label file: precision, recall and stability, each with its n. |
| | `devops review export-feedback [OPTIONS]` | Append review verdicts to the JSONL feedback dataset, which `devops ai prompt-eval` reads. |
| | `devops review corpus COMMAND [ARGS]...` | AI-powered multi-persona code review and security audits. |
| | `devops review samples COMMAND [ARGS]...` | AI-powered multi-persona code review and security audits. |
Expand Down
15 changes: 15 additions & 0 deletions changelog.d/1138.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Added
- `devops review score SESSION... --labels FILE [--json]` scores saved review sessions against a label file, offline: lenient, strict and per-distinct-defect precision split by producer, VERIFIED and HIGH/CRITICAL precision, recall against the label file's recall set and against its input's known defects, and stability across sessions of one input digest (the mean pairwise Jaccard of their identities and Fleiss' κ of their statuses over the identities every one reported). Every ratio shows its n; 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, and a session that records no input digest is compared with no other. Each score is kept as a `review-score` run, which names each figure it could not compute and why (#1138).
- A row's identity is its cluster in a session the label file maps row by row; otherwise the `fingerprint_v2` of the findings.sarif result at its cited file and line, else that result's tool, rule, path and line or object, and results of more than one tool, rule or fingerprint at that place leave the row unlabelled; otherwise, for a model's row, the one label of its path and origin page within five lines. Nothing is read from a title. Stored absolute paths are made relative to the input's checkout, a row outside the session's reviewed tree counts as false, and a row echoed from a fixture page is no recall (#1138).
- `tests/fixtures/review_labels/labels.json` holds the seed labels of S11 and the ten loop sessions (S12–S21): a row map of all 492 findings.json rows and 169 labelled clusters, transcribed from the loop study. Scored, they give S11 12/51 lenient, 11/51 strict and 4/30 per distinct defect, and the loop 75/441 and 49/441 (#1138).
- `devops review score --materialise-golden DIR` writes the golden set's files into a git repository with one fixed commit, for a path review, and lists the 12 golden defects no tool can express as accepted recall loss. It refuses a DIR that is a file and a golden file under `.git/` (#1138).
- `devops ai runs check` takes `--max-precision-drop` and `--max-stability-drop` for review score runs, and `--max-calls-increase` for model calls, a review's cost. A precision or stability figure the baseline recorded and the run could not compute, such as precision over a new unlabelled row, fails the check and reads "not computable"; model calls are judged when both runs record them (#1138).
- ADR 0005 records that review findings come from tools and checked facts while models explain and plan, and `docs/VISION.md` item 8 becomes Evidence-First Code Reviews (#1138).
- Dependency: statsmodels 0.15.0, with scipy, pandas, patsy and formulaic, for Fleiss' κ; it is imported only when a score computes κ (#1138).

### Changed
- `devops ai runs check` also fails a run whose model calls rose more than its `--max-calls-increase` (default 20%) over the baseline's, for any two runs that both record calls, review benchmarks included (#1138).
- `docs/SELF_IMPROVEMENT.md`'s recall protocol scores its samples with `devops review score` in place of an inline `score_recall.py` script. It counts reported rows only: it no longer counts the candidates before re-ranking and verification, so its bar counts a sample that reports a set finding, not one that only found it (#1138).

### Fixed
- The knowledge base's RAG article no longer says reviews ground on whatever the index holds: a review asks the index for each page by its file path and symbol names, and for each finding it verifies by the finding's title and description, and writes nothing to it (#1138).
53 changes: 50 additions & 3 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3621,6 +3621,28 @@ devops ai review benchmark [OPTIONS] <targets>
| `--no-static-scan` | `boolean` | - | Disable static security scanning. |
| `--concurrency`, `-c` | `integer` | - | Max concurrent workers for parallel review and verification. |

#### `devops ai review score`

**Score saved review sessions against a label file: precision, recall and stability, each with its n.**

```bash
devops ai review score [OPTIONS] <sessions>
```

**Arguments:**

| Argument | Type | Required | Description |
|---|---|---|---|
| `<sessions>` | `path` | No | Review session directories to score. |

**Options:**

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--labels` | `path` | - | Label file: the labelled inputs, the row map of each mapped session and the labels, such as tests/fixtures/review_labels/labels.json. |
| `--materialise-golden` | `path` | - | Write the label file's golden set into this directory as a git repository with one fixed commit, for a path review, and list the defects no tool can express. Takes no sessions. |
| `--json` | `boolean` | - | Output findings or metrics as JSON. |

#### `devops ai review export-feedback`

**Append review verdicts to the JSONL feedback dataset, which `devops ai prompt-eval` reads.**
Expand Down Expand Up @@ -4536,7 +4558,7 @@ devops ai runs reindex [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--mechanism`, `-m` | `choice (review-benchmark|sample-validation|corpus-score|gateway-tune|prompt-eval|ai-benchmark|template-sweep)` | - | Only index runs of this mechanism. |
| `--mechanism`, `-m` | `choice (review-benchmark|sample-validation|corpus-score|review-score|gateway-tune|prompt-eval|ai-benchmark|template-sweep)` | - | Only index runs of this mechanism. |

#### `devops ai runs connect`

Expand Down Expand Up @@ -4567,7 +4589,7 @@ devops ai runs list [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--mechanism`, `-m` | `choice (review-benchmark|sample-validation|corpus-score|gateway-tune|prompt-eval|ai-benchmark|template-sweep)` | - | Only list runs of this mechanism. |
| `--mechanism`, `-m` | `choice (review-benchmark|sample-validation|corpus-score|review-score|gateway-tune|prompt-eval|ai-benchmark|template-sweep)` | - | Only list runs of this mechanism. |
| `--subject-key`, `-s` | `string` | - | Only list runs matching this subject key or prefix. |
| `--limit`, `-n` | `integer` | `20` | Maximum number of runs to show. |
| `--format`, `-f` | `string` | `table` | Output format: table or json. |
Expand Down Expand Up @@ -4635,6 +4657,9 @@ devops ai runs check [OPTIONS] <run_id>
| `--max-recall-drop` | `float` | `0.0` | Maximum allowable relative drop in recall (e.g. 0.05 for 5%). |
| `--max-duration-increase` | `float` | `0.15` | Maximum allowable relative increase in duration (e.g. 0.15 for 15%). |
| `--max-tokens-increase` | `float` | `0.2` | Maximum allowable relative increase in prompt tokens (e.g. 0.20 for 20%). |
| `--max-precision-drop` | `float` | `0.0` | Maximum allowable relative drop in a review score's lenient and strict precision (e.g. 0.05 for 5%). |
| `--max-stability-drop` | `float` | `0.0` | Maximum allowable relative drop in a review score's Jaccard and Fleiss kappa (e.g. 0.05 for 5%). |
| `--max-calls-increase` | `float` | `0.2` | Maximum allowable relative increase in model calls, a review's cost (e.g. 0.20 for 20%). |
| `--format`, `-f` | `string` | `table` | Output format: table or json. |

#### `devops ai runs baseline`
Expand Down Expand Up @@ -4689,7 +4714,7 @@ devops ai runs baseline show [OPTIONS] <subject_or_run>

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--mechanism`, `-m` | `choice (review-benchmark|sample-validation|corpus-score|gateway-tune|prompt-eval|ai-benchmark|template-sweep)` | - | Mechanism for subject lookup. |
| `--mechanism`, `-m` | `choice (review-benchmark|sample-validation|corpus-score|review-score|gateway-tune|prompt-eval|ai-benchmark|template-sweep)` | - | Mechanism for subject lookup. |
| `--format`, `-f` | `string` | `table` | Output format: table or json. |

### `devops ai cost`
Expand Down Expand Up @@ -5209,6 +5234,28 @@ devops review benchmark [OPTIONS] <targets>
| `--no-static-scan` | `boolean` | - | Disable static security scanning. |
| `--concurrency`, `-c` | `integer` | - | Max concurrent workers for parallel review and verification. |

### `devops review score`

**Score saved review sessions against a label file: precision, recall and stability, each with its n.**

```bash
devops review score [OPTIONS] <sessions>
```

**Arguments:**

| Argument | Type | Required | Description |
|---|---|---|---|
| `<sessions>` | `path` | No | Review session directories to score. |

**Options:**

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--labels` | `path` | - | Label file: the labelled inputs, the row map of each mapped session and the labels, such as tests/fixtures/review_labels/labels.json. |
| `--materialise-golden` | `path` | - | Write the label file's golden set into this directory as a git repository with one fixed commit, for a path review, and list the defects no tool can express. Takes no sessions. |
| `--json` | `boolean` | - | Output findings or metrics as JSON. |

### `devops review export-feedback`

**Append review verdicts to the JSONL feedback dataset, which `devops ai prompt-eval` reads.**
Expand Down
1 change: 1 addition & 0 deletions docs/ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ names the class each row describes. One code never maps to two exit statuses.
| `ReleaseWorkingTreeDirtyError` | `RELEASE_WORKING_TREE_DIRTY` | `1` | Git | Raised when the working tree has uncommitted changes before cutting a release. |
| `ReplyRejectedError` | `LLM_INFERENCE_ERROR` | `10` | Devops_cli.ai.client.models | Raised when the caller's validator refused a reply; it carries the reply, never cached. |
| `ReviewPoolError` | `REVIEW_POOL_ERROR` | `1` | Ai | Raised when an error occurs during parallel review worker pool execution. |
| `ReviewStateError` | `REVIEW_STATE_ERROR` | `1` | Devops_cli.review.state | Exception raised for invalid review finding state or state transition. |
| `RoadmapCardChangedError` | `ROADMAP_CARD_CHANGED` | `1` | Roadmap | Raised before a job's board write that would revert a change made since it read the card. |
| `RoadmapRefineError` | `ROADMAP_REFINE_FAILED` | `1` | Roadmap | Raised after a refine run in which the model call failed for one or more items. |
| `RoadmapRunError` | `DEVOPS_CLI_ERROR` | `1` | Roadmap | Raised when one or more roadmap jobs fail during execution. |
Expand Down
85 changes: 23 additions & 62 deletions docs/SELF_IMPROVEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ prompt is built from it: a prompt changes when someone edits a file under `ai/ta

| Data | Default path | Written by | Read by |
| :--- | :--- | :--- | :--- |
| Review sessions | `.data/reviews/<session>/` | each review | `devops review findings`, `verify`, `stats`, `export-feedback`, `corpus score` |
| Review sessions | `.data/reviews/<session>/` | each review | `devops review findings`, `verify`, `stats`, `score`, `export-feedback`, `corpus score` |
| Learned catalog | `.data/common_hallucinations.json` | a person's INVALIDATED verdict | every review |
| Mitigations ledger | `.data/mitigated_findings.json` | a person's MITIGATED verdict | branch and PR reviews, `devops pr check-readiness` |
| Feedback dataset | `.data/feedback_dataset.jsonl` | `devops review export-feedback` | `devops ai prompt-eval` |
Expand Down Expand Up @@ -972,69 +972,30 @@ evidence. The gate calls no model, so it cannot score recall; a person runs this
done
```

3. **Score.** Save the script below as `score_recall.py` and run it once per arm on that arm's
sessions, as in `python3 score_recall.py $R/b/tests/fixtures/review_recall/recall_set.json
$R/data-b/reviews/2*/`. For each finding of the set it prints how many samples found it, with a
match among the candidates before verification, and how many reported it, then the location
and title of each match. A match names the file and cites a line inside the set's range. Last,
it lists every other candidate on the set's files.

```python
import json, re, sys

recall_set, *sessions = sys.argv[1:]
entries = json.load(open(recall_set))["findings"]


def place(finding):
"""The set's path that a finding names, or None, and the first and last line it cites."""
path, _, lines = finding["location"].partition(":")
named = next(
(e["path"] for e in entries if path == e["path"] or path.endswith("/" + e["path"])),
None,
)
span = re.fullmatch(r"(\d+)(?:-(\d+))?", lines)
return named, span and (int(span[1]), int(span[2] or span[1]))


def matches(entry, finding):
path, span = place(finding)
start, end = entry["lines"]
return path == entry["path"] and bool(span) and span[0] <= end and span[1] >= start


def load(session, name):
return json.load(open(f"{session}/{name}"))["findings"]


for entry in entries:
found = [[f for f in load(s, "candidates.json") if matches(entry, f)] for s in sessions]
kept = [[f for f in load(s, "findings.json") if matches(entry, f)] for s in sessions]
print(
f"{entry['path']}:{entry['lines'][0]}-{entry['lines'][1]}",
f"found {sum(map(bool, found))}/{len(sessions)}",
f"reported {sum(map(bool, kept))}/{len(sessions)}",
)
for session, hits in zip(sessions, found):
for f in hits:
print(" ", session, f["location"], f["title"])
print("unmatched on the set's files")
for session in sessions:
for f in load(session, "candidates.json"):
if place(f)[0] and not any(matches(e, f) for e in entries):
print(" ", session, f["location"], f["title"])
```
3. **Score.** From a devops-cli checkout, score each arm's sessions with `devops review score`,
as in `devops review score $R/data-b/reviews/2*/ --labels
tests/fixtures/review_labels/labels.json`. The label file names the recall set, so the Recall
Set table shows, for each finding of the set, how many samples reported it. A row matches when
it names the file, as a repository path or through the file its cited code names, cites a line
inside the set's range, and was raised on the file's own page rather than echoed from a
fixture. A location without line numbers, as kube-linter gives, cites no line. The Unlabelled
Rows table lists every row no label covers, those on the set's files among them. The score
reads each session's reported rows (`findings.json`) only. The `score_recall.py` script this
step ran until #1138 also counted the candidates before re-ranking and verification
(`candidates.json`), and its bar counted a sample that found a set finding there; the protocol
no longer measures candidates, so it no longer tells a finding lost after generation from one
never generated, and the bar in step 4 counts reported rows.

4. **Read.** The bar counts a sample only when one of its matches describes the set's defect:
read each title, because a finding on the construct's lines can describe another defect. An
unmatched candidate that describes a set's defect on other lines counts for it too; name it in
the PR. Label every other unmatched candidate valid, opinion or false: they are what the
change adds on the set's own files. B passes when it finds each Network Exposure finding of the
set in at least 2 of its 3 samples; the Error Handling and Security Claims findings are counted
and reported, not gated. A path review shows no code to a docs page and no diff to a broad
`except`, so those two classes are measured in branch reviews; #423 carries broad excepts and
#921 the `docs/VISION.md` text. A's counts, read the same way, are the baseline. A finding that B found and
did not report was lost at verification, not at generation.
read each title (`devops review findings <session>`), because a finding on the construct's
lines can describe another defect. An unmatched row that describes a set's defect on other
lines counts for it too; name it in the PR. Label every other row on the set's files valid,
opinion or false: they are what the change adds on the set's own files. B passes when it
reports each Network Exposure finding of the set in at least 2 of its 3 samples; the Error
Handling and Security Claims findings are counted and reported, not gated. A path review shows
no code to a docs page and no diff to a broad `except`, so those two classes are measured in
branch reviews; #423 carries broad excepts and #921 the `docs/VISION.md` text. A's counts, read
the same way, are the baseline.
5. **Precision guard.** Session `20261002-205520` reported 24 findings on 15 files, and 22 of them
were false or opinion: all but the broad excepts at `pricing.py:55` and `:65`. Review those
files once from B, fresh, at T, and label each finding in the session's `findings.json` valid,
Expand Down
Loading
Loading