Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9d63e7e
feat(agents): add a Gator review team and review replay harness
johntmyers Nov 19, 2026
aa7411d
feat(agents): check change blast radius and revalidation ordering in …
johntmyers Nov 21, 2026
c051c21
fix(agents): kill replay reviewers that ignore the timeout signal
johntmyers Nov 30, 2026
f980d5c
feat(agents): add a compatibility member to the Gator review team
johntmyers Nov 30, 2026
8a00609
feat(agents): check Gator fixes and keep reviewing after the budget r…
johntmyers Nov 30, 2026
f42811b
feat(agents): choose Gator's single reviewer or review team at launch
johntmyers Nov 30, 2026
189ea5d
feat(agents): launch Gator as the gator-review-bot GitHub App
johntmyers Nov 30, 2026
5c20d1b
feat(agents): let Gator approve maintainer-authored PRs as the GitHub…
johntmyers Nov 30, 2026
2ac9bda
feat(agents): harden Gator reviews and enable App approvals
johntmyers Dec 1, 2026
c90ed17
feat(agents): budget Gator specialist consults and record coverage
johntmyers Dec 2, 2026
ab12a1d
fix(gator): verify review thread authorship
johntmyers Dec 2, 2026
e29c0ac
fix(gator): bound replay reviewer shutdown and cleanup
johntmyers Dec 2, 2026
1c76054
fix(gator): check review and CI before App approval
johntmyers Dec 3, 2026
c71411d
fix(gator): honor maintainer clearance on the reviewed head
johntmyers Dec 3, 2026
14e3c53
fix(gator): check all blockers in spaced finding lists
johntmyers Dec 3, 2026
a054823
fix(gator): scope review history to the active GitHub identity
johntmyers Dec 3, 2026
dc5b145
docs(gator): clarify default App approval behavior
johntmyers Dec 3, 2026
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
4 changes: 3 additions & 1 deletion .agents/agents/gator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ COPY bin/review-feedback-ledger /usr/local/bin/review-feedback-ledger
COPY bin/resolve-gator-review-threads /usr/local/bin/resolve-gator-review-threads
COPY bin/validate-review-findings /usr/local/bin/validate-review-findings
COPY bin/approve-gator-workflow /usr/local/bin/approve-gator-workflow
COPY bin/review-team /usr/local/bin/review-team
RUN rm -f /usr/local/bin/gh && \
cp /usr/local/bin/gh-gator /usr/local/bin/gh && \
chmod 755 /usr/local/bin/gh /usr/local/bin/review-feedback-ledger \
/usr/local/bin/resolve-gator-review-threads \
/usr/local/bin/validate-review-findings /usr/local/bin/approve-gator-workflow
/usr/local/bin/validate-review-findings /usr/local/bin/approve-gator-workflow \
/usr/local/bin/review-team

RUN printf 'export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"\nexport PS1="\\u@\\h:\\w\\$ "\n' \
> /sandbox/.bashrc && \
Expand Down
40 changes: 36 additions & 4 deletions .agents/agents/gator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ The manifest-driven launcher at `scripts/agents/run.sh` reads `agent.yaml`, whic
The launcher:

- Scans `profile_paths` in manifest order and imports or updates `providers/github-gator.yaml`.
- Creates or updates the `github-gator` provider from `gh auth token`.
- Creates or updates the `github-gator` provider from `gh auth token`. With `--option github=app`, it instead imports `providers/github-app-gator.yaml`, creates the `github-gator-app-v2` provider, and configures gateway refresh for the `gator-review-bot` GitHub App installation token.
- Selects the requested harness and bakes the common runtime into the immutable sandbox payload.
- Builds with the latest Codex CLI by default. Docker can reuse the cached install layer; rebuild with that layer's cache disabled to fetch a newer release.
- For `--harness codex`, imports `providers/codex-gator.yaml`, creates or updates the `codex-gator` provider from `$HOME/.codex/auth.json`, and stores the refresh token as gateway-only refresh material.
- For `--harness codex`, reuses gateway-managed refresh for `CODEX_AUTH_ACCESS_TOKEN`. Initial setup and explicit resets configure and rotate it once.
- Passes the non-secret Codex account ID from host auth as `CODEX_ACCOUNT_ID`. The harness writes it literally into `auth.json` for local workspace discovery; access tokens remain opaque provider placeholders and refresh tokens remain gateway-only.
- Enables `agent_policy_proposals_enabled` and `proposal_approval_mode=auto` on the gator sandbox only. Gateway-global values for these keys take precedence; the launcher does not change them.
- Uses the gator image policy copied to `/etc/openshell/policy.yaml`.
- Installs the gator-specific `gh` wrapper from `gator/bin/gh` as `/usr/local/bin/gh` to fail closed when same-head-SHA history cannot be checked, prevent duplicate dispositions, and require versioned review payloads.
- Installs the Gator `gh` wrapper to check same-head history, prevent duplicate dispositions, and require versioned review payloads. It deduplicates App approvals separately from code-review comments.
- Installs `gator/bin/review-feedback-ledger` as `/usr/local/bin/review-feedback-ledger` so reviews receive tree- and patch-aware scope, prior summaries and findings, resolution state, convergence telemetry, and the three-round Warning budget.
Patch identity uses fetched merge-base/head trees in a temporary bare Git
repository, avoiding GitHub's full-diff size limit without checking out PR
Expand All @@ -125,6 +125,7 @@ The launcher:
- Keeps that normalized evidence as Gator's internal review contract, then renders validated blockers for people as a read-aloud `Summary`, an actionable `Fix`, and a deterministic `Verify`. Exact paths and only the additional provenance an implementation agent needs appear in collapsed `Agent context`; raw evidence headings such as `Base` and `Head` are not posted publicly. Review-process provenance, docs and E2E disposition, SHAs, and state codes appear at the end of the summary in collapsed `Gator metadata`, while required human actions remain visible.
- Bakes `.agents/agents/gator/skills/gator-gate/SKILL.md` into `/etc/openshell/agent-payload`.
- Bakes `.agents/agents/principal-engineer-reviewer/prompts/principal-engineer-reviewer.md` so the selected harness can run a deterministic independent reviewer execution through `/etc/openshell/agent-payload/runtime/subagent.sh principal-engineer-reviewer < task.md`.
- Bakes the review team: `bin/review-team`, the `prompts/review-*.md` members, and `skills/gator-gate/references/review-team.json`.
- For `--harness codex`, optionally bakes a host Codex executable as `/etc/openshell/agent-payload/runtime/harnesses/codex/codex`.
- Starts the selected harness without a TTY.
- Runs gator in `watch` mode by default. The sandbox stays alive while the supervisor sleeps between bounded Codex cycles, so Codex is not connected during passive PR waits. The supervisor prints periodic heartbeat lines during active cycles and passive sleeps.
Expand All @@ -133,7 +134,21 @@ The GitHub provider profile allows read-only GraphQL queries on `api.github.com/

Set `GATOR_CODEX_ACCESS_CREDENTIAL_KEY` or pass `--codex-access-key` if the gator Codex profile uses a credential key other than `CODEX_AUTH_ACCESS_TOKEN` for the short-lived access token.

Use `--once` for a single reconciliation cycle. Use `--poll-interval <seconds>` to change the default 15-minute watch cadence.
To run Gator as the `gator-review-bot` GitHub App, point `GATOR_GITHUB_APP_PRIVATE_KEY_FILE` at the App PEM and pass `--option github=app`. The gateway mints installation tokens scoped to `ai-openshell/openshell` with the permissions in `agent.yaml`; the sandbox sees only a placeholder. App launches cannot reach private advisory forks.

GitHub requires **Contents: Read and write** and **Pull requests: Read and write** for the App to resolve review threads. Approve updated permissions on the installation before launching. Relaunch older watchers with the default `github-gator-app-v2` provider, or choose a fresh custom provider name. Refreshing an older provider keeps its original token scopes. The sandbox policy still permits thread resolution and blocks push and merge routes.

To replace the PEM, launch with the new key and a new `--github-provider NAME`. The previous provider keeps serving while the replacement mints its first token. Use the new provider name on subsequent launches after it succeeds. `--reset-refresh` does not replace App keys.

Use `--once` for a single reconciliation cycle and `--poll-interval <seconds>`
to change the default 15-minute watch cadence. Use `--option reviewer=team`
to let the generalist request scoped specialist consults. Set
`--option specialist_budget=N` to cap the number per review (default `1`;
`0` skips consults; `any` or `-1` allows every eligible specialist). Gator
records which specialists ran in the PR review's collapsed metadata. The
default `--option reviewer=single` runs the generalist alone.
The specialist budget counts consults per review. It is separate from the
three-round budget for posting new Warnings.

The launcher preserves gateway-owned Codex refresh material without reading host refresh material or forcing rotation on subsequent launches. Lookup, configuration, and rotation errors fail the launch rather than triggering an automatic reset. After reauthenticating Codex locally, pass `--reset-refresh` only when you intend to replace the shared provider's refresh ownership; this affects other sandboxes using that provider.

Expand All @@ -143,7 +158,21 @@ Workspace secrets are optional. Existing provider-owned refresh material remains

Test labels select CI suites. Gator can approve current-head workflow runs only
with explicit launch authorization. PRs changing `.github/` require manual
approval. PR approval, merging, reruns, and dispatch require separate authorization.
approval. Merging, reruns, and dispatch require separate authorization.

## GitHub PR approval

Selecting `--option github=app` enables guarded PR approval without extra
instructions in the launch prompt. Gator approves the reviewed head of a
maintainer-authored PR. Its `gh` wrapper checks for a clean exact-head App
review, resolved feedback, and passing required CI before submitting. The
`OpenShell / Maintainer Approval` check independently verifies the App review,
author, head, and provenance of every PR commit. Required CI and CODEOWNER
reviews still apply. The PR author merges in GitHub.

Before enabling this flow, require `OpenShell / Maintainer Approval` from
GitHub Actions in the `main` ruleset and verify that GitHub counts the App
review toward its native approving-review requirement.

## Tests

Expand All @@ -152,3 +181,6 @@ The test suite requires Bash, Ruby, Node.js, jq, and ripgrep on the host. It moc
```shell
mise run test:gator
```

To measure reviewer changes against past review misses, see
[`evals/README.md`](evals/README.md).
72 changes: 70 additions & 2 deletions .agents/agents/gator/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

id: gator
payload_version: 16
payload_version: 24
display_name: Gator Gate Agent
description: Validate and monitor OpenShell GitHub issues and pull requests through the gator state machine.

Expand All @@ -15,13 +15,27 @@ harness:
default: codex
supported:
codex:
model: gpt-6.1-sol
model: gpt-6.2-sol
reasoning: medium

runtime:
mode: watch
poll_interval_seconds: 900
max_transient_failures: 5
options:
# single: generalist only. team: generalist with scoped specialist consults.
reviewer:
values: [single, team]
default: single
specialist_budget:
min_integer: 0
values: [any, "-1"]
default: 1
# user: the operator's `gh auth token`. app: the gator-review-bot GitHub App,
# with the private key path in GATOR_GITHUB_APP_PRIVATE_KEY_FILE.
github:
values: [user, app]
default: user

profile_paths:
- providers
Expand All @@ -36,6 +50,7 @@ providers:
- id: github
name: github-gator
profile: github-gator
option: {github: user}
credential_mode: explicit
credentials:
- env: GITHUB_TOKEN
Expand All @@ -44,6 +59,32 @@ providers:
command: gh auth token
export: true

- id: github-app
# The old provider keeps its read-only Contents scope on refresh.
name: github-gator-app-v2
profile: github-app-gator
option: {github: app}
credential_mode: runtime
refresh:
credential_key: GITHUB_TOKEN
strategy: github-app-installation
materials:
- name: client_id
value: Iv23liXeS0Vd5XOUzVgN
- name: installation_id
value: "187638323"
# ai-openshell/openshell
- name: repository_ids
value: "[1166129534]"
- name: permissions
# GitHub requires Contents write for resolveReviewThread.
value: '{"actions":"write","checks":"read","contents":"write","issues":"write","members":"read","pull_requests":"write","statuses":"write"}'
- name: private_key
secret: true
source:
kind: file
path_env: GATOR_GITHUB_APP_PRIVATE_KEY_FILE

- id: codex
name: codex-gator
profile: codex-gator
Expand Down Expand Up @@ -84,11 +125,38 @@ resources:
- id: gator-review-findings-schema
source: agent://skills/gator-gate/references/review-findings-schema.md
destination: skills/gator-gate/references/review-findings-schema.md
- id: gator-review-team-config
source: agent://skills/gator-gate/references/review-team.json
destination: skills/gator-gate/references/review-team.json
- id: gator-review-team-member-rules
source: agent://skills/gator-gate/references/review-team-member.md
destination: skills/gator-gate/references/review-team-member.md
- id: gator-networking-checklist
source: agent://skills/gator-gate/references/networking-checklist.md
destination: skills/gator-gate/references/networking-checklist.md

subagents:
- id: principal-engineer-reviewer
source: repo://.agents/agents/principal-engineer-reviewer/prompts/principal-engineer-reviewer.md
destination: subagents/principal-engineer-reviewer.md
expose_as: REVIEWER_COMMAND
- id: review-correctness
source: agent://prompts/review-correctness.md
destination: subagents/review-correctness.md
- id: review-security
source: agent://prompts/review-security.md
destination: subagents/review-security.md
- id: review-contracts
source: agent://prompts/review-contracts.md
destination: subagents/review-contracts.md
- id: review-compatibility
source: agent://prompts/review-compatibility.md
destination: subagents/review-compatibility.md
- id: review-networking
source: agent://prompts/review-networking.md
destination: subagents/review-networking.md
- id: review-merge
source: agent://prompts/review-merge.md
destination: subagents/review-merge.md

prompt_template: prompts/gator.md
10 changes: 7 additions & 3 deletions .agents/agents/gator/bin/approve-gator-workflow
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ fi
repo=ai-openshell/openshell
pr="$2" run="$3"
deny() { echo "Workflow not approved: $*" >&2; exit 1; }
actor="$(gh api user --jq .login)"
permission="$(gh api "repos/$repo/collaborators/$actor/permission" --jq .permission)"
case "$permission" in admin|maintain|write) ;; *) deny 'repository write permission is required' ;; esac
# A user identity must have write access. A GitHub App installation token has
# no user; GitHub enforces the installation's actions permission instead.
if [[ "${OPENSHELL_AGENT_OPTION_GITHUB:-user}" != app ]]; then
actor="$(gh api user --jq .login)"
permission="$(gh api "repos/$repo/collaborators/$actor/permission" --jq .permission)"
case "$permission" in admin|maintain|write) ;; *) deny 'repository write permission is required' ;; esac
fi
pull="$(gh api "repos/$repo/pulls/$pr")"
head="$(jq -er '.head.sha' <<< "$pull")"
jq -e --arg repo "$repo" '.state == "open" and .draft == false and (.base.repo.full_name | ascii_downcase) == ($repo | ascii_downcase)' <<< "$pull" >/dev/null || deny 'PR is not open and ready in the target repository'
Expand Down
Loading
Loading