Skip to content

feat(review): a review session records its head commit and clean tree, and says whether it is on merged code #2415

Closed

Description

@dan-petty

Problem or Motivation

Part 1 of #883 (owner decision 2026-10-28 on #883). A review session records no head commit and no clean-tree flag, so no code can tell a session "on merged code" from a session on a topic branch or a dirty tree.

  • review_subject (src/devops_cli/ai/review/history.py) holds the target type, the ref and a digest of the pages.
  • ReviewProfile (src/devops_cli/ai/review/profile.py) holds target, and the tree commit only inside each tool run record.

Proposed Solution & Architectural Design

  • The session record (findings.json) records the head commit and whether the working tree was clean when the review started.
  • One function decides whether a session is on merged code: its target type is path, its tree was clean, and git merge-base --is-ancestor <head> origin/main passes. It sends no GitHub request.
  • review pr and review branch sessions are never on merged code.

Target Subsystem

Review sessions: src/devops_cli/ai/review/history.py, the session writer, and src/devops_cli/review/.

Existing Tool Considered

git (rev-parse HEAD, status --porcelain, merge-base --is-ancestor) gives every fact. Nothing new is built beyond two recorded fields and one predicate.

Acceptance criteria

  • A review path session on a clean tree records its head commit and clean: true. A dirty tree records clean: false.
  • The merged-code predicate is true only for a path session on a clean tree whose head is an ancestor of origin/main. A parametrized test covers pr, branch, a dirty tree and a head that is not on origin/main, with git faked at the process edge.
  • The tests run offline.

Related

Parent: #883. Sibling items: the fingerprint marker, and the devops review intake command.

Source: #883

Proposed design

Problem statement

A review session does not record its head commit or whether the working tree was clean at review start. No code can tell a session on merged code apart from one on a topic branch or a dirty tree. This issue adds two fields to the session record and one predicate that decides whether a session is on merged code, using only local git commands.

Acceptance criteria

  • Criterion 1: A review path session on a clean tree records its head commit and clean: true in findings.json. A dirty tree records clean: false.
    Verification: Run devops review path on a clean tree and confirm findings.json contains the head commit and clean: true. Run it on a dirty tree and confirm clean: false.
  • Criterion 2: The merged-code predicate returns true only when the target type is path, the tree was clean, and git merge-base --is-ancestor origin/main exits 0.
    Verification: A parametrized test covers pr, branch, a dirty tree, and a head not on origin/main. Git is faked at the process edge. Each case asserts the expected boolean.
  • Criterion 3: The tests run offline with no network access.
    Verification: Run the test suite with network disabled. All tests pass.

Key questions

  • Where are the head commit and clean-tree flag recorded?: In the session record (findings.json), as new fields written by the session writer in the runner. (proposed) [sources: src/devops_cli/ai/review/runner.py:1583, src/devops_cli/ai/review/history.py]
  • What conditions make a session on merged code?: Three conditions must all hold: the target type is path, the tree was clean, and git merge-base --is-ancestor origin/main exits 0. (proposed) [sources: src/devops_cli/ai/review/history.py]
  • Does the merged-code predicate send a GitHub request?: No. It uses only local git commands: rev-parse HEAD, status --porcelain, and merge-base --is-ancestor. (proposed) [sources: src/devops_cli/ai/review/history.py]
  • Are review pr and review branch sessions ever on merged code?: No. They are never on merged code because their target type is not path. (proposed) [sources: src/devops_cli/ai/review/history.py]
  • Which git commands provide the facts the predicate needs?: rev-parse HEAD for the head commit, status --porcelain for the clean-tree flag, and merge-base --is-ancestor for the ancestry check. [sources: src/devops_cli/ai/review/history.py, src/devops_cli/ai/review/runner.py:1583]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/feature. It adds new fields to the session record and a new predicate function.
    • Priority: P2-Medium. It is Part 1 of a planned feature set and is a building block, not an urgent fix.
    • Value: Medium. It enables routing and reporting decisions about whether a review ran on merged code.
    • Effort: Low. It adds two recorded fields and one predicate using existing git commands, with a clear acceptance criteria.
    • Related: feat(review): Add repository URI to SARIF versionControlProvenance #2101, which asks for a different change. Both record git state in a review record, but the candidate adds head commit and clean flag to findings.json while #2101 adds repository URI and revision to the ToolRun and SARIF export.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 73d1807 (see proposed design in issue body).

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

    source/agenttype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions