Skip to content

feat(review): each review session writes a job result line #5170

Open

Description

@dan-petty

Part of #5164 (child 5).

Problem or Motivation

devops review is an agentic workflow that agents run on each branch and pull request. It writes no result line, so it gets no grade (#5164). devops review stats and the verdicts (docs/SELF_IMPROVEMENT.md) measure the precision of the findings, but no measure says how many review sessions end complete, how many retry a chunk or fall back to another model, and what a session costs.

Proposed Solution & Architectural Design

  • Add the job review to the result line (roadmap/job_result.py).
  • Attempt: one review session of a pull request, a branch or a path.
  • Results: completed (each file of the target reviewed and the report written), partial (a chunk failed or a budget stopped the session), failed. Intended result: completed.
  • First pass: completed with chunk_retries = 0 and fallbacks = 0.
  • Counts: files, chunks, chunk_retries, fallbacks, findings, and the attempt counts of the result line (model_calls, tokens, seconds, cost_usd_micros, gh_requests).
  • repo is the repository of the target, and item is the pull request number or none.
  • The precision of the findings stays in review stats. The grade report shows it next to the grade when verdicts exist.

Target Subsystem

AI & Agentic Review Pipeline (src/devops_cli/review/).

Existing Tool Considered

devops review stats reads the verdicts and gives precision, not the success of a session. The line uses the writer of the roadmap jobs; no new tool. Cost: about 200,000 tokens, 5 hours elapsed.

Acceptance Criteria

  • A test review session with a fake model writes one line with result=completed first_pass=true.
  • A session with one failed chunk writes result=partial and the class of the error.
  • devops roadmap eval grades lists review.

Dependencies

#5168 (the attempt context and first_pass), #5169 (a local run sends the line to Loki).

Owner decision 2026-11-13

The approved pipeline split (tracker #5482, Phase 7) uses this result line in the review unit (#5521).

  • Live proof: after the merge and the release, a review session runs on an open bot PR. A comment gives its result line.

Proposed design

Problem statement

devops review writes no result line, so its sessions get no grade. The change adds a code_review job result line (the review job name already belongs to the roadmap verdict step, #5969) with the session result, the first-pass state, the file and finding counts and the cost. Finding precision stays in devops review stats.

Acceptance criteria

Requirement: Review session result line

Each review session SHALL write one job result line with job="code_review".

Scenario: A completed session writes one line

  • WHEN a test review session runs with a fake model over one file and writes its report
  • THEN the line has job=code_review, result=completed, success=true, first_pass=true, files=1 and findings=0, with the attempt counts of the session.

Requirement: Partial result on a failed file

A review session SHALL write result="partial" when a file unit fails or a budget stops the session and the report is still written.

Scenario: A failed file unit records partial

  • WHEN a test review session has one file unit that fails with an AIClientError and writes its report
  • THEN the line has result=partial, success=false and class=provider.

Requirement: Failed result with no report

A review session SHALL write result="failed" when it ends with no report.

Scenario: A session that raises before its report records failed

  • WHEN a test review session raises an AIClientError before it writes its report
  • THEN the line has result=failed, success=false and class=provider.

Requirement: First pass from retry and fallback counts

The code_review result line SHALL set first_pass=false when chunk_retries or fallbacks is not zero.

Scenario: One chunk retry clears first pass

  • WHEN a test logs a code_review line with result=completed and chunk_retries=1
  • THEN the line has first_pass=false and chunk_retries=1.

Requirement: Review counts and attempt counts

The code_review result line SHALL carry the review counts and the attempt counts of the session.

Scenario: Counts come from the session

  • WHEN a test review session reviews two files and raises one finding
  • THEN the line has files=2 and findings=1, and model_calls, tokens, seconds, cost_usd_micros and gh_requests from the attempt context.

Requirement: Target repository and item

The code_review result line SHALL set repo to the target repository and item to the pull request number, or none for a branch or path target.

Scenario: A pull request target records its item

  • WHEN a test review session targets pull request 123 of owner/repo
  • THEN the line has repo=owner/repo and item=#123.

Requirement: Grade report lists code_review

The grade report SHALL list code_review when a result line for job code_review exists.

Scenario: The grades command lists code_review

  • WHEN the test runs uv run devops roadmap eval grades with a fake Loki client that returns one result line for job code_review
  • THEN the output lists code_review.

Existing Tool Considered

OpenTelemetry logs (open, maintained, CNCF; https://opentelemetry.io/docs/specs/otel/logs/) covers one structured line per attempt and its export to the collector and Loki, which the project already uses for these lines (docs/roadmap/job-success.md:22, #5169). It lacks the roadmap job schema: the job set, the intended results, the first-pass rules and the grade are the project's own in src/devops_cli/roadmap/job_result.py. devops review stats gives finding precision only, not the success of a session. The change extends the existing writer rather than building a second one; written cost: about 200,000 tokens and 5 hours elapsed.

Key questions

  • Where should the review session's result line be written?: Extend the existing result-line writer in src/devops_cli/roadmap/job_result.py (log_job_result) and call it once from execute_review_workflow in src/devops_cli/ai/review/runner.py, so every path, branch and pull request session writes one line. Do not add a second writer. (best practice) [sources: src/devops_cli/roadmap/job_result.py:269, src/devops_cli/ai/review/runner.py:1369, docs/roadmap/job-success.md:7]
    • Chosen: Extend roadmap/job_result.py. The grade reads one schema and one job set, and the OpenTelemetry handler already exports this module's lines.
    • Rejected: A review-specific result writer. It duplicates the schema, and devops roadmap eval grades cannot read it.
  • Which job name does the review session's line use?: code_review. The name review already belongs to the roadmap step that gives a bot pull request a verdict (RoadmapJob.REVIEW, results judged and failed, feat(roadmap): a review job gives each bot PR its verdict #5969), so a second review job would collide with that job's result enum, success set and grade. code_review names the devops review session and its report. (best practice) [sources: src/devops_cli/roadmap/job_result.py:61, src/devops_cli/roadmap/job_result.py:108, docs/roadmap/job-success.md:39, src/devops_cli/ai/review/runner.py:1369]
    • Chosen: code_review. It names the command's work and does not collide with the review job of the roadmap verdict step.
    • Rejected: review. RoadmapJob.REVIEW exists with its own result enum and success set (feat(roadmap): a review job gives each bot PR its verdict #5969); a second review breaks the one-job-one-result-set rule and the grade.
    • Rejected: review_session. It puts review and review_session side by side in the job table, where a reader confuses the roadmap step with the code review command.
  • Which review outcome maps to each result value?: completed when each file of the target is reviewed and the report is written; partial when a file unit fails or a budget stops the session and the report is still written; failed when the session writes no report. success is true only for completed, and the job's result enum holds the three values. (best practice) [sources: src/devops_cli/ai/review/runner.py:1369, src/devops_cli/ai/review/runner.py:1487, docs/roadmap/job-success.md:26]
    • Chosen: Map the report and the file units to the result. The report and the state of each file unit are the observable facts of a session.
    • Rejected: Use the exit code only. A session stopped by a budget can exit with a report and is not a failure.
  • How is first_pass set for a review session?: Add code_review to FIRST_PASS with CountLimit("chunk_retries", 0) and CountLimit("fallbacks", 0). is_first_pass then returns true only for a completed session with both counts at zero, and a retry or a fallback clears it. (best practice) [sources: src/devops_cli/roadmap/job_result.py:121, src/devops_cli/roadmap/job_result.py:172, docs/roadmap/job-success.md:90]
    • Chosen: Derive from the retry and fallback counts. The writer's first-pass rule already reads the counts of the job, and the counts are the fix rounds of a session.
    • Rejected: Set from the session exit code. A retry that succeeds still exits zero but is not a first pass.
  • Does the review session retry a chunk or fall back to another model today?: No. execute_review_workflow builds one orchestrator and runs each file's payload once through ReviewWorkerPool; no module under src/devops_cli/ai/review/ retries a chunk or counts a model fallback. The chunk_retries and fallbacks counts have no producer in the session yet. [sources: src/devops_cli/ai/review/runner.py:1369, src/devops_cli/ai/review/runner.py:1487, src/devops_cli/ai/review/pool.py:53]
  • Which counts belong in the review session's result line?: files and findings from the session, plus model_calls, tokens, seconds, cost_usd_micros and gh_requests from the attempt context. chunks is not a unit of the session (the pipeline runs one payload per file), and chunk_retries and fallbacks are deferred until the session has the retry and fallback behavior that produces them. (best practice) [sources: src/devops_cli/roadmap/job_result.py:207, src/devops_cli/ai/review/runner.py:1369, src/devops_cli/ai/review/pipeline.py:1]
    • Chosen: Add the review counts to the existing line. The grade and the cost report read one line, and the attempt context already holds the efficiency counts.
    • Rejected: A separate review metrics file. It adds a second source, and the grade cannot join it.
    • Rejected: Report chunk_retries and fallbacks now. The session records neither count, so the line would carry a number that no code measures.
  • How should a partial or failed session record the error?: Put the FailureClass of the stopping error in the line's class field (provider for a model failure, limit_reached for a budget stop), and keep the message out of the line. The writer takes a FailureClass and writes its value; the line has no error field, and a Python exception class name is not a value of the taxonomy. (best practice) [sources: src/devops_cli/roadmap/job_result.py:269, src/devops_cli/roadmap/failure.py:67]
    • Chosen: Record the FailureClass. The class is a fixed name of the taxonomy, stable across versions, and reveals no secret.
    • Rejected: Record the Python class name. The line's class field takes a FailureClass; a Python class name is not one, and the line has no error field.
    • Rejected: Record the full error message. The message can hold paths, tokens or user data.
  • How does devops roadmap eval grades list code_review?: Add code_review to RoadmapJob. The grade report lists every member of RoadmapJob, so the job appears with no change to the command, and the test that maps each job to its result enum in tests/roadmap/test_job_result.py:84 gets the new job's enum. (best practice) [sources: src/devops_cli/roadmap/job_grade_report.py:523, tests/roadmap/test_job_result.py:84, docs/ROADMAP_WORKFLOW.md:496]
    • Chosen: Add code_review to the shared job set. One list keeps the writer, the grade report and the result-enum test in step.
    • Rejected: Hard-code code_review in the grades command. The writer would accept a job that the grade report does not know.
  • Does the result line replace devops review stats?: No. devops review stats remains the source of finding precision; the result line records the session outcome and its cost. The grade report shows the precision next to the grade only when verdicts exist. (best practice) [sources: docs/SELF_IMPROVEMENT.md:91, docs/commands/review.md:244, src/devops_cli/commands/review.py:1388]
    • Chosen: Keep precision in review stats. Precision needs verdicts, and the result line records the outcome of a session.
    • Rejected: Move precision into the result line. A session can have no verdict, so the line cannot hold precision.
  • Which approved pipeline split uses this result line?: The approved pipeline split into jobs is tracker feat(roadmap): track the roadmap pipeline split into jobs #5482 (P3, AW-J1), recorded at docs/ROADMAP_WORKFLOW.md:518; the issue's Owner decision of 2026-11-13 places this result line in its review unit (feat(roadmap): a review unit posts a COMMENT review on each ready PR #5521). [sources: docs/ROADMAP_WORKFLOW.md:518]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/review
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

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

    effort/mediumpriority/p2-mediumscope/reviewsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions