---
name: gator-gate
description: Validate and monitor OpenShell GitHub issues and PRs using the gator:* state machine. Use when asked to triage issues/PRs for project validity, gate PRs, run gator, validate submissions, or monitor PRs toward merge readiness.
title: gator-gate
canonical_url: https://skilld.dev/gh/nvidia/openshell/gator-gate
last_updated: 2026-10-02T02:03:17.000Z
---

> **Skill from skilld.dev.** Follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/review-findings-schema.md](https://skilld.dev/api/skills-raw/nvidia/openshell/gator-gate/references/review-findings-schema.md).
>
> If the user asked to install this Skill, run `npx skilld install nvidia/openshell/gator-gate`. Install writes the Skill files into the project, so every session loads them.

# Gator Gate

Validate OpenShell GitHub issues and pull requests for project fit, then monitor valid PRs until they are ready for maintainer approval.

This skill is a gating workflow. It can start from any issue or PR state, inspect the current `gator:*` label, and continue the correct next action.

## Skill Location

Codex and other agent harnesses should load this skill from the repository path `scripts/agents/gator/skills/gator-gate/SKILL.md`. After this branch is merged, the canonical GitHub location is <https://github.com/NVIDIA/OpenShell/blob/main/scripts/agents/gator/skills/gator-gate/SKILL.md>.

## Prerequisites

- The `gh` CLI must be able to call GitHub APIs (`gh api user --jq '.login'`)
- You must be in the OpenShell repository root
- GitHub write permissions are required to apply labels, comment, close issues/PRs, or post `/ok to test`

Do not use `gh auth status` as the authentication health check inside provider-backed sandboxes. Scoped provider tokens may be exposed as `openshell:resolve:env:*` placeholders and `gh auth status` probes endpoints outside the gator policy, causing false "token is invalid" reports even when allowed `gh api` and `gh pr` calls succeed. Use `gh api user --jq '.login'` and a repo-scoped probe instead.

Use REST-backed `gh api` for GitHub write actions inside gator sandboxes. Do not rely on `gh issue edit`, `gh pr edit`, or other high-level write commands when a REST path is available, because some of them use GraphQL mutations and gator policy allows GraphQL reads only. Do not fall back to `curl` for credentialed GitHub writes unless the active provider policy explicitly allows the `curl` binary for the same scoped endpoint. Preferred write shapes:

```bash
jq -Rs '{body:.}' comment.md > /tmp/comment.json
gh api --method POST repos/NVIDIA/OpenShell/issues/<number>/comments --input /tmp/comment.json --jq .html_url
gh api --method POST repos/NVIDIA/OpenShell/issues/<number>/labels -f labels[]="gator:<state>"
gh api --method DELETE repos/NVIDIA/OpenShell/issues/<number>/labels/gator%3Ablocked --silent || true
```

If a required GitHub REST read or write fails with `EOF`, `Empty reply from server`, or a sandbox `NET:FAIL` after the current policy shows the endpoint was allowed, treat it as a transient transport or provider failure. Do not convert the PR or issue to `gator:blocked`, do not report it as a rate-limit/auth failure, and do not keep probing optional endpoints such as `/rate_limit`. In supervised watch mode, finish with `OPENSHELL_AGENT_RESULT {"status":"transient_failure","next_poll_seconds":120,"reason":"github_transport_eof","notes":"GitHub transport failed after policy allowed the request. The supervisor should retry without changing the PR state."}` so the supervisor retries soon.

If the `principal-engineer-reviewer` sub-agent fails before producing usable review output, treat that as transient gator infrastructure failure, not as a PR blocker. This includes Codex auth or token-refresh failures, model transport failures, sub-agent command failures, empty reviewer output, malformed reviewer output, and sandbox policy denials that only affect the sub-agent harness. Do not post a marked gator comment or PR review, do not apply `gator:blocked`, and do not consume the one-disposition-per-head-SHA slot. In supervised watch mode, finish with `OPENSHELL_AGENT_RESULT {"status":"transient_failure","next_poll_seconds":120,"reason":"reviewer_subagent_failed","notes":"The reviewer did not produce usable feedback, so no PR state was changed. The supervisor should retry the review."}` so the supervisor retries after the operator or provider issue clears.

## Authority Rules

- Do not push commits to a contributor's PR branch by default.
- You may push changes only when explicitly instructed by a GitHub comment from a maintainer or by a direct operator prompt.
- Do not post `/ok to test <full-head-sha>` unless the current GitHub user has maintainer authority.
- Code review is code-only. Do not run pre-commit, unit tests, or E2E locally as part of the initial PR review unless explicitly instructed.
- Security vulnerabilities must not be triaged through public GitHub issues. Follow `SECURITY.md`.

Maintainer authority means one of:

- User is in the NVIDIA `openshell-maintainers` team
- User is a CODEOWNER listed in `.github/CODEOWNERS`
- Repository permission is `admin`, `maintain`, or `write` for maintainer-only actions such as `/ok to test`

Use these checks where needed:

```bash
gh api user --jq '.login'
gh api repos/NVIDIA/OpenShell/collaborators/<user>/permission --jq '{permission,role_name}'
gh api orgs/NVIDIA/teams/openshell-maintainers/members --jq '.[].login'
```

If a permission or team-membership query fails due to API access, fall back to CODEOWNERS and repository permission where possible. If authority cannot be verified, do not perform maintainer-only actions.

## Comment Marker

All comments posted by this skill must begin with this marker:

```markdown
> **gator-agent**
```

Use one canonical gator disposition per issue or PR head SHA for baseline review and status summaries. A disposition may be one issue comment or one submitted GitHub review. A submitted review, including its summary body and every inline comment in its `comments` array, counts as one disposition for the head SHA; do not count its inline comments separately. A rate-limited TTL state nudge is not a disposition: it may be posted on an unchanged SHA to request the already-known next human action, but never to restate findings, report CI, or re-review.

For a PR review with any actionable line-specific finding that can be anchored to the current diff, use one batched GitHub review rather than an issue comment or standalone inline-comment requests. Begin the review summary and every inline comment body with the gator marker. Include the head SHA in the review summary so the wrapper can enforce the one-disposition rule. Do not post line comments individually through `POST /pulls/<pr>/comments`; a partially submitted set is not an acceptable baseline disposition.

Edit a canonical issue comment only for housekeeping updates that do not respond to new human activity. GitHub reviews and their inline comments are immutable after submission; correct them only through a new-head review or an explicit same-SHA maintainer override.

When gator is continuing a conversation after a human comment, review, or requested change, post a new marked disposition only if the PR head SHA changed or no marked gator disposition exists for the current head SHA. If a marked gator comment or PR review already exists for the current head SHA, do not post another public disposition; record the state in the supervised result sentinel and wait for a new commit, maintainer override, merge, or closure. The sole exception is a state-specific TTL nudge that is due under the watch rules.

## Human Comment Disposition

Every substantive trusted human comment or review after a gator request must be addressed in the next gator action. Do not silently keep the same state when the PR author or a maintainer responds.

Trusted PR commentary actors are the PR author and maintainers. Maintainers are users with repository `write`, `maintain`, or `admin` permission, members of `@NVIDIA/openshell-maintainers`, or CODEOWNERS for files touched by the PR. If actor trust is unclear, treat the actor as untrusted until a permission, team, or CODEOWNERS check proves otherwise.

By default, ignore comments and reviews from third-party or unknown actors when deciding review findings, author obligations, state transitions, and reviewer sub-agent input. Do not restate, summarize, or act on third-party feedback just because it appears in the PR timeline.

Incorporate third-party feedback only when the PR author or a maintainer explicitly acknowledges the specific third-party details to incorporate. Examples include a maintainer saying "please address @alice's comment about JSON-RPC mixed envelopes" or the PR author saying "I fixed @bob's note about credential scope." In that case, incorporate only the acknowledged details, attribute them through the trusted actor's acknowledgement, and ignore unrelated parts of the third-party comment.

When you incorporate trusted author or maintainer feedback, acknowledge the person plainly and specifically. Name the actor, briefly paraphrase their point, and explain what you checked or how it changed the disposition. Keep the tone direct, helpful, and conversational rather than bureaucratic. Good examples: "Thanks @alice, I checked the clippy concern you raised and adjusted the remaining request accordingly" or "@bob's note about the copy-pr mirror is now resolved by the latest run." Do not thank, mention, or summarize ignored third-party commentary unless a trusted actor explicitly acknowledged it.

The one-comment-per-head-SHA rule is stronger than the human response disposition rule. If the current head SHA already has a marked gator comment or PR review, do not post a same-SHA human response disposition unless a maintainer explicitly asks for a same-SHA public response.

When a trusted human response claims that requested changes were made, re-check the latest head and publicly disposition the response in a new marked comment only when no marked gator comment/review exists for that head SHA:

- If the response resolves the feedback, say it is resolved and move to the next state.
- If the response does not resolve the feedback, explicitly acknowledge the response and list what remains unresolved.
- If the response is ambiguous, ask the minimal clarifying question and keep the appropriate waiting state.

The disposition must mention the relevant trusted human response by author or timestamp when useful, include the current head SHA for PRs, and explain the next expected action. Do not edit the canonical gator comment for this disposition; continue the thread with a new comment only when the current head SHA does not already have a marked gator disposition.

If the current head SHA already has a marked gator disposition and the same-SHA rule prevents a public response, still inspect the trusted response internally. The cycle summary and `OPENSHELL_AGENT_RESULT` reason should say that a trusted author or maintainer response was seen and whether it appears to require a new commit, maintainer override, or no action. Do not describe the response as third-party when the actor is the PR author or a verified maintainer.

### Durable review dispositions

Every prior Gator finding is a durable review disposition across later head
SHAs. A new commit permits a delta review; it does not erase trusted feedback
history or reopen the unchanged PR.

Before every fresh reviewer run, collect Gator review summaries, general
findings, issue-comment dispositions, inline review threads, replies, resolution
state, resolver, stable finding IDs, and review-head context:

```bash
review-feedback-ledger NVIDIA OpenShell <pr-number> \
  > /tmp/gator-review-feedback-ledger.json
jq -e '
  .schema_version == 4 and
  (.dispositions | type == "array") and
  (.threads | type == "array") and
  (.review_scope.mode |
    IN("initial", "follow_up", "already_reviewed", "critical_only"))
' \
  /tmp/gator-review-feedback-ledger.json >/dev/null
```

Treat the ledger as required reviewer input, not optional background:

- Verify whether the PR author, resolver, or replying actor is trusted under the rules above.
- Treat `review_scope.mode` and `previous_reviewed_sha` as authoritative. Use
  `initial` for a complete PR review, `follow_up` for an unresolved-feedback
  plus `<previous_reviewed_sha>..HEAD` delta review, and `already_reviewed` to
  suppress another reviewer run. Use `critical_only` after three
  finding-bearing rounds as described below.
- Use `current_patch_id`, `previous_reviewed_patch_id`, base SHA, and merge-base
  SHA to preserve review identity across rebases and merge-main commits. If
  `rebase_equivalent` is true, do not review the same effective patch again.
- For a non-equivalent rebase, compare author patch IDs or use `git range-diff`
  to isolate the author-only delta. Upstream changes are context, not new PR
  findings.
- Carry every still-open finding forward as an existing obligation. Do not post
  a new thread or semantically equivalent general finding for it.
- A Gator thread resolved by a verified maintainer is addressed. If the resolver is only the PR author, inspect the trusted reply and latest diff to decide whether the finding was fixed; resolution alone does not grant a non-maintainer author waiver authority.
- When a later commit demonstrably fixes an open inline Gator finding, resolve
  that Gator-owned GitHub review thread as part of the same reconciliation
  cycle. Also resolve it after a verified maintainer explicitly waives the
  finding. Do not resolve a thread merely because it is outdated, the author
  says it is fixed, or a new review omits it.
- Preserve a verified maintainer's reply as the rationale. An explicit rejection such as "invalid", "intentional", "fine as implemented", or "won't fix" is a waiver, not an unanswered request.
- An unresolved thread with an explicit verified-maintainer waiver is also waived. A non-maintainer author's disagreement remains context for review but does not override a maintainer-required change.
- Preserve each `GATOR-<origin-sha-prefix>-<ordinal>` finding ID across later
  reviews. Use the ledger's `gator-inline-<comment-id>` fallback for legacy
  inline findings that predate explicit IDs.
- Do not re-raise an open, resolved, or waived finding, or a semantically
  equivalent finding with different wording, merely because the head SHA
  changed.
- Re-raise it only when the new diff materially invalidates the prior rationale or reintroduces the defect. State what changed since the resolution and why the earlier disposition no longer applies.
- If the ledger lookup or validation fails, do not run a context-free reviewer. Return a transient supervised result. Use `github_transport_eof` for the transport failures described above; otherwise use `review_feedback_lookup_failed`.
- Record the ledger's `review_telemetry` in the internal cycle summary. Treat a
  nonzero duplicate finding-ID count, a waived finding reappearing, or an
  unchanged-code proposal as a reviewer-quality signal, not an author defect.

### Resolve addressed Gator threads

After checking the new diff and trusted replies, partition every open ledger
finding into still-open, fixed by the current head, or explicitly waived by a
verified maintainer. Before posting the current-head disposition or advancing
out of review, resolve each fixed or waived inline Gator thread by stable
finding ID:

```bash
resolve-gator-review-threads \
  /tmp/gator-review-feedback-ledger.json \
  GATOR-<origin-sha-prefix>-<ordinal> [...]
```

The resolver accepts only exact threads from the feedback ledger whose first
comment carries the Gator marker. Never resolve a human-owned review thread, a
still-open finding, or a thread whose disposition is ambiguous. General
findings and issue comments have no review thread to resolve; retain their
durable disposition in the ledger.

Thread resolution is required housekeeping for an addressed inline finding,
not a new review disposition, and does not consume the one-disposition-per-head
SHA slot. If GitHub does not confirm every requested resolution, do not advance
the Gator state or post the follow-up disposition. Return
`OPENSHELL_AGENT_RESULT {"status":"transient_failure","next_poll_seconds":120,"reason":"review_thread_resolution_failed","notes":"GitHub did not confirm every requested Gator thread resolution. Retry reconciliation before advancing the PR state."}`
and retry the reconciliation later.

## Labels

There must be at most one `gator:*` label on an issue or PR at any time.

| Label | Meaning |
|-------|---------|
| `gator:follow-up-needed` | Needs submitter or maintainer clarification; 48 business-hour TTL applies |
| `gator:blocked` | Process blocker prevents validation or monitoring from progressing |
| `gator:validated` | Issue is valid and ready for work; no active PR monitoring needed |
| `gator:in-review` | PR is valid and in agent review or author-feedback loop |
| `gator:watch-pipeline` | Review feedback is resolved; CI/CD monitoring is active |
| `gator:approval-needed` | Agent work is complete; maintainer approval is still needed |
| `gator:merge-ready` | Maintainer approval is present; merge or close decision remains |

If labels are missing and you have permission to create them, create them with clear descriptions. Otherwise report the missing labels to the operator.

```bash
gh label create "gator:follow-up-needed" --description "Gator needs submitter or maintainer follow-up" --color "FBCA04"
gh label create "gator:blocked" --description "Gator is blocked by process or repository gates" --color "BFD4F2"
gh label create "gator:validated" --description "Gator validated this issue as ready for work" --color "0E8A16"
gh label create "gator:in-review" --description "Gator is reviewing or awaiting PR review feedback" --color "1D76DB"
gh label create "gator:watch-pipeline" --description "Gator is monitoring PR CI/CD status" --color "5319E7"
gh label create "gator:approval-needed" --description "Gator completed review; maintainer approval needed" --color "C5DEF5"
gh label create "gator:merge-ready" --description "Gator completed review and approval is present; merge decision pending" --color "0E8A16"
```

When changing state, remove all existing `gator:*` labels first, then add the new one.

```bash
for label in gator%3Afollow-up-needed gator%3Ablocked gator%3Avalidated gator%3Ain-review gator%3Awatch-pipeline gator%3Aapproval-needed gator%3Amerge-ready; do
  gh api --method DELETE repos/NVIDIA/OpenShell/issues/<number>/labels/$label --silent || true
done
gh api --method POST repos/NVIDIA/OpenShell/issues/<number>/labels -f labels[]="gator:<state>"
```

Pull requests are also GitHub issues for label operations, so the REST issue label endpoints are valid for PR labels.

## Invocation Modes

The user may provide:

- A GitHub issue number
- A GitHub PR number
- Both an issue and a PR number
- No number, with an instruction to process untriaged or active gator items

Resolve PRs and issues carefully:

```bash
gh issue view <issue> --json number,title,body,state,author,labels,comments,createdAt,updatedAt,closedAt,url
gh pr view <pr> --json number,title,body,state,author,labels,comments,reviews,closingIssuesReferences,files,isDraft,mergeStateStatus,reviewDecision,headRefOid,headRefName,baseRefName,mergedAt,closedAt,url
```

For a PR-only input, derive linked issues from `closingIssuesReferences`, PR body references such as `Fixes #123`, and issue comments that mention the PR. If no linked issue exists, validate the PR directly.

## Invocation Scope

Before discovering work, define the invocation target selector and keep every later query within that selector.

- Explicit issue or PR numbers: process only those items, even if a PR is closed or merged.
- "My PRs" or similar operator-owned requests: resolve the current GitHub user with `gh api user --jq '.login'` and process only PRs authored by that login.
- "All active PRs", "all gator-labeled PRs", or repo-wide requests: process across authors only when the operator explicitly asks for repo-wide scope. For write actions across authors, verify maintainer authority first.
- No-number requests that mention untriaged issues: process only the issue set implied by the request, such as open issues with `state:triage-needed`.

For PR watch requests, normal discovery should include open non-draft PRs matching the target selector. Closed/merged reconciliation may also include closed or merged PRs matching the same selector when they still have an active `gator:*` label. This is a cleanup extension of the current invocation scope, not permission to scan or mutate all gator-labeled PRs in the repository.

When searching for closed or merged PRs with active gator labels, query each label separately and de-dupe by PR number. Do not combine labels into one comma-separated search term; GitHub search does not treat that as an OR query and can miss PRs. Example for "my PRs":

```bash
author="$(gh api user --jq '.login')"
for label in \
  gator:follow-up-needed \
  gator:blocked \
  gator:validated \
  gator:in-review \
  gator:watch-pipeline \
  gator:approval-needed \
  gator:merge-ready; do
  gh pr list --repo NVIDIA/OpenShell --author "$author" --state closed \
    --search "label:$label" \
    --json number,title,state,mergedAt,closedAt,labels,url,updatedAt
done | jq -s 'add | unique_by(.number)'
```

When using closed/merged reconciliation for a PR that was not explicitly requested by number, require a prior comment beginning with `> **gator-agent**` before mutating labels.

If a closed or merged PR has an active `gator:*` label but no gator marker and was not explicitly requested, report the label drift in the cycle summary and leave the labels unchanged.

## State Machine

```text
No gator label
  -> gator:follow-up-needed  missing why, UX path, repro, RFC/roadmap link, or author action
  -> gator:blocked           process blocker prevents progress
  -> gator:validated         issue is valid and ready for work
  -> gator:in-review         PR is valid and enters monitoring
  -> close not planned       invalid or out of project scope

gator:follow-up-needed
  -> gator:validated         issue clarified and valid
  -> gator:in-review         PR clarified and valid
  -> gator:blocked           process blocker discovered
  -> close not planned       48 business-hour TTL expired

gator:blocked
  -> previous intended state blocker resolved
  -> stay blocked            blocker still present
  -> nudge responsible party blocker unchanged after 48 business hours
  -> stop                    closed by vouch gate; wait for vouch and reopen

gator:validated
  -> stop                    issue is already ready for work, no new PR or comments
  -> gator:in-review         linked PR appears and is valid
  -> re-evaluate             new substantive comments or labels change scope

gator:in-review
  -> gator:watch-pipeline    review feedback resolved
  -> nudge PR author         review feedback unanswered after 48 business hours
  -> gator:follow-up-needed  author action needed
  -> gator:blocked           draft, vouch, DCO, merge conflict, or authority blocker

gator:watch-pipeline
  -> gator:approval-needed   required checks are green and maintainer approval is missing
  -> gator:merge-ready       required checks are green and maintainer approval is present
  -> gator:in-review         new review feedback or code changes need attention
  -> gator:follow-up-needed  author action needed for failures
  -> gator:blocked           process blocker prevents test execution

gator:approval-needed
  -> gator:merge-ready       maintainer approval arrives and checks remain green
  -> nudge maintainers       no approval after 48 business hours
  -> gator:watch-pipeline    checks are no longer green
  -> gator:in-review         maintainer requests changes or author updates PR

gator:merge-ready
  -> stop                    PR merged or closed
  -> nudge maintainers       no merge or close decision after 48 business hours
  -> gator:watch-pipeline    checks are no longer green
  -> gator:in-review         maintainer requests changes or author updates PR
```

## Step 1: Fetch Context

Fetch issue, PR, comments, reviews, files, labels, and linked references. Also inspect existing gator state.

For PRs, record:

- PR number and URL
- PR author login
- Head SHA from `headRefOid`
- Linked issue numbers
- Draft status
- Merge state
- Review decision
- Changed files and affected subsystems
- Existing `test:*` labels
- Trusted commentary actors: PR author plus verified maintainers or CODEOWNERS relevant to changed files
- Untrusted third-party comments only when a trusted actor explicitly acknowledged the specific details to incorporate

For issues, record:

- Issue number and URL
- Author and author association where available
- Current labels
- Whether a linked PR exists
- Last human or maintainer comment after any gator follow-up request

## Step 2: Recover From Current State

If exactly one `gator:*` label exists, resume from that state in the state machine.

If multiple `gator:*` labels exist:

1. Treat this as label drift.
2. Read recent comments and labels to infer the most advanced safe state.
3. Comment with the correction.
4. Remove all but the chosen `gator:*` label.

If no `gator:*` label exists, begin validation.

## Closed/Merged PR Reconciliation

Before running normal PR validation, review, CI, or approval logic, check whether each target PR is already closed or merged.

For merged PRs:

1. Post a `Monitoring Complete` comment when the PR still has an active `gator:*` label or the latest gator comment does not already record monitoring completion.
2. Remove all active `gator:*` labels.
3. Do not run duplicate detection, review, CI watch, approval nudges, or other active-state transitions.

For closed-unmerged PRs:

1. Post a `Monitoring Complete` comment when the PR still has an active `gator:*` label or the latest gator comment does not already record monitoring completion.
2. Remove all active `gator:*` labels.
3. Do not run duplicate detection, review, CI watch, approval nudges, or other active-state transitions.

For closed or merged PRs that have no active `gator:*` label and already have a monitoring-complete gator comment, take no GitHub write action.

In supervised watch mode, return `OPENSHELL_AGENT_RESULT {"status":"complete","reason":"pr_merged","notes":"The monitored PR was merged, so Gator monitoring is complete."}` or `OPENSHELL_AGENT_RESULT {"status":"complete","reason":"pr_closed","notes":"The monitored PR was closed without merging, so Gator monitoring is complete."}` only when all targeted PRs in the cycle are closed, merged, or otherwise complete. If any targeted PR still needs future reconciliation, return the appropriate `waiting` or `blocked` sentinel for the active work.

## Watch Loop Rules

Every gator state is a watch state. On each invocation, determine the current state, inspect the latest issue/PR activity, and either advance to the next state, keep waiting, or post a TTL nudge.

When `OPENSHELL_AGENT_RUN_MODE=watch`, the OpenShell agent supervisor owns the sleep/relaunch loop. In that mode, perform exactly one reconciliation cycle, do not run `sleep 900` or an unbounded polling loop inside the harness, and finish with a single final-line result sentinel:

```text
OPENSHELL_AGENT_RESULT {"status":"waiting","next_poll_seconds":900,"reason":"checks_pending","notes":"Required checks are still running on the current head. Gator will inspect the results next cycle."}
```

Use `status=waiting` for routine CI/PR activity waits, `status=blocked` for human or process blockers, `status=complete` for closed or merged PRs and other complete items, `status=terminal_failure` for unrecoverable errors, and `status=transient_failure` only when the supervisor should retry soon. Every sentinel must include `notes`: one or two concise, plain-language sentences that summarize the current diagnosis, identify any notable issue or unanswered question, and state the next useful action or owner. Make the notes understandable when read aloud. Do not repeat mechanical metadata, dump raw logs, or include secrets. The supervisor will persist the result, sleep, and invoke the harness again with fresh GitHub state.

When not running under supervised watch mode, do not stop after a one-shot check when a PR is in an active waiting state unless the operator explicitly asks for a one-shot status check. Enter a polling loop and state the interval and stop conditions before waiting.

Default live-watch cadence:

- For supervised watch mode, set `next_poll_seconds` to 900 for PRs in active states: `gator:in-review`, `gator:watch-pipeline`, `gator:approval-needed`, `gator:merge-ready`, and `gator:blocked`.
- Watch PRs indefinitely across gator state transitions until they close, merge, or the operator stops the session. In supervised watch mode this means return a `waiting` or `blocked` result sentinel and let the supervisor sleep outside the model session.
- For supervised watch mode, set `next_poll_seconds` to 3600 for issue-only `gator:follow-up-needed` or issue-only `gator:blocked` states until they progress, close, or reach a TTL threshold.
- Stop immediately for issue-only `gator:validated` items that have no associated PR.
- Do not stop PR monitoring just because the gator state changes, a human comments, or new commits arrive. Treat those as triggers to re-evaluate and continue from the new state.
- Stop PR monitoring only when the PR closes, merges, the operator stops the session, or an unrecoverable process blocker prevents further agent action.

Use a concise cycle summary before returning the result sentinel, for example: "No action needed for PR #123; supervisor should recheck in 15 minutes until it closes, merges, or the session is stopped."

Use 48 business hours as the default inactivity threshold for states that are waiting on a person. Business hours are Monday through Friday; do not count Saturday or Sunday.

State-specific monitoring:

- `gator:follow-up-needed`: wait for submitter or maintainer clarification. If no substantive response arrives after 48 business hours, close as not planned or close the PR with a TTL-expired comment.
- `gator:blocked`: re-check the blocker. If resolved, continue to the previous intended state. If still blocked after 48 business hours, nudge the responsible party unless the PR was auto-closed by the vouch system.
- `gator:validated`: for an issue-only item with no associated PR, stop; the issue is ready for work. If an associated PR exists or appears during a later invocation, validate the PR and move it to `gator:in-review`. If new information changes the scope, re-run validation.
- `gator:in-review`: watch for author commits, trusted author responses, trusted maintainer comments, and unresolved gator findings. Ignore unacknowledged third-party comments. If feedback is addressed, move to E2E/test-label decision and then `gator:watch-pipeline`. If feedback is unanswered after 48 business hours, nudge the PR author. Continue watching after either action.
- `gator:watch-pipeline`: watch checks until green, failed, or blocked. Move to `gator:approval-needed` when required checks are green, no review feedback remains, and maintainer approval is missing. Move directly to `gator:merge-ready` when required checks are green, no review feedback remains, and maintainer approval is present. Continue watching after either state transition because maintainer feedback can arrive later.
- `gator:approval-needed`: watch for maintainer approval, merge, closure, new commits, author responses, or maintainer requested changes. If maintainer approval arrives while checks remain green and no review feedback remains, move to `gator:merge-ready`. If no approval arrives after 48 business hours, nudge maintainers and CODEOWNERS. If humans request changes, move back to `gator:in-review` and continue watching author follow-up.
- `gator:merge-ready`: watch for merge, closure, new commits, failed checks, or maintainer requested changes. If no merge or close decision occurs after 48 business hours, nudge maintainers and CODEOWNERS. If checks are no longer green, move back to `gator:watch-pipeline`. If humans request changes or the author updates the PR, move back to `gator:in-review`.

When calculating a nudge TTL, use the latest relevant event for that state:

- The first comment that entered the current state
- The most recent gator comment in the current state
- The most recent comment or review from the expected actor
- The most recent commit pushed to the PR, when waiting on code changes

Do not post repeated nudges more often than once per 48 business hours for the same state and actor.

## Step 3: Check Process Blockers

Before project-validity review, check blockers.

Move to `gator:blocked` when any of these apply:

- PR is draft and not ready for review
- PR is blocked by the vouch system or was auto-closed for lack of vouch
- DCO is missing or failing
- PR has merge conflicts or `mergeStateStatus` indicates dirty/blocked for conflict reasons
- Required `/ok to test <full-head-sha>` is needed and the current user lacks maintainer authority
- Required CI cannot run because the copy-pr mirror is missing or stale and maintainer authority is unavailable

For auto-closed vouch-gate PRs, do not treat the proposal as invalid. Comment only if useful, then stop and wait until the author is vouched and the PR is reopened.

For blocked open PRs, post a concise gator comment that lists the blocker and the exact next human action. On later invocations, re-check the blocker and nudge the responsible party after 48 business hours if it remains unresolved.

## Step 4: Duplicate Detection

For newer issues and PRs, check for duplicates before deciding validity. Duplicate detection is a project-fit input, not a substitute for human judgment.

Search for existing issues and PRs using the title, subsystem labels, changed files, key error strings, and important feature terms:

```bash
gh search issues --repo NVIDIA/OpenShell "<keywords>" --state open --json number,title,state,url,labels,updatedAt
gh search issues --repo NVIDIA/OpenShell "<keywords>" --state closed --json number,title,state,url,labels,updatedAt
gh search prs --repo NVIDIA/OpenShell "<keywords>" --state open --json number,title,state,url,labels,updatedAt
gh search prs --repo NVIDIA/OpenShell "<keywords>" --state closed --json number,title,state,url,labels,updatedAt
```

Treat items as duplicate candidates when they share the same user-visible problem, requested capability, affected subsystem, or implementation approach. Do not rely on title similarity alone.

If a submission is an exact duplicate of an open validated issue or active PR:

1. Comment with the matching issue or PR.
2. Apply `duplicate` if available.
3. Close only when the duplicate relationship is clear and no extra author-specific context is needed.

If a submission appears related but may contain new constraints, reproduction details, or a different use case:

1. Move to `gator:follow-up-needed`.
2. Link the duplicate candidates.
3. Ask the author to explain what is different or whether the older issue/PR covers their need.
4. Flag the candidate duplicate set for human review in the comment.

If a PR duplicates another open PR or implements a feature already being reviewed elsewhere, move to `gator:follow-up-needed` unless a maintainer has already directed both PRs to proceed independently.

## Step 5: Auto-Validation

Auto-validate submissions from maintainers, but still review PR implementations.

Auto-validation applies when the submitter is:

- A CODEOWNER
- In `@NVIDIA/openshell-maintainers`

For maintainer-authored issues without PRs, move to `gator:validated` unless the issue is clearly security-sensitive and belongs outside GitHub.

For maintainer-authored PRs, move to `gator:in-review` and start PR monitoring. Auto-validation means the change is project-valid; it does not mean the implementation is merge-ready.

## Step 6: Validate Issues and PRs

Apply the criteria below in order. If evaluating an issue/PR pair, validate both as one submission but set each object to its appropriate current state:

- Issue without PR: `gator:validated`
- PR with or without linked issue: `gator:in-review`
- Issue linked to a valid active PR: `gator:validated` on the issue and `gator:in-review` on the PR

### Already Validated Issue

If a PR is mapped to an issue that is already valid for the same work, consider the PR project-valid and enter `gator:in-review` unless the PR clearly exceeds the issue scope.

### RFCs

For PRs that add or modify `rfc/**`, validate against `rfc/README.md` and `rfc/0000-template/README.md`:

- RFC lives in `rfc/NNNN-short-name/README.md`
- Front matter includes `authors`, `state`, and `links`
- State is one of `draft`, `review`, `accepted`, `rejected`, `implemented`, `superseded`
- RFC has summary, motivation, non-goals, proposal, implementation plan, risks, alternatives, prior art, and open questions
- RFC is appropriate for cross-cutting, architectural, API, process, or multi-team decisions
- Small bug fixes, small single-component features, docs, dependency updates, and interface-preserving refactors should not use RFCs

Distinguish structural validity from acceptance. A structurally valid RFC PR can enter `gator:in-review`, but implementation work should not be considered ready until the RFC is accepted or an explicit maintainer says otherwise.

### Small Concentrated Work

Validate small and concentrated work when it has clear motivation and one of these shapes:

- One subsystem: gateway, CLI, supervisor, drivers, network proxy, policy, sandbox, TUI, docs, build/release
- Refactor that removes duplicate code or simplifies internals without UX or functional impact
- Logical packaging refactor, such as splitting crates or separating proto/native schema boundaries
- Test improvements for important code paths or features
- Concentrated bug fix with reproducibility steps and a clear test path
- TUI, CLI, or API quality-of-life improvement with a clear user path
- Driver improvement that makes sandbox lifecycle management easier or more efficient
- Documentation clarification, typo fix, errata, or missing documentation
- CI/CD/build/release improvement, including Snap, package, release, or test harness work

Documentation changes from non-maintainers must not reorder ToC items, change fundamental hierarchy, or restructure docs without a clear maintainer-approved reason.

### Provider Profiles and Credential Support

Provider-profile work is a supported high-traction area, but requires all of the following:

- Clear UX path for how users configure and use the provider feature in OpenShell
- Clear statement of why the change is important
- Clear statement of who will use it
- Security boundary analysis for credential handling
- Explanation of whether secrets remain hidden from the sandbox agent

Provider profiles are the authoritative provider model. Provider additions and
updates must define their network policy, credentials, discovery, refresh
metadata, and user-facing semantics through a built-in or imported profile.
Treat any new or modified legacy `ProviderDiscoverySpec` entries as a blocking
review finding unless a maintainer explicitly requests the legacy path. Do not
ask contributors to update both systems for compatibility or to enable a
gateway feature switch; profile-backed behavior is always active.

Be skeptical of changes that expose raw credentials to agents or weaken the credential proxy model, even if the user story is clear.

### Large or Cross-Cutting Work

For larger changes that impact multiple subsystems, introduce major architecture changes, or touch high single-digit or double-digit file counts, require at least one:

- Fits an existing `roadmap` issue
- Directly follows an already validated issue or PR
- Has an accepted or actively reviewed RFC for the design
- Has explicit maintainer confirmation in the issue or PR thread

If this evidence is missing, use `gator:follow-up-needed` and ask for roadmap/RFC/linkage or maintainer clarification.

### Follow-Up Triggers

Use `gator:follow-up-needed` when the submission:

- Does not meet validation criteria yet
- Lacks practical demonstration of why the author is submitting it
- Lacks reproduction steps for a bug
- Lacks a clear UX path for a user-facing feature
- Supports a narrow upstream project convenience without showing why OpenShell should own it
- Suggests swapping core OpenShell components for another project's technology without a strong OpenShell-specific reason
- Introduces CLI/API/UX changes that only work for one driver implementation
- Overlaps existing work and needs reconciliation with the linked issue/PR/RFC

When requesting follow-up, ask only for the minimal missing information needed to validate.

### Invalid or Out of Scope

Close as not planned or wontfix when the submission is clearly outside OpenShell's scope, duplicates a resolved decision, weakens a project invariant without acceptable rationale, or remains unvalidated after the follow-up TTL.

Comment before closing and include a concise reason. Apply `wontfix` if appropriate and available.

## Step 7: Follow-Up TTL

When applying `gator:follow-up-needed`, post a comment with:

- What information is missing
- Who needs to respond, usually the original submitter
- That the item may be closed if no author or maintainer response arrives within 48 business hours

Business hours are Monday through Friday. Do not count Saturday or Sunday toward the 48-hour TTL.

Any substantive comment from the original submitter or a maintainer resets the clock. Maintainers may also manually change labels; respect the latest maintainer-applied state.

Bot comments and gator-agent comments do not reset the clock.

If TTL expires:

1. Comment that the TTL elapsed.
2. State that the issue or PR can be reopened or re-run through gator when the missing information is available.
3. Close the issue as not planned or close the PR.

## Step 8: PR Review Loop

When a PR enters `gator:in-review`, run an independent code-only review.

### Pragmatic review calibration

Keep reviews proportional, scope-bound, and convergent:

- Evaluate the change against its stated intent, supported user paths,
  documented threat model, and repository invariants.
- Make a finding blocking only when it identifies a concrete reachable
  scenario, material impact, a defect introduced or materially worsened by the
  PR, and a proportionate requested fix.
- Require every blocker to state its reachability, impact, and why this PR owns
  the problem. Do not make the author infer those from a speculative example.
- Do not block on pre-existing or orthogonal defects, unsupported
  configurations, speculative future requirements, stylistic preference, or
  implausible combinations of failures outside a real adversarial trust
  boundary. Preserve rigorous review of attacker-controlled input at actual
  trust boundaries.
- Consider the complexity cost of the requested fix. Do not require defensive
  branches, abstractions, configuration, or policy surface that make the code
  less readable or maintainable than the risk warrants. Prefer accepting a
  clear constraint or recommending non-blocking follow-up hardening.
- Classify minor improvements and low-probability hardening as Suggestions.
  Suggestions never require another commit, never count as unresolved review
  feedback, and never keep a PR in `gator:in-review`.
- Group equivalent cases into one root-cause finding. Describe the invariant
  that must hold and the complete supported failure class, not merely one
  failing input. Do not suggest a partial workaround when the broader failure
  class is already apparent.
- On the first review, inspect the complete PR and surface the complete known
  blocker set. On follow-up reviews, inspect unresolved feedback plus
  `<previous_reviewed_sha>..HEAD`; do not mine unchanged code for new findings.
- Introduce a finding against unchanged code on a follow-up only when newly
  available evidence demonstrates a Critical security, data-loss, or
  correctness defect. Explain the new evidence and why the earlier review could
  not reasonably have identified it.
- Route pre-existing security defects through the private security process.
  Do not publish exploit details or make them blockers on the current PR.
  Route other pre-existing defects to a non-blocking follow-up.
- Treat docs, skill drift, diagnostic wording, and test-strength feedback as
  non-blocking unless the published contract is materially false, the
  diagnostic causes an operational or safety failure, or missing coverage
  leaves a concrete PR-owned regression undetectable.

### Convergence and scope-growth checkpoint

After three finding-bearing rounds, the autonomous Warning budget is
exhausted. Set `review_scope.mode` to `critical_only`, stop posting new
Warnings, and inspect the latest author-only delta solely for a newly introduced
Critical security, data-loss, or correctness defect. Review-budget exhaustion
alone is not a process blocker and must not prevent required tests from
starting.

After the critical-only review, separately determine whether a maintainer
decision is actually required. Set `maintainer_decision_required` in the
internal cycle summary to true only when at least one of these applies:

- A prior finding remains unresolved and unwaived.
- Remediation introduced scope growth that crosses a linked issue or RFC
  non-goal, adds a new subsystem, or expands the public configuration or policy
  surface.
- Gator has a specific proposed Warning that it may post only if a maintainer
  explicitly authorizes another autonomous Warning-bearing round.

When a maintainer decision is required, summarize the relevant root causes,
dispositions, and scope growth; request only the concrete choice that is still
needed; and move to `gator:blocked` with reason
`review_convergence_decision_required`. Do not present generic choices that do
not apply to the PR.

When all prior findings are resolved or waived, no qualifying scope growth
exists, and no new Critical was found, set `maintainer_decision_required` to
false and continue directly to the E2E/test-label decision. Move to
`gator:watch-pipeline` only after the required workflows are confirmed queued,
running, or complete. Do not move to `gator:approval-needed` until every
required check is green.

A newly introduced Critical does not require a convergence decision. Post the
Critical with its complete evidence contract and keep the PR in
`gator:in-review`; do not add Warnings.

Require the same concrete maintainer decision before another autonomous review
when remediation introduces a new subsystem, crosses a linked issue or RFC
non-goal, or expands the public configuration or policy surface. Do not let
review feedback silently turn a focused PR into an architecture project.

For security-sensitive state machines, construct one remediation matrix before
requesting another fix. Cover the applicable protocol adapters, identity
replacement, revocation timing, snapshot versus live state, fallback behavior,
and trust-boundary transitions. Review the matrix as one invariant family so
fix-induced regressions are found together instead of one cell per round.

### Reviewer-quality telemetry

After normalization, include these internal metrics in the cycle summary:

- Semantic duplicate proposals divided by proposed findings. Use invariant
  fingerprints, not wording equality.
- Waived or resolved findings proposed again.
- Proposals scoped to unchanged code.
- Each finding's first-seen head SHA.
- Finding-bearing rounds and rounds to convergence.
- Critical or Warning proposals downgraded for a missing reproducer.

Use `review_telemetry` and `finding_history` from the ledger plus `telemetry`
from `review-findings.json`. These metrics evaluate Gator, not the contributor.
Do not post them as author criticism.

Before running the reviewer or posting any marked gator comment/review, build
and validate the feedback ledger. If its review mode is `already_reviewed`, do
not run the reviewer. If its mode is `critical_only`, follow the review-budget
rules above. Also check whether gator has already posted for the
current PR head SHA. Search existing issue comments and PR reviews for the gator
marker and either `Head SHA: <sha>`, `Head SHA: `<sha>``, or the current
`headRefOid` anywhere in the body. Gator may post at most one marked public
disposition for a given head SHA. A state-specific TTL nudge is separately
rate-limited and is not a disposition.

The `gh` write wrapper independently re-reads the current head, issue comments,
and reviews immediately before a marked POST. It fails closed when any lookup
fails and requires review dispositions to carry the exact head SHA and current
Gator payload version. Do not bypass guard exits 21 or 22. Return a transient
`gator_write_guard_failed` result and investigate stale payload or GitHub
transport state instead.

If the current head SHA already has a marked gator disposition:

- Do not run the reviewer sub-agent again for that SHA.
- Do not post another marked issue comment, `PR Review Status`, `Re-check After ... Update`, CI update, duplicate findings summary, or PR review for that SHA.
- Reuse the latest gator disposition for that SHA internally to decide whether the PR is still waiting on author action, ready for pipeline watch, or blocked.
- For any same-SHA status update, including CI completion, failed checks, human replies, label changes, or maintainer/reviewer comments, do not post a public status comment. Record the next state only in the supervised result sentinel.
- Do post a state-specific TTL nudge when it is due under the watch rules, even on the same SHA. Use only the nudge templates below, name the responsible actor and outstanding action, and respect the 48-business-hour limit for the same state and actor. A nudge neither authorizes another reviewer run nor consumes, replaces, or alters the existing disposition.

Only run a fresh review or post another marked public disposition when the PR head SHA changes, a maintainer explicitly asks gator to re-review or publicly respond on the same SHA, the PR reaches terminal merged/closed cleanup, or the earlier gator attempt failed before posting any marked disposition. State-specific TTL nudges remain allowed on an unchanged SHA as described above. A prior marked comment that only says the reviewer sub-agent failed before producing review output is a legacy infrastructure-failure report, not a valid current-head review disposition; ignore it for same-SHA review suppression and run the reviewer again. A prior marked `## Blocked` comment whose only blocker was that the PR was draft is also not a valid code-review disposition after the PR becomes ready for review; ignore it for same-SHA review suppression and run the reviewer once.

For PRs authored by `dependabot[bot]`, the primary gator responsibility is dependency-update validation, not normal feature review. Do a quick sanity check for suspicious changes outside expected dependency manifests or lockfiles, then ensure the full required test suite runs, including E2E, and watch for breakages caused by the update.

Use the `principal-engineer-reviewer` sub-agent. Include:

- PR title, body, linked issues, labels, and files
- The complete JSON from `/tmp/gator-review-feedback-ledger.json`
- For `initial` mode, the full PR diff or enough chunked context to review every change
- For `follow_up` mode, unresolved feedback plus the diff and affected-file
  context for `<previous_reviewed_sha>..HEAD`; include older code only when
  needed to understand that delta
- For `critical_only` mode, the latest author-only delta and explicit
  instruction to return only newly introduced Critical defects; the main Gator
  process, not the reviewer, determines whether a maintainer decision is needed
- An explicit instruction to carry open findings without duplicating them and
  to honor trusted resolved and waived findings across head SHAs
- An explicit instruction to apply the pragmatic review calibration above
- Instruction to focus on correctness, regressions, security, maintainability, and missing tests
- Instruction to check whether direct UX changes update the Fern docs under `docs/` and navigation when needed
- Instruction to classify each finding as blocking Critical, blocking Warning,
  or non-blocking Suggestion
- Instruction to assign each new blocker a stable
  `GATOR-<current-head-prefix>-<ordinal>` finding ID
- Instruction to group semantically equivalent examples under one invariant
- For each blocker, instruction to return the complete machine-enforced
  evidence contract in
  `references/review-findings-schema.md`, including attacker or operator
  prerequisite, supported entry point and sink, changed location,
  base-vs-head behavior, observable impact, a minimal deterministic
  reproducer, PR ownership, and a proportionate requested fix
- For each line-specific blocker, instruction to return the exact repository
  path, current-head diff line, side (`RIGHT` for an added/context line or
  `LEFT` for a deleted line), severity, finding ID, and concise comment body
- Instruction not to rely on local test execution

When running inside the `scripts/agents/gator` sandbox launcher, invoke the reviewer command specified in the sandbox prompt. Use `task.md` for the subagent input. Put the review feedback ledger, review mode, PR metadata, linked issue context, and mode-appropriate diff/file context in `task.md`. Require the reviewer to emit only the JSON envelope described in `references/review-findings-schema.md` to `review-findings.raw.json`, then run `validate-review-findings review-findings.raw.json > review-findings.json`. Only normalized entries with `blocking: true` may affect labels or public review comments. Missing evidence downgrades a proposed Critical or Warning to a non-blocking hypothesis; do not repair the reviewer output by guessing. The main gator process remains responsible for labels, comments, docs gates, and CI monitoring. Before posting, compare every proposed finding with all open, resolved, and waived ledger findings plus prior review summaries. Remove semantically equivalent findings unless the new diff reintroduces the defect or newly available evidence meets the Critical unchanged-code exception above. If the reviewer command exits nonzero or the saved reviewer output is absent, malformed, or fails envelope validation, stop the cycle with the `reviewer_subagent_failed` transient result described above without changing GitHub labels or posting a public disposition.

Post findings using these rules:

- For every blocking line-specific defect that can be anchored to the
  mode-appropriate diff, post an inline comment. Do not move an anchorable
  blocker into the summary merely for convenience.
- Submit all inline comments for a head SHA together in one `COMMENT` review. The review summary plus its complete inline-comment batch is the single gator disposition for that SHA.
- Begin the review summary and each inline body with `> **gator-agent**`. Put the current head SHA in the summary using the canonical `Head SHA: <sha>` field.
- Put the stable finding ID in every blocking summary item and inline comment.
- Keep the normalized evidence contract in `review-findings.json`; do not copy
  its field labels into the public comment. Render each new blocker as the
  human-first card below.
- Write `Summary` as natural prose that can be read aloud to someone who has
  not seen the code. In one compact paragraph, explain who encounters the
  problem, what they do, what goes wrong, and the concrete consequence. Prefer
  product concepts over internal identifiers unless an identifier is needed
  to understand the issue.
- Write `Fix` as a proportionate imperative derived from `requested_change`.
  Retain every operative constraint and required regression-test outcome.
- Write `Verify` as a deterministic setup, action, and current-versus-expected
  observation derived from `reproducer`. Preserve identity and equality
  qualifiers and distinguish concurrent calls, staged objects, and durable
  state when those distinctions matter.
- Across the visible card and its agent context, preserve the operative facts
  needed to understand, fix, and verify the blocker: exact trigger conditions,
  actor or permission scope, supported-path qualifiers, causal direction,
  observable impact, relevant identifiers, and negations. Never move a read,
  transform, store, forward, reject, or delete operation to a neighboring
  component for brevity. Do not infer missing facts.
- Do not expose `Invariant`, `Prerequisite`, `Entry point`, `Sink`, `Base`,
  `Head`, or `PR ownership` as headings. Those fields validate the finding;
  they are not the public explanation.
- Add collapsed `Agent context` after the visible card. Always include the
  validated `changed_location` as `path:line`. Include the exact execution
  path, PR ownership, minimal historical contrast, or concrete sibling sites
  only when that information is not already clear above and helps an agent act
  or establishes otherwise-unclear PR causality. Do not add empty rows or
  duplicate the visible prose. Most findings need no historical comparison.
- Target roughly 130 total words and about half the legacy evidence-dump
  length. Operative fidelity is the escape hatch: exceed the target rather
  than make the defect, fix, or verification ambiguous.
- Put review-process bookkeeping at the end of the review summary in one
  collapsed `<details><summary>Gator metadata</summary>` block. This includes
  validation provenance, docs and E2E disposition, check status, head/base/
  merge-base SHAs, patch ID, payload version, review mode, previous reviewed
  SHA, review-budget state, maintainer-decision state, next Gator state, and a
  machine-readable blocked reason. Keep the canonical `Head SHA: <sha>` and
  `Gator payload: <version>` text intact inside the block so the write guard
  and feedback ledger can parse them.
- Do not hide an action a person must take. When blocked, approval-needed, or
  awaiting clarification, put one plain-language `Action required:` sentence
  in the visible summary. Keep the redundant state code and operational detail
  in `Gator metadata`.
- Use the review summary for blocking design concerns, missing tests,
  cross-file findings, and blockers that cannot be anchored because the
  relevant line is outside the mode-appropriate diff. For an unanchored
  line-specific blocker, retain the `path:line` reference and state why it is
  in the summary.
- Put Suggestions only in a clearly labeled non-blocking summary section on the
  initial review. Do not post Suggestions as inline comments or repeat them on
  follow-up reviews.
- List still-open ledger findings as carried obligations by finding ID; do not
  create replacement threads or restate them as new findings.
- If there are no inline-eligible findings, use one general marked review or issue comment as the disposition.
- Do not submit standalone inline comments before or after the batch review. Do not post a separate PR Review Status issue comment for the same SHA after submitting the review.
- Do not nitpick style unless it affects maintainability or project conventions.

Build the batch as one REST request. Verify every requested line appears in the current diff before submission; GitHub rejects comments on lines that are not part of the diff. Use `RIGHT` for an added or context line in the current head and `LEFT` for a deleted line. Example request shape:

```json
{
  "commit_id": "<head-sha>",
  "event": "COMMENT",
  "body": "> **gator-agent**\n\n## PR Review Status\n\n<plain-language disposition and general findings>\n\n<details>\n<summary>Gator metadata</summary>\n\n- Head SHA: `<head-sha>`\n- Base SHA: `<base-sha>`\n- Merge base SHA: `<merge-base-sha>`\n- Patch ID: `<patch-id>`\n- Gator payload: `<payload-version>`\n\n</details>",
  "comments": [
    {
      "path": "crates/example/src/lib.rs",
      "line": 123,
      "side": "RIGHT",
      "body": "> **gator-agent**\n\n**Warning — GATOR-12345678-01 · Authorization happens after lookup**\n\n**Summary:** A user who can request a workspace can make the server look up another workspace before checking access. That discloses whether the workspace exists.\n\n**Fix:** Restore the authorization check before the workspace lookup and cover cross-workspace requests.\n\n**Verify:** Request another workspace as an unauthorized user; the server must return 404 without performing the lookup.\n\n<details>\n<summary>Agent context</summary>\n\n- **Agent path:** `GET /workspaces/{name}` → workspace record lookup\n- **Ownership:** This PR reordered the authorization check and lookup.\n- **Location:** `server.rs:123`\n\n</details>"
    }
  ]
}
```

```bash
gh api --method POST \
  repos/NVIDIA/OpenShell/pulls/<pr-number>/reviews \
  --input review.json
```

The root `body` is what the gator `gh` wrapper checks for the marker and current head SHA. Therefore one accepted request reserves exactly one same-SHA disposition even when `comments` contains multiple inline findings. If GitHub rejects any inline coordinate, fix the batch and retry before any disposition is accepted; do not fall back to a partial set of standalone comments.

If Critical or Warning findings require author changes, remain in
`gator:in-review` or move to `gator:follow-up-needed` if the author must clarify
the proposal before code review can continue. Suggestions alone do not require
author changes and do not prevent pipeline handoff.

For validated PRs with direct user-facing UX changes, require Fern docs updates before moving to `gator:watch-pipeline`. Direct UX changes include CLI commands/flags/output, sandbox behavior visible to users, provider setup flows, gateway configuration fields, TUI screens, published API behavior, policy syntax, installation/packaging behavior, and documented workflows. Accept either relevant updates under `docs/` plus `docs/index.yml` navigation when needed, or a clear maintainer-authored explanation in the PR that docs are intentionally unnecessary. If docs are missing and no explanation exists, treat it as review feedback.

If no blocking findings remain, decide whether E2E labels are needed, then move to `gator:watch-pipeline`.

When resuming a PR already in `gator:in-review`, use the feedback ledger to
determine which Gator findings or trusted maintainer comments are still
unanswered. Ignore unacknowledged third-party comments and reviews. If the PR
author has pushed commits and `review_scope.mode` is `follow_up`, review only
the unresolved obligations plus `<previous_reviewed_sha>..HEAD`, carrying all
other dispositions without duplicating them. Resolve the Gator-owned inline
threads for obligations that the follow-up confirms are fixed or explicitly
waived before posting the new-head disposition or advancing the label. If the
author replied without pushing a new commit, do not re-review, repost findings,
or post a same-SHA disposition; inspect the response internally and wait for a
new commit or maintainer override. If CI changes state without a new commit, do
not post a same-SHA CI update. A due TTL author nudge remains allowed when the
unresolved feedback still requires an author action.

If review feedback is waiting on the PR author for more than 48 business hours, post a single author nudge. Use the latest of these timestamps as the TTL start:

- The gator review comment that requested changes
- The latest maintainer review requesting changes
- The latest gator author-nudge comment
- The latest author commit or author response

Do not move to `gator:watch-pipeline` until review feedback is addressed or explicitly waived by a maintainer.

## Step 9: E2E and Test Label Decision

Apply or recommend `test:*` labels based on changed files and behavior.

Always apply or require `test:e2e` for PRs authored by `dependabot[bot]`. Dependabot PRs must run the full required test suite, including E2E, even when the dependency update appears isolated to manifests or lockfiles.

Use `test:e2e` for changes that affect:

- Sandbox lifecycle
- Gateway/supervisor interaction
- Policy enforcement
- Network proxy behavior
- Provider credential flow
- Docker, Podman, VM, or Kubernetes driver behavior
- Release packaging that needs a runtime smoke test

Use `test:e2e-gpu` for GPU runtime, CDI, CUDA, GPU driver, or GPU policy behavior.

Use `test:e2e` for Helm, Agent Sandbox CRDs, Kubernetes scheduling, namespace, workspace mode, or controller behavior; it runs the Kubernetes, managed-workspace, and operator-workspace suites.

Add `test:e2e-kubernetes` for gateway high availability or Kubernetes Secrets and Vault credential driver storage. It runs only the HA and credential-driver suites, so apply it alongside `test:e2e` when other Kubernetes coverage is also needed.

Apply `test:windows` whenever a PR affects Windows support. This includes Windows or MSVC CI and `mise` tasks, Windows lock-file platform entries, the MXC driver, and `cfg(windows)` implementations or tests in otherwise cross-platform crates. Apply it alongside any applicable E2E label; it is not a substitute for runtime coverage.

After applying a `test:*` label, read the bot comment that is posted by the E2E Label Help workflow and follow its instructions.

If a mirror is missing or stale and you have maintainer authority, post:

```text
/ok to test <full-head-sha>
```

`<full-head-sha>` MUST be the full 40-character SHA-1 of the current PR head. Read it fresh from GitHub immediately before posting instead of reusing a SHA from earlier in the cycle:

```bash
gh api repos/NVIDIA/OpenShell/pulls/<number> --jq .head.sha
```

The `/ok to test <full-head-sha>` comment must contain only that command. Do not include the `> **gator-agent**` marker, explanations, Markdown fences, or any other text in the same comment.

If you do not have maintainer authority, move to `gator:blocked` and state that a maintainer must post `/ok to test <full-head-sha>` with the full current head SHA written out.

Do not treat a test label or `/ok to test` comment as proof that testing
started. Confirm that every required workflow has a check or run for the
current head in `queued`, `in_progress`, or `completed` state before applying
`gator:watch-pipeline`. If the E2E Label Help bot says **Re-run all jobs** is
required:

- If the operator explicitly authorized workflow reruns, identify the relevant
  current-head run and rerun it with `gh run rerun <run-id>`, then verify that a
  new attempt was queued before moving to `gator:watch-pipeline`.
- If workflow reruns were not authorized or no rerunnable current-head run can
  be identified, move to `gator:blocked` with reason
  `test_dispatch_required` and state the exact maintainer action. Do not claim
  that CI monitoring is active.

## Step 10: Pipeline Watch Loop

When in `gator:watch-pipeline`, monitor PR checks and workflow runs.

Use:

```bash
gh pr checks <pr-number>
gh run list --branch <head-branch>
```

Required gates include at least:

- `OpenShell / Branch Checks`
- `OpenShell / Helm Lint`
- `OpenShell / Trivy Changes`
- `OpenShell / E2E` when `test:e2e` is applied
- `OpenShell / GPU E2E` when `test:e2e-gpu` is applied
- Both x64 and ARM64 `Windows MSVC / PR lint and test` checks when `test:windows` is applied

If checks are pending, wait a reasonable interval and re-check.

If checks fail:

- Inspect failed logs with `gh run view <run-id> --log-failed`
- Determine whether the failure is PR-caused, flaky, or infrastructure-related
- If author changes are required, comment and move to `gator:in-review` or `gator:follow-up-needed`
- If maintainer action is required, move to `gator:blocked`
- If explicitly authorized to push fixes, make the minimal fix and continue watching

When all required checks are green and no review feedback remains, inspect `reviewDecision` and trusted maintainer reviews. Move to `gator:merge-ready` if maintainer approval is present. Otherwise move to `gator:approval-needed`.

## Step 11: Approval Needed

When applying `gator:approval-needed`, post a concise handoff comment:

- Validation summary
- Review status
- CI status
- E2E labels and outcomes
- Remaining action: maintainer approval

Do not approve or merge unless explicitly instructed and authorized.

When resuming an item already in `gator:approval-needed`, first check whether maintainer approval is now present. If approval is present and required checks remain green with no unresolved review feedback, move to `gator:merge-ready`. Otherwise check whether maintainer approval has been waiting for more than 48 business hours since the latest of:

- The first `gator:approval-needed` handoff comment
- The most recent maintainer comment or review
- The most recent gator maintainer-nudge comment

If more than 48 business hours have elapsed, post a single nudge comment tagging `@NVIDIA/openshell-maintainers` and any relevant CODEOWNERS. For PRs, derive relevant CODEOWNERS from `.github/CODEOWNERS` and the changed files; because OpenShell has broad ownership, include the broad owner set when no more specific owner exists.

Do not post repeated nudges more often than once per 48 business hours. If the PR is no longer green, has new review feedback, or has changed materially, move it back to `gator:in-review` instead of nudging.

## Step 12: Merge Ready

When applying `gator:merge-ready`, post a concise handoff comment:

- Validation summary
- Review status
- Approval status
- CI status
- E2E labels and outcomes
- Remaining action: maintainer merge or close decision

Do not merge unless explicitly instructed and authorized.

When resuming an item already in `gator:merge-ready`, watch for merge, closure, new commits, failed checks, requested changes, or approval dismissal. If the PR merges or closes, perform closed/merged reconciliation. If checks fail or become pending, move to `gator:watch-pipeline`. If review feedback appears, approval is dismissed, or the author pushes new commits, move to `gator:in-review`.

If no merge or close decision occurs after 48 business hours, post a single merge-decision nudge tagging `@NVIDIA/openshell-maintainers` and any relevant CODEOWNERS. Use the latest of these timestamps as the TTL start:

- The first `gator:merge-ready` handoff comment
- The most recent maintainer comment or review
- The most recent gator merge-decision nudge comment

Do not post repeated nudges more often than once per 48 business hours.

## Comment Templates

### Follow-Up Needed

```markdown
> **gator-agent**

## Follow-Up Needed

I cannot validate this submission yet because <specific missing information>.

Please provide <minimal requested details>. If the original submitter or a maintainer does not respond within 48 business hours, this may be closed as not planned. Weekend hours do not count toward the TTL.
```

### Blocked

```markdown
> **gator-agent**

## Blocked

Gator is blocked by <blocker>.

Next action: <specific human action>.
```

### Validated Issue

```markdown
> **gator-agent**

## Validated

This issue is valid for OpenShell because <reason>.

Recommended next step: <create-spike/build-from-issue/human planning/other>.
```

### PR Review Handoff

```markdown
> **gator-agent**

## PR Review Status

<one or two natural sentences describing the review disposition>

Action required: <specific human action; include only when one is required>

Blocking findings:
- `<finding-id>`: <finding or "No blocking findings remain">

Carried findings:
- `<finding-id>`: <existing obligation or "None">

Non-blocking suggestions:
- <initial-review suggestion or "None"; omit on follow-up reviews>

<details>
<summary>Gator metadata</summary>

- Validation: <why this PR is project-valid>
- Docs: <Fern docs updated / not needed because ... / missing for direct UX change>
- Checks: <current-head required-check disposition>
- E2E: <current-head E2E disposition or N/A>
- Head SHA: `<sha>`
- Base SHA: `<sha>`
- Merge base SHA: `<sha>`
- Patch ID: `<stable patch id>`
- Gator payload: `<payload version>`
- Review mode: `<initial|follow_up|critical_only>`
- Previous reviewed SHA: `<sha or none>`
- Review budget exhausted: `<yes|no>`
- Maintainer decision required: `<yes|no — concrete reason when yes>`
- Next state: `<gator:in-review|gator:watch-pipeline|gator:follow-up-needed|gator:blocked>`
- Blocked reason: `<machine-readable reason; include only when blocked>`

</details>
```

### Maintainer Convergence Decision

```markdown
> **gator-agent**

## Maintainer Convergence Decision

The autonomous Warning budget is exhausted, and a specific maintainer decision
is required before review can proceed.

Root-cause findings:
- `<finding-id>`: <invariant and current disposition>

Scope growth:
- <new subsystem, non-goal crossing, remediation complexity, or "None">

Reviewer-quality signals:
- <duplicate, waived re-raise, unchanged-code proposal, or "None">

Maintainer action: <state only the applicable choice, affected finding or scope
boundary, and exact next action>

<details>
<summary>Gator metadata</summary>

- Head SHA: `<sha>`
- Base SHA: `<sha>`
- Merge base SHA: `<sha>`
- Patch ID: `<stable patch id>`
- Gator payload: `<payload version>`
- Next state: `gator:blocked`
- Blocked reason: `review_convergence_decision_required`

</details>
```

### Human Response Disposition

Post this as a new comment after a substantive author, maintainer, or reviewer response. Do not edit an older gator comment for this case.

```markdown
> **gator-agent**

## Re-check After <author|maintainer|reviewer> Update

Thanks <person>. I re-evaluated latest head `<sha>` after your <date/time> comment about <short paraphrase>.

What I checked: <specific files, checks, or behavior inspected because of the comment>.

Disposition: <resolved / partially resolved / not resolved / needs clarification>.

Remaining items:
- <specific unresolved item, or "No blocking items remain">

Action required: <specific human action; include only when one is required>

<details>
<summary>Gator metadata</summary>

- Head SHA: `<sha>`
- Base SHA: `<sha>`
- Merge base SHA: `<sha>`
- Patch ID: `<stable patch id>`
- Gator payload: `<payload version>`
- Next state: `<gator:in-review|gator:watch-pipeline|gator:follow-up-needed|gator:blocked|gator:approval-needed|gator:merge-ready>`
- Blocked reason: `<machine-readable reason; include only when blocked>`

</details>
```

### Approval Needed

```markdown
> **gator-agent**

## Maintainer Approval Needed

Gator validation and PR monitoring are complete.

Review: <summary>

Human maintainer approval is now required.

<details>
<summary>Gator metadata</summary>

- Validation: <summary>
- Docs: <summary>
- Checks: <summary>
- E2E: <summary or N/A>
- Next state: `gator:approval-needed`

</details>
```

### Merge Ready

```markdown
> **gator-agent**

## Merge Ready

Gator validation and PR monitoring are complete, and maintainer approval is present.

Review: <summary>
Approval: <summary>

Human maintainer merge or close decision is now required.

<details>
<summary>Gator metadata</summary>

- Validation: <summary>
- Docs: <summary>
- Checks: <summary>
- E2E: <summary or N/A>
- Next state: `gator:merge-ready`

</details>
```

### Monitoring Complete

```markdown
> **gator-agent**

## Monitoring Complete

Monitoring is complete because this PR has <merged / been closed without merge>.

Final status: <summary of the last known gator state, checks, or review status when useful>

I removed the active `gator:*` label because there is nothing left for gator to monitor on this PR.
```

### Maintainer Nudge

```markdown
> **gator-agent**

## Maintainer Review Nudge

This PR has been in `gator:approval-needed` for more than 48 business hours with no maintainer approval.

@NVIDIA/openshell-maintainers <relevant CODEOWNER mentions>, can someone review and either approve, request changes, or close this out?
```

### Merge Decision Nudge

```markdown
> **gator-agent**

## Merge Decision Nudge

This PR has been in `gator:merge-ready` for more than 48 business hours with maintainer approval present and no merge or close decision.

@NVIDIA/openshell-maintainers <relevant CODEOWNER mentions>, can someone merge this PR or close/request changes if it should not proceed?
```

### Author Nudge

```markdown
> **gator-agent**

## Author Follow-Up Nudge

This PR has been in `gator:in-review` for more than 48 business hours with unresolved review feedback.

@<author>, please respond to the review comments or push an update. If this is no longer planned, please say so and a maintainer can close it out.
```

### Blocker Nudge

```markdown
> **gator-agent**

## Blocker Follow-Up Nudge

This item is still blocked by <blocker> after more than 48 business hours.

Next action: <specific responsible party and action>.
```

### Possible Duplicate

```markdown
> **gator-agent**

## Possible Duplicate

This looks related to existing work:

- <issue-or-pr-link>: <why it may overlap>

Please confirm whether this submission has different requirements or reproduction details. A maintainer should review the duplicate relationship before this proceeds.
```
