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
58 changes: 54 additions & 4 deletions .github/agent-safety-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schema_version": 1,
"description": "Paths whose changes require one current-head cross-vendor independent review.",
"description": "Paths whose changes require a current-head independent review. The review-verdict check and the manual protected-safety-review workflow both read this list.",
"areas": [
{
"id": "verification-authority",
Expand All @@ -18,7 +18,11 @@
"packages/flow/openadapt_flow/runtime/effects/**",
"packages/flow/openadapt_flow/local_state_sources.py",
"packages/flow/tests/test_verify_run.py",
"packages/flow/tests/test_verify_tools.py"
"packages/flow/tests/test_verify_tools.py",
"packages/flow/openadapt_flow/verifier_audit/**",
"packages/flow/openadapt_flow/verification.py",
"packages/flow/openadapt_flow/terminal_verification_v2.py",
"packages/flow/openadapt_flow/scaffold_verifier.py"
]
},
{
Expand Down Expand Up @@ -50,7 +54,14 @@
"packages/flow/tests/test_write_receipt.py",
"packages/flow/tests/test_offline_seal.py",
"packages/flow/tests/test_cloud_seal.py",
"packages/types/tests/test_seal.py"
"packages/types/tests/test_seal.py",
"packages/flow/openadapt_flow/receipt_*.py",
"packages/flow/openadapt_flow/cli_receipt.py",
"packages/flow/openadapt_flow/seal_*.py",
"packages/flow/openadapt_flow/public_seal.py",
"packages/flow/openadapt_flow/cli_local_seal.py",
"packages/flow/openadapt_flow/bundle_sealing.py",
"packages/flow/openadapt_flow/sealed_*.py"
]
},
{
Expand Down Expand Up @@ -84,7 +95,46 @@
"scripts/ci/__init__.py",
"docs/agent-safety-evidence-v1.md",
"tests/test_attestation.py",
"tests/test_protected_safety_review.py"
"tests/test_protected_safety_review.py",
".github/review-verdict.json",
"scripts/ci/review_verdict.py",
"tests/test_review_verdict.py",
"tests/fixtures/review_verdict/**",
"docs/maintainers/review-verdict-rollout.md",
"packages/flow/tests/failopen/sites/review_verdict.py"
]
},
{
"id": "wrap-and-transducer",
"rationale": "The wrap SDK and the simplex transducer decide what an agent's write is allowed to commit and what it reports back.",
"paths": [
"openadapt/wrap_sdk.py",
"openadapt/simplex_transducer.py",
"openadapt/transducer_*.py"
]
},
{
"id": "governed-kernel",
"rationale": "The kernel enforces signed policy and produces the receipts the rest of the product trusts.",
"paths": [
"packages/kernel/**"
]
},
{
"id": "runtime-replay-and-confirmation",
"rationale": "Replay, target resolution and commit confirmation decide which on-screen element is acted on and whether a write is reported as committed.",
"paths": [
"packages/flow/openadapt_flow/runtime/replay/**",
"packages/flow/openadapt_flow/runtime/resolver.py",
"packages/flow/openadapt_flow/runtime/worklist_copilot.py"
]
},
{
"id": "ci-workflows",
"rationale": "Workflows and composite actions run with repository tokens and decide which checks a pull request must pass.",
"paths": [
".github/workflows/**",
".github/actions/**"
]
}
]
Expand Down
14 changes: 14 additions & 0 deletions .github/review-verdict.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"schema_version": 1,
"status_context": "review-verdict",
"protected_paths_manifest": ".github/agent-safety-manifest.json",
"sources": ["issue_comment", "pull_request_review"],
"authors": [
{
"login": "abrichr",
"reviewers": ["Grok", "Codex"],
"native_reviews": false,
"note": "Founder account. Grok and Codex post their reviews from it today, so each comment must name its reviewer in a From: line."
}
]
}
39 changes: 39 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,45 @@ EOF
Then remove the `legacy-run-ci` and `legacy-packages-gate` jobs from ci.yml.
App 15368 is GitHub Actions, the app the current checks are pinned to.

## Review verdict

review-verdict.yml publishes a commit status named `review-verdict`. It
reads the Grok and Codex review comments, so a pull request can't merge
over an open REQUEST CHANGES the way #2769 did.

- A pull request that changes no path in `.github/agent-safety-manifest.json`
passes with "no protected paths". The manifest is the one list of
protected paths. It covers the verifier, receipts and seals, replay and
commit confirmation, `wrap_sdk.py`, the transducer, `packages/kernel/**`
and `.github/workflows/**`.
- Otherwise the newest review from an account in `.github/review-verdict.json`,
with a `From: Grok` or `From: Codex` line, must name the current head in
its `Reviewed-Head:` line and say exactly `APPROVE`. A conditional approval,
BLOCK, REQUEST CHANGES, a stale head or no review fails.
- A REQUEST CHANGES at the current head stands until the same reviewer
approves. Another reviewer's APPROVE doesn't clear it.
- A review stays current across merges from main when each merge is clean
and the pull request's own diff is unchanged.
- In the merge queue the check re-reads the comments for every queued pull
request, so a REQUEST CHANGES posted after queueing stops the merge.

The full rule is in the docstring of `scripts/ci/review_verdict.py`, and
the tests are in `tests/test_review_verdict.py`. The job runs on pull request
pushes, on comments that contain `Reviewed-Head`, on pull request reviews
and in the merge queue. It always runs the script from `main`. To re-check a
pull request by hand, for example a fork's, run the workflow with its number:

```bash
gh workflow run review-verdict.yml --repo OpenAdaptAI/OpenAdapt -f pull_request=<number>
```

Until an admin adds `review-verdict` to the required checks, it reports but
doesn't block. The steps are in `docs/maintainers/review-verdict-rollout.md`.
protected-safety-review.yml stays manual-only. Both read the same manifest.
The one rule it has that `review-verdict` lacks is the author-vendor rule (the
reviewer's vendor must differ from the author's), so decide about that rule
before deleting it.

## Jobs by tier

| Workflow | Job | PR tier | Queue tier | Post-merge tier |
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/review-verdict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Review verdict

# Publishes the `review-verdict` commit status. A pull request that changes
# a protected path (.github/agent-safety-manifest.json) needs the newest Grok
# or Codex review to approve its current head. The rule is in the docstring
# of scripts/ci/review_verdict.py; the rollout steps are in
# docs/maintainers/review-verdict-rollout.md.
#
# The script and its config always come from a checkout of main. Pull
# request commits are fetched as git objects for the merge-from-main check
# and are never checked out or run. There is no pull_request_target trigger.
on:
pull_request:
types: [opened, synchronize, reopened]
issue_comment:
types: [created, edited, deleted]
pull_request_review:
types: [submitted, edited, dismissed]
merge_group:
types: [checks_requested]
workflow_dispatch:
inputs:
pull_request:
description: Pull request number to re-evaluate
required: true
type: number

permissions:
contents: read
pull-requests: read
statuses: write

jobs:
evaluate:
name: Evaluate review verdict
# Skip, without taking a runner, comments that can't change a verdict:
# comments on plain issues, and comments without a Reviewed-Head line.
# Skipping is safe only here, because the verdict is the status.
if: >-
github.event_name != 'issue_comment' ||
(github.event.issue.pull_request &&
(contains(github.event.comment.body, 'Reviewed-Head') ||
contains(github.event.changes.body.from, 'Reviewed-Head')))
# Jobs for one pull request queue behind each other, so the newest one
# reads the newest comments and publishes last. This sits on the job, not
# the workflow: a skipped comment run must not replace a pending
# evaluation in the queue.
concurrency:
group: review-verdict-${{ github.event.pull_request.number || github.event.issue.number || inputs.pull_request || github.event.merge_group.head_sha || github.run_id }}
cancel-in-progress: false
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out main (trusted code only)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
fetch-depth: 0
filter: blob:none
persist-credentials: false
- name: Evaluate and publish the review-verdict status
env:
GITHUB_TOKEN: ${{ github.token }}
DISPATCH_PULL_REQUEST: ${{ inputs.pull_request }}
run: python3 scripts/ci/review_verdict.py
125 changes: 125 additions & 0 deletions docs/maintainers/review-verdict-rollout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Rolling out the review-verdict check

`review-verdict` is a commit status. `.github/workflows/review-verdict.yml`
publishes it from `scripts/ci/review_verdict.py`. It reports on every pull
request as soon as the workflow is on `main`, but it blocks nothing until an
admin makes it required. The agent that built it changed no repository
settings. A repository admin takes the steps below.

## Before you start

- The workflow must be on `main`. GitHub runs comment-triggered workflows only
from the default branch, so the check can't react to review comments
before then.
- Run it once on a pull request with a protected path and once on one without,
and confirm that the `review-verdict` status shows "GitHub Actions" as its
source. Also confirm that a Dependabot pull request's own run can publish
the status. The workflow asks for `statuses: write`, which GitHub grants to
Dependabot runs; if it doesn't, every Dependabot pull request waits for a
manual run once the check is required:

```bash
gh workflow run review-verdict.yml --repo OpenAdaptAI/OpenAdapt -f pull_request=<number>
```

## 1. Add `review-verdict` to the required checks on `main`

This replaces the whole list, so it repeats the three current checks:

```bash
gh api -X PATCH repos/OpenAdaptAI/OpenAdapt/branches/main/protection/required_status_checks --input - <<'EOF'
{"strict": false, "checks": [{"context": "ci", "app_id": 15368}, {"context": "gitleaks", "app_id": 15368}, {"context": "dependency-review", "app_id": 15368}, {"context": "review-verdict", "app_id": 15368}]}
EOF
```

App 15368 is GitHub Actions. Pinning the app means a status that someone posts
with a personal token doesn't count. If GitHub refuses the pin for a commit
status, use `"app_id": -1` (any source) and say so in the PR that records the
change.

After the change:

- Every open pull request needs a `review-verdict` status on its head before
it can merge. A push, a review comment or a manual run sets it. To set it on
all open pull requests at once:

```bash
for n in $(gh pr list --repo OpenAdaptAI/OpenAdapt --state open --limit 200 --json number -q '.[].number'); do gh workflow run review-verdict.yml --repo OpenAdaptAI/OpenAdapt -f pull_request="$n"; done
```

- Check that the merge queue waits for `review-verdict` on its first group.
The status goes on the merge-group commit.
- Pull requests from forks get a read-only token, so their own push can't
publish the status. A review comment or a manual run publishes it instead.
- Dependabot pull requests that bump actions change `.github/workflows/**`,
so they need a review too.

## 2. Create GitHub App identities for Grok and Codex

Today Grok and Codex post from the founder's account, and the check trusts
that account's comments when they carry `From: Grok` or `From: Codex`.

**Until this step is done, the check can be spoofed.** Every agent session
that posts as `abrichr` (Claude, Gemini, Grok, Codex, or a script using the
founder's token) can write a comment that starts
`## Independent adversarial review: APPROVE` / `From: Grok` /
`Reviewed-Head: <head>`, and the check will pass it. Nothing in a comment
proves which model wrote it. The `From:` line only labels it. Until the
reviewers have identities of their own, `review-verdict` catches the
accidents it was built for, such as merging over a REQUEST CHANGES, a stale
approval or no review at all. It doesn't stop a session that writes its own
approval.

Separate identities fix this:

1. Create one GitHub App per reviewer, for example `openadapt-grok-review`
and `openadapt-codex-review`, owned by the OpenAdaptAI organization. Give
each one Pull requests: Read and write and Contents: Read only. Install
each app on `OpenAdaptAI/OpenAdapt` only.
2. Give each reviewer harness its app's private key, and have it post with an
installation token.
3. Add each app's bot login to `.github/review-verdict.json` in a reviewed
pull request:

```json
{"login": "openadapt-grok-review[bot]", "reviewers": ["Grok"], "native_reviews": true}
```

With `native_reviews: true`, a real GitHub review from that app counts: its
state is the verdict and its `commit_id` is the reviewed head. Comments from
the app still need the usual header.
4. When both apps are posting, remove the `abrichr` entry, and optionally set
`"sources": ["pull_request_review"]` so that only real reviews count.

## 3. Require one approval on protected paths

The workflow file runs from the pull request's own merge commit, so a pull
request that edits `.github/workflows/review-verdict.yml` could change what
the check does for itself. Code-owner review closes this:

1. In `.github/CODEOWNERS`, add owners for the protected paths that aren't
listed yet, at least `/.github/workflows/`, `/.github/review-verdict.json`,
`/.github/agent-safety-manifest.json`, `/scripts/ci/review_verdict.py`,
`/openadapt/wrap_sdk.py`, `/openadapt/simplex_transducer.py`,
`/openadapt/transducer_*.py` and `/packages/kernel/`. Do this in a
reviewed pull request.
2. In branch protection for `main`, set required approvals to 1 and turn on
"Require review from Code Owners". Leave stale-review dismissal off;
`review-verdict` already handles stale heads.
3. Do this only after step 2. Agents open pull requests from the founder's
account, and GitHub doesn't let an author approve their own pull request.
With the founder as the only code owner, every protected pull request would
be stuck. Make the reviewer apps code owners of those paths, or add a second
human code owner, before you turn the requirement on.

## Not done, and why

- protected-safety-review.yml stays as it is: manual-only since #2678.
`review-verdict` covers what it checked. Both read the same manifest, so
deleting it later loses nothing. Its stricter author-vendor rule (a review
must come from a vendor other than the author's) isn't part of
`review-verdict`. Decide whether to keep that rule before deleting the old
workflow.
- #2678 turned off the old automatic gate, partly because its comment trigger
took a runner for every comment. This job skips, without a runner, comments
that have no `Reviewed-Head` line or aren't on a pull request.
Loading
Loading