Skip to content

feat(review): keep runner review sessions in the store #4768

Done

Description

@dan-petty

Update 2026-11-26 (infra move): The cache bucket rule is in dan-petty/homelab now.

k8s/object-store/buckets.yaml there expires cache after 7 days. This item writes only product code. The k8s row of this repository cannot show that rule.


Problem or Motivation

When devops review runs in the runner shell (#3827), the session folder (review.md, findings.json, findings.sarif, files/) is on the pod disk. The pod stops, and the session is lost. Then devops review findings, the MCP findings tools and the PR evidence cannot read it.

Proposed Solution & Architectural Design

  • The runner publishes the session folder through the devops store adapter (feat(cli): publish and read content-store files #4761) to bucket cache, prefix sessions/<owner>/<repo>/<session-id>/.
  • The lifecycle rule of cache removes the objects after 7 days, the same age as devops cleanup uses for local sessions.
  • When no local copy exists, devops review findings <session-id> reads the session from the store.
  • A session can hold cited code of a private repository, so it never goes to a bucket that the files host serves.

Target Subsystem

AI & Agentic Review Pipeline (src/devops_cli/review/), with the store adapter.

Existing Tool Considered

The S3 API through the devops store adapter (boto3). No new tool. Cost (estimate): about 80 lines with tests, about 100k tokens and 1 hour.

Acceptance Criteria

  • A runner review leaves a session in cache.
  • devops review findings <session-id> reads that session from another pod.
  • The object expires after 7 days.
  • The files host cannot serve the session (a GET through files.<domain> returns the 404 page).

Dependencies

Source: #4742

Alternatives check of 2026-11-24: in-use.
The repository already uses this tool.
Tool: boto3 (https://pypi.org/project/boto3), Apache-2.0, last activity 2026-11-23, maintained.
Reason: Searches and the package facts found boto3, the standard Python S3 client already held in uv.lock and pinned by the store adapter, which stores and reads session objects; the bucket guard, prefix layout, CLI/MCP wiring and expiration stay in this item.

Covers:

  • Signed S3 object upload and download from Python
  • Configurable endpoint, region and credentials for S3-compatible stores
  • Built-in retries and streaming file transfer per object

Lacks:

  • No session prefix layout or owner/repo key convention
  • No CLI or MCP findings read path and no local-first precedence
  • No refusal of a public files-host bucket
  • No object expiration; the 7-day rule stays a cluster resource

Proposed design

Problem statement

A review that runs in the runner shell keeps its session (review.md, findings.json, findings.sarif, files/) on the pod disk. The pod stops and the session is lost. Then devops review findings, the MCP review_findings tool and the PR evidence cannot read it. This change publishes every file of a published session to the private cache bucket under sessions/<owner>/<repo>/<session-id>/ through the devops store adapter of #4761. It adds a local-first store fallback to the read path. The cache bucket's 7-day expiration comes from #4756, so this item writes no lifecycle configuration.

Acceptance criteria

Requirement: Runner session upload

The runner SHALL upload every file under a published review session folder, at its path relative to that folder, to the cache bucket under sessions/<owner>/<repo>/<session-id>/ through the devops store adapter, where owner and repo are the casefolded RepoRef.path_parts of the reviewed repository.

Scenario: Fake adapter records session files

  • WHEN A runner review publishes a session with review.md, findings.json, findings.sarif and files/example.py, and a fake store adapter records each upload.
  • THEN The fake adapter records each file at the session prefix with its relative path, and the local session folder stays readable.

Requirement: Store fallback for findings

devops review findings <session-id> SHALL read the session from the store under the prefix of the repository that the checkout origin names when no local session folder exists.

Scenario: Read findings from the store

  • WHEN The local session folder is absent, the checkout origin names the reviewed repository, and a fake store holds findings.json under that repository's session prefix.
  • THEN The command prints the findings parsed from that file and creates no local session folder.

Requirement: MCP findings read of a stored session

The MCP review_findings tool SHALL return the findings of a stored session when no local session folder exists.

Scenario: MCP reads a stored session

  • WHEN The local session folder is absent, a fake store holds the session, and review_findings(session=<session-id>) runs.
  • THEN The tool returns the findings of the stored session and sends no store write.

Requirement: Private session storage

The session publisher MUST take the bucket from the store adapter's cache target and MUST refuse any other session bucket before it uploads any session file, because only the reports and reports-private buckets are served anonymously.

Scenario: Anonymously readable bucket refused

  • WHEN The store adapter's session target names the anonymously readable reports bucket and the publisher runs with a fake store adapter.
  • THEN The publisher fails with the refusal error naming reports, and the fake adapter records no upload.

Requirement: Local session precedence

devops review findings <session-id> SHALL read a local session folder before it reads the store.

Scenario: Local copy present

  • WHEN A local session folder exists and the fake store also holds the session.
  • THEN The command prints the local findings and the fake store records no read.

Requirement: Missing session report

devops review findings <session-id> SHALL print the no-session warning naming the local reviews directory and the store prefix, and exit 0, when neither place holds the session.

Scenario: Session absent

  • WHEN No local session folder exists, the fake store holds no object for the session, and devops review findings <session-id> runs.
  • THEN The command prints the warning naming the reviews directory and the session prefix and exits 0.

Requirement: Store read dry-run plan

devops review findings SHALL declare the request-plan dry-run class and, under --dry-run with no local session, print the store read it would make and send none.

Scenario: Dry run of the store read

  • WHEN devops review findings <session-id> --dry-run runs and no local session folder exists.
  • THEN The command prints the session prefix it would read, the fake store records no read, and devops review findings --help lists --dry-run.

Requirement: Store upload failure

The runner SHALL exit nonzero when it cannot store the session after the adapter's retries.

Scenario: Store upload fails

  • WHEN The fake store adapter fails every upload attempt for the session.
  • THEN The runner exits nonzero and keeps the local session folder.

Requirement: Verdict writes stay local

devops review verify MUST read and write only a local session folder and MUST NOT load a session from the store.

Scenario: Verify with only a stored session

  • WHEN No local session folder exists, the fake store holds the session, and devops review verify --session <session-id> --index 1 --status VERIFIED runs.
  • THEN The command exits 1 with the session-not-found message and the fake store records no read and no write.

Requirement: No lifecycle write

Session publication MUST NOT write a bucket lifecycle configuration.

Scenario: No lifecycle write

  • WHEN The session publisher runs with a fake store adapter that records lifecycle calls.
  • THEN The fake adapter records no lifecycle call.

Requirement: Cache bucket expiration

The cache bucket SHALL expire every object under sessions/ after 7 days.

Scenario: Cache lifecycle expires sessions

  • WHEN A person reads k8s/object-store/buckets.yaml of dan-petty/homelab.
  • THEN BucketLifecyclePolicy cache expires objects after 7 days. This repository has no check for it.

Existing Tool Considered

boto3 (https://pypi.org/project/boto3), Apache-2.0, maintained, last activity 2026-11-23. The alternatives block of 2026-11-24 records the verdict in-use: the repository already uses this tool. The block's Lacks: list is the source for what the tool lacks, and this item supplies what that list names: the session prefix layout, the CLI and MCP read path with local-first precedence, the refusal of a public files-host bucket, and the 7-day expiration from the cache bucket lifecycle. uv.lock:343 holds boto3 today only as an indirect dependency of litellm (uv.lock:2310), and #4761 pins it as a direct dependency, so this item adds no dependency and writes no S3 client. Cost of the project wiring (estimate): about 80 lines with tests, about 100k tokens and 1 hour.

Key questions

  • Where does the runner publish a review session so that another pod can read it?: The runner uploads the session folder through the devops store adapter to the private cache bucket under sessions/<owner>/<repo>/<session-id>/ after ReviewSession.publish() returns the published directory. The upload keeps the local folder. cache is private: only reports and reports-private set anonymousRead. (best practice) [sources: src/devops_cli/review/session.py:151, src/devops_cli/ai/review/runner.py:1104, k8s/object-store/buckets.yaml:42, k8s/object-store/buckets.yaml:11]
    • Chosen: Store adapter to the cache bucket. It uses the existing adapter and a durable object store, so another pod can read the session.
    • Rejected: Pod volume. The pod disk stops with the pod and loses the session.
    • Rejected: Database table. It adds a new store and a schema for file-shaped session data.
  • How does devops review findings <session-id> find a session?: It reads the local session folder first through _find_session_dir. Only when that returns nothing does the read command fetch the requested file (findings.json or candidates.json) from the store prefix. The fallback stays in the read command, not in _find_session_dir, so devops review verify keeps its local-only resolver. The MCP review_findings tool runs the same CLI command and uses the same read path. (best practice) [sources: src/devops_cli/commands/review.py:1120, src/devops_cli/ai/review/runner.py:107, src/devops_cli/commands/review.py:1163, tests/ai/mcp/test_mcp_run_command.py:62]
    • Chosen: Local first, then store, in the read command only. It keeps the offline path and verdict writes on disk, and adds the store only as a read fallback.
    • Rejected: Store first. It adds a network read to every local lookup.
    • Rejected: Fallback inside _find_session_dir. verify and the other writers would find a session that is not on disk and fail when they write the verdict.
  • How does the read path know the repository of a stored session, so that it can build the session prefix?: From the origin of the current checkout: get_repo_origin_name gives the name and RepoRef.path_parts gives the casefolded owner and name. review findings has no --repo, and the architecture gives a command with no --repo the root of the working directory. When no origin resolves, the command prints the no-session warning that names both places. (best practice) [sources: ARCHITECTURE.md:208, src/devops_cli/ai/review/runner.py:972, src/devops_cli/github/repo_ref.py:150]
    • Chosen: Resolve the prefix from the checkout origin. It needs no new option and gives the same RepoRef that the runner used, because the pod that reads the session has the checkout.
    • Rejected: Add a --repo option to review findings. It adds an option to the read command and its MCP twin for no requirement of the issue.
    • Rejected: List every repository prefix in cache. It needs List on the bucket and a scan of every session for one lookup.
  • Which repository name does the store prefix hold?: The casefolded owner and name from RepoRef.path_parts, built from the origin of the checkout or the --repo argument. RepoRef is the one value type for a repository name, so the code parses no owner/name itself. (best practice) [sources: src/devops_cli/github/repo_ref.py:150, ARCHITECTURE.md:227, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
    • Chosen: RepoRef.path_parts. One value type gives the casefolded owner and name, matches the clone path, and avoids a second parser.
    • Rejected: Parse the remote in the session code. It repeats parsing and can give two prefixes for one repository.
    • Rejected: Use the GitHub spelling. Two spellings of one repository can make two prefixes.
  • Where is the 7-day rule for a stored session declared?: In the BucketLifecyclePolicy of cache in k8s/object-store/buckets.yaml of dan-petty/homelab, whose expire rule sets 7 days with no prefix, so every object under sessions/ expires with the bucket. The change of feat(k8s): apply store buckets, keys and rules from git #4756 that adds it is archived and the manifest is in the tree. This item writes no lifecycle configuration, because a second rule would duplicate that resource. (best practice) [sources: k8s/object-store/buckets.yaml:116, openspec/changes/archive/2026-11-22-4756-store-buckets-from-git/design.md:16, src/devops_cli/core/cleanup.py:263]
  • How does the publisher keep a session off a bucket that the files host serves?: The publisher takes the bucket from the store adapter's cache target, not from its caller, and refuses any other bucket before the first upload. Only reports and reports-private set anonymousRead; cache sets none, so a session there is not served anonymously. The refusal names the bucket and records no upload. (best practice) [sources: k8s/object-store/buckets.yaml:11, k8s/object-store/buckets.yaml:42, openspec/specs/object-store/spec.md:290]
    • Chosen: One bucket from the adapter's cache target, plus a refusal of any other bucket. The caller cannot choose a bucket, and one check before upload gives a clear test for an anonymously readable bucket.
    • Rejected: Prefix check only. An anonymously readable bucket can still serve the prefix.
    • Rejected: No check. A configuration error can expose cited private code.
  • Which files of the session folder are uploaded?: Every file under the session folder, at its relative path: review.md, findings.json, findings.sarif, candidates.json, analysis.json and files/. The MCP tools and the PR evidence read the whole session, cited code included. (best practice) [sources: src/devops_cli/review/session.py:96, src/devops_cli/review/session.py:140, src/devops_cli/ai/review/exporter.py:45]
    • Chosen: All files at their relative paths. The MCP tools and the PR evidence need the full session, including the cited files.
    • Rejected: Only the findings files. It drops review.md and files/, so the evidence and MCP reads fail.
    • Rejected: One archive. It forces a full download to read one file.
  • Should a store upload failure fail the review?: Yes. The runner retries the adapter uploads and then exits nonzero if the session is still not stored. It keeps the local folder, so a runner review fails closed rather than report success without its stored session. The review already fails this way when it cannot publish the session (ReviewSessionExistsError exits 1), and the runner review's fail-closed rule and AGENTS.md rule 2 forbid swallowing the error. (best practice) [sources: AGENTS.md:8, docs/ERRORS.md:118, src/devops_cli/review/session.py:151, src/devops_cli/ai/review/runner.py:1104, openspec/changes/archive/2026-11-21-3827-devops-review-runs-in-the-runner/design.md:9]
    • Chosen: Fail closed after retries. A review that cannot store its evidence must not report success, and the review already exits nonzero when it cannot publish its session.
    • Rejected: Warn and continue. It swallows the error, and the pod stop still loses the session.
  • What does devops review findings do when neither the local folder nor the store holds the session?: It prints the no-session warning, now naming both the local reviews directory and the store prefix, and exits 0. This keeps the recorded behavior of review findings and adds the store location to the warning. (best practice) [sources: src/devops_cli/commands/review.py:1121, src/devops_cli/lang/en/messages.py:84]
    • Chosen: Warning naming both places, exit 0. It keeps the recorded behavior of review findings and only adds the store location to the warning.
    • Rejected: Exit nonzero. It changes the command's recorded exit code for no requirement of the issue.
    • Rejected: Warning naming the local directory only. It hides the second place the session could be.
  • How does devops review findings behave under --dry-run once it can read the store?: It declares the request-plan dry-run class and exposes --dry-run. With no local session, a dry run prints the store prefix it would read and sends no read. A local session still prints its findings, because a local read sends no external request. The command is no-external-request today, so the class changes with the new read. (best practice) [sources: ARCHITECTURE.md:170, src/devops_cli/commands/review.py:1079]
    • Chosen: request-plan with a --dry-run option. The command now makes an external read, and a dry run must print the requests it would send.
    • Rejected: Keep no-external-request. A dry run would then read the store, which the class forbids.
    • Rejected: Keep the store read out of a dry run by reading local only. A dry run would hide the request that a real run makes when no local session exists.
  • Does devops review verify read the store once the findings command can?: No. verify resolves its session through _require_session_dir, which calls the local-only _find_session_dir. A verdict therefore needs a local session folder, and the status is given with the required --status VERIFIED option. (best practice) [sources: src/devops_cli/commands/review.py:1163, src/devops_cli/ai/review/runner.py:107]
    • Chosen: Keep verify local-only. A verdict writes into the session folder, so a session read from the store could not take the write.
    • Rejected: Download the session, then write the verdict. It adds a store write path and a local copy for a command that needs no network read.
  • How does the MCP review_findings tool read a stored session?: It uses the same local-first read path as devops review findings: local session first, then the store prefix. It returns findings and sends no store write. The MCP tool runs the CLI command, so the change needs no second store client. (best practice) [sources: docs/MCP_TOOLS.md:1816, src/devops_cli/commands/review.py:1120, tests/ai/mcp/test_mcp_run_command.py:62]
    • Chosen: Shared local-first read path. One read path keeps the command and the MCP tool consistent.
    • Rejected: Separate MCP store client. It duplicates the store read and its tests.
  • Does this item still wait on feat(roadmap): devops review runs in the runner shell #3827 and feat(k8s): apply store buckets, keys and rules from git #4756?: No. The change of feat(roadmap): devops review runs in the runner shell #3827 is archived and the review runner keeps its session at runner.py:1104; the change of feat(k8s): apply store buckets, keys and rules from git #4756 is archived and its cache lifecycle policy is in the tree. Only feat(cli): publish and read content-store files #4761, the devops store adapter, is still needed first. [sources: openspec/changes/archive/2026-11-21-3827-devops-review-runs-in-the-runner/design.md:9, src/devops_cli/ai/review/runner.py:1104, openspec/changes/archive/2026-11-22-4756-store-buckets-from-git/design.md:16, k8s/object-store/buckets.yaml:104]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4761

Activity

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

    @dan-petty
    OwnerAuthor

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

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/review. The (review) scope of the title gives the scope.
    • Priority: P2-Medium. It unblocks the runner review workflow but is not a security fix or a blocking defect.
    • Value: Medium. Without it, runner review sessions are lost when the pod stops, so findings and PR evidence are unreadable.
    • Effort: Low. The body estimates about 80 lines with tests and one hour of work.
    • Related: refactor(review): review session store that owns layout, fingerprints and verdicts #771, which asks for a different change. Both deal with the review session store, but #771 defines the local directory layout and #4742-child-10 adds remote S3 persistence for runner pods.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: covers

    Reason: The searches found that the S3 API through boto3 already covers the need: it writes and reads the session-folder objects in a bucket and configures a lifecycle rule that expires them after a set number of days. The issue itself names this tool ("The S3 API through the devops store adapter (boto3). No new tool."), so it is already in use and no new library is required.

    Tool: boto3 (https://pypi.org/project/boto3)

    • License: Apache-2.0
    • Last activity: 2026-11-13
    • Maintained: yes

    Covers:

    • Publishes and reads the session-folder objects (review.md, findings.json, findings.sarif, files/) in the cache bucket under sessions/<owner>/<repo>/<session-id>/
    • Reads a session from the store from another pod when no local copy exists
    • Bucket lifecycle rule expires the objects after 7 days, matching devops cleanup's local-session age

    Lacks:

    • The project-specific wiring: the devops store adapter, the cache bucket/prefix layout, and the refusal to serve the session from the files host
    • devops review findings <session-id> store-read path and its tests

    Tools considered:

    Searches run:

    • python library store session files in S3 bucket with lifecycle expiration boto3, results: 5
    • S3 bucket lifecycle rule expire objects after 7 days boto3 put_object, results: 5
    • open source tool persist ephemeral session data object storage python, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Owner question: The alternatives check found that https://pypi.org/project/boto3 covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    Answer to the open question: adopt boto3 through the devops store adapter of #4761. This item writes no S3 client of its own.

    • License: Apache-2.0. AWS maintains it.
    • Today uv.lock holds boto3 only as an indirect dependency. feat(cli): publish and read content-store files #4761 pins it as a direct dependency. So this item adds no new dependency.
    • Keep the item. It adds the session upload, the read fallback and the bucket guard.

    Correction to the Proposed design: remove the session lifecycle applier and its two requirements. #4756 declares the 7-day rule of the bucket cache as a BucketLifecyclePolicy resource in git. Code that writes a lifecycle configuration would fight that resource. This item writes no lifecycle configuration.

  9. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  10. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: covers, tool https://pypi.org/project/boto3. A person decides what the new result means for the item.

    Searches (7)

    Tools considered:

    Searches run:

    • boto3 S3 upload download objects Python library, results: 5
    • boto3 AWS SDK for Python S3 documentation, results: 5
    • s3fs fsspec Python S3 filesystem interface upload files, results: 5
    • boto3 pypi package, results: 5
    • python upload directory to s3 bucket library maintained, results: 5
    • "boto3" S3 client put_object upload_file documentation, results: 5
    • SeaweedFS S3 gateway compatible AWS SDK boto3 client, results: 5

    Sources:

  11. 9 remaining items

  12. added
    owner/service
    and removed
    owner/service
    on Nov 25, 2026
  13. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  14. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  15. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-28 17:56 UTC

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/lowpriority/p2-mediumscope/reviewsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions