diff --git a/.agents/agents/gator/agent.yaml b/.agents/agents/gator/agent.yaml index 54fd5f55d3..2a2b217235 100644 --- a/.agents/agents/gator/agent.yaml +++ b/.agents/agents/gator/agent.yaml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 id: gator -payload_version: 15 +payload_version: 16 display_name: Gator Gate Agent description: Validate and monitor OpenShell GitHub issues and pull requests through the gator state machine. diff --git a/.agents/agents/gator/bin/gh b/.agents/agents/gator/bin/gh index d65159ff7b..df57741200 100755 --- a/.agents/agents/gator/bin/gh +++ b/.agents/agents/gator/bin/gh @@ -116,10 +116,20 @@ is_ttl_state_nudge() { esac } +is_deferred_process_disposition() { + local lower_body + lower_body="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" + [[ "$lower_body" == *"## blocked"* ]] || return 1 + [[ "$lower_body" == *"reviewer deferred"* ]] || return 1 + [[ "$lower_body" != *"## pr review status"* && "$lower_body" != *"## re-check after"* ]] || return 1 + ! grep -Eq 'GATOR-[[:xdigit:]]{8}-[[:digit:]]+' <<< "$1" +} + has_blocking_same_sha_disposition() { local head_sha="$1" local current_is_draft="$2" local encoded_bodies="$3" + local proposed_body="$4" local encoded_body existing_body while IFS= read -r encoded_body; do @@ -136,6 +146,13 @@ has_blocking_same_sha_disposition() { continue fi + # A deferred process report consumes no review slot, but still prevents + # repeated blocker comments. The gate must recheck blockers before review. + if [[ "$current_is_draft" != "true" && "$proposed_body" == *"## PR Review Status"* ]] && + is_deferred_process_disposition "$existing_body"; then + continue + fi + return 0 done <<< "$encoded_bodies" @@ -183,7 +200,7 @@ guard_duplicate_gator_disposition() { return 21 fi - if has_blocking_same_sha_disposition "$head_sha" "$current_is_draft" "$(printf '%s\n%s\n' "$existing_comments" "$existing_reviews")"; then + if has_blocking_same_sha_disposition "$head_sha" "$current_is_draft" "$(printf '%s\n%s\n' "$existing_comments" "$existing_reviews")" "$body"; then echo "openshell-agent: blocked duplicate gator same-SHA disposition for $owner/$repo#$number ($head_sha)" >&2 echo "openshell-agent: push a new commit, remove the old disposition, or set OPENSHELL_GATOR_ALLOW_SAME_SHA_COMMENT=1 for an explicit maintainer-requested same-SHA action" >&2 return 20 diff --git a/.agents/agents/gator/prompts/gator.md b/.agents/agents/gator/prompts/gator.md index b9c7baffbc..83fefde812 100644 --- a/.agents/agents/gator/prompts/gator.md +++ b/.agents/agents/gator/prompts/gator.md @@ -12,6 +12,11 @@ Load and follow this skill exactly: Important sandbox constraints: +- Reconcile resolved process blockers even on an unchanged head. A process-only + report that deferred review is not a completed code review; follow the gate + skill's first-review exception. Non-required check statuses never block + progression; inspect required checks separately from the full rollup. + - Target ai-openshell/openshell unless the operator explicitly scopes this run to a private advisory fork. Never substitute the public repository for a private target. GitHub writes remain subject to the provider policy. diff --git a/.agents/agents/gator/skills/gator-gate/SKILL.md b/.agents/agents/gator/skills/gator-gate/SKILL.md index 55d7986156..9c8acb8264 100644 --- a/.agents/agents/gator/skills/gator-gate/SKILL.md +++ b/.agents/agents/gator/skills/gator-gate/SKILL.md @@ -427,7 +427,7 @@ Use 48 business hours as the default inactivity threshold for states that are wa 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. +- `gator:blocked`: re-check the blocker. If resolved, remove `gator:blocked` and continue to the previous intended state, even on the same head SHA. A public-comment guard must not prevent label or internal-state reconciliation. If still blocked after 48 business hours, nudge the responsible party. - `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. @@ -452,7 +452,7 @@ Move to `gator:blocked` when any of these apply: - PR is draft and not ready for review - DCO is missing or failing - PR has merge conflicts or `mergeStateStatus` indicates dirty/blocked for conflict reasons -- An outside contributor's workflow runs await approval and the current user lacks maintainer authority +- An outside contributor's required workflows or selected test suites await approval and the current user lacks maintainer authority or operator authorization 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. @@ -738,7 +738,12 @@ current PR head SHA. Search existing issue comments and PR reviews for the gator marker and either `Head SHA: `, ``Head 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. +rate-limited and is not a disposition. A process-only `## Blocked` report with +`Review mode: initial; reviewer deferred for process blockers` and no findings +does not consume the code-review slot. Preserve that report in the ledger, but +once every process blocker clears, run the first code review on the same head +and post its `PR Review Status`. This exception does not permit repeated blocker +reports, CI updates, or another review after a real code-review 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 @@ -747,7 +752,7 @@ 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: +If the current head SHA already has a marked gator code-review 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. @@ -755,7 +760,13 @@ If the current head SHA already has a marked gator disposition: - 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. +The deferred-process exception above also permits the first review after a +same-head process report. Recheck draft status, mergeability, DCO, issue +acceptance, and required workflow approval before proceeding. Mark process +reports with the review-mode field only when no code review ran and no findings +are being carried. Do not reinterpret an actual review as a process-only report. + +Apart from the deferred-process exception above, 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. @@ -968,11 +979,14 @@ When in `gator:watch-pipeline`, monitor PR checks and workflow runs. Use: ```bash -gh pr checks +gh pr checks --required gh run list --branch ``` -Required gates include at least: +Discover required checks from the repository's rules using `--required`; do not +infer requiredness from the complete check rollup or a workflow's name. Also +require execution of suites selected by applicable `test:*` labels. Typical +required gates are: - `OpenShell / Branch Checks` - `OpenShell / Helm Lint` @@ -980,9 +994,16 @@ Required gates include at least: - `OpenShell / E2E` when `test:e2e` 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. +Only required checks and selected test suites gate progression. Non-required +checks, including advisory compatibility review, never block review, label +transitions, or handoff, whether pending, failed, or awaiting approval. They may +inform review findings, but their check status is not itself a blocker. If +requiredness cannot be determined, report the lookup failure rather than treating +every check as required. + +If required checks are pending, wait a reasonable interval and re-check. -If checks fail: +If required checks fail: - Inspect failed logs with `gh run view --log-failed` - Determine whether the failure is PR-caused, flaky, or infrastructure-related diff --git a/.agents/agents/gator/tests/gh_guard_test.sh b/.agents/agents/gator/tests/gh_guard_test.sh index 086547d882..ae85124ce7 100755 --- a/.agents/agents/gator/tests/gh_guard_test.sh +++ b/.agents/agents/gator/tests/gh_guard_test.sh @@ -46,6 +46,9 @@ if [[ "$1" == "api" && "$2" == "repos/ai-openshell/openshell/issues/1865/comment if [[ -n "$MOCK_EXISTING_BODY" ]]; then jq -Rn --arg body "$MOCK_EXISTING_BODY" '$body' fi + if [[ -n "${MOCK_EXTRA_EXISTING_BODY:-}" ]]; then + jq -Rn --arg body "$MOCK_EXTRA_EXISTING_BODY" '$body' + fi exit 0 fi @@ -295,4 +298,42 @@ Gator payload: `2`' \ false \ comments +process_blocked_body='> **gator-agent** + +## Blocked + +Required workflows await native approval. Code review remains deferred. + +Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f` +Review mode: `initial; reviewer deferred for process blockers` +Blocked reason: `test_dispatch_required`' + +run_review_case "allows first review after a deferred process report" \ + "$process_blocked_body" 0 +MOCK_EXTRA_EXISTING_BODY="$same_sha_body" \ + run_review_case "an actual review still blocks alongside a process report" \ + "$process_blocked_body" 20 +run_case "does not allow repeated process reports" \ + "$process_blocked_body" "$process_blocked_body" 20 +run_case "does not allow CI updates after a process report" \ + "$process_blocked_body" '> **gator-agent** + +## CI Update' 20 +run_case "does not allow a review while still draft" \ + "$process_blocked_body" '> **gator-agent** + +## PR Review Status' 20 true +run_review_case "does not ignore a blocker with review findings" \ + "$process_blocked_body +Carried finding: GATOR-11111111-01" 20 +run_review_case "does not ignore an actual review mentioning deferral" \ + "$process_blocked_body +## PR Review Status +The review found a blocking regression." 20 +run_review_case "does not infer review deferral from a generic blocker" \ + '> **gator-agent** + +## Blocked +Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f`' 20 + printf 'PASS: gh same-SHA guard tests\n' diff --git a/.agents/agents/gator/tests/review_feedback_ledger_test.sh b/.agents/agents/gator/tests/review_feedback_ledger_test.sh index cdf1746179..02c4f16c1f 100755 --- a/.agents/agents/gator/tests/review_feedback_ledger_test.sh +++ b/.agents/agents/gator/tests/review_feedback_ledger_test.sh @@ -399,6 +399,23 @@ jq -e ' (.threads | length) > 0 ' "$tmp/no-patch-ledger.json" >/dev/null +jq ' + .review_pages = [] | + .thread_pages[0].data.repository.pullRequest.reviewThreads.nodes = [] | + .issue_comment_pages = [[{ + id: 9900, + body: "> **gator-agent**\n\n## Blocked\n\nHead SHA: `2222222222222222222222222222222222222222`\nReview mode: `initial; reviewer deferred for process blockers`\nBlocked reason: `test_dispatch_required`", + created_at: "2026-07-28T20:00:00Z" + }]] +' "$tmp/raw-ledger-input.json" > "$tmp/process-input.json" +"$LEDGER" --input "$tmp/process-input.json" > "$tmp/process-ledger.json" +jq -e ' + (.dispositions | length) == 1 and + .dispositions[0].is_code_review == false and + .review_rounds == 0 and .last_reviewed_sha == null and + .review_scope.mode == "initial" +' "$tmp/process-ledger.json" >/dev/null + rg -q 'COPY bin/review-feedback-ledger /usr/local/bin/review-feedback-ledger' \ "$GATOR_DIR/Dockerfile" rg -q 'COPY bin/resolve-gator-review-threads /usr/local/bin/resolve-gator-review-threads' \ @@ -407,7 +424,7 @@ rg -q 'COPY bin/validate-review-findings /usr/local/bin/validate-review-findings "$GATOR_DIR/Dockerfile" ruby -ryaml -e ' manifest = YAML.load_file(ARGV.fetch(0)) - abort unless manifest.fetch("payload_version") == 15 + abort unless manifest.fetch("payload_version") == 16 resource = manifest.fetch("resources").find { |entry| entry.fetch("id") == "gator-review-findings-schema" } @@ -422,6 +439,10 @@ rg -q 'review-feedback-ledger ai-openshell openshell ' \ rg -q 'Every prior Gator finding is a durable review disposition' \ "$GATOR_DIR/skills/gator-gate/SKILL.md" rg -q 'review feedback ledger' "$GATOR_DIR/prompts/gator.md" +rg -Fq 'gh pr checks --required' "$GATOR_DIR/skills/gator-gate/SKILL.md" +rg -Fq 'Non-required' "$GATOR_DIR/skills/gator-gate/SKILL.md" +rg -Fq 'checks, including advisory compatibility review, never block review' \ + "$GATOR_DIR/skills/gator-gate/SKILL.md" # Keep security routing consistent across the gate, top-level prompt, and # independent reviewer; PR-owned regressions must remain actionable reviews. rg -Fq 'PR in that PR' "$GATOR_DIR/skills/gator-gate/SKILL.md" diff --git a/.agents/skills/launch-openshell-gator/SKILL.md b/.agents/skills/launch-openshell-gator/SKILL.md index e068d0bb9b..011115b162 100644 --- a/.agents/skills/launch-openshell-gator/SKILL.md +++ b/.agents/skills/launch-openshell-gator/SKILL.md @@ -243,7 +243,7 @@ refuses PRs changing `.github/`, which need manual inspection and approval. Do not reuse an old launch assignment's `/ok to test` authorization as permission to approve workflow runs. Request explicit workflow-approval authorization. -When payload 15 is published, replace still-active older watchers after checking +When payload 16 is published, replace still-active older watchers after checking their current state. Baked skills cannot update in place. Keep private-advisory watchers scoped to their private repository and review-only authorization. @@ -419,6 +419,7 @@ The wrapper intentionally blocks duplicate same-head-SHA gator dispositions. A r - The earlier attempt failed before posting. - The prior marked disposition was only a reviewer infrastructure failure. - The prior marked disposition was only a draft blocker and the PR is now ready for review. +- A process-only report explicitly deferred review, all process blockers cleared, and no code review exists for that head. The gate and wrapper permit the first `PR Review Status`, not repeated process reports. - A state-specific TTL nudge is due after 48 business hours. The nudge may request the pending human action, but it must not repeat the review disposition or trigger another reviewer run.