Repository navigation
Restrict /review rerun eligibility to author activity #35874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
129b09d
7aa823e
ace4373
6579016
3939e24
f264273
0e519c1
df5f314
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,12 @@ BeforeAll { | |
| } | ||
|
|
||
| Describe 'Resolve-RerunEligibility' { | ||
| It 'normalizes app-style GitHub bot author logins' { | ||
| Normalize-GitHubActorLogin 'app/dependabot' | Should -Be 'dependabot[bot]' | ||
| Normalize-GitHubActorLogin ' dependabot[bot] ' | Should -Be 'dependabot[bot]' | ||
| Normalize-GitHubActorLogin '' | Should -Be '' | ||
| } | ||
|
|
||
| It 'parses review command branch and platform options for reruns' { | ||
| $parsed = ConvertFrom-ReviewCommand '/review -b feature/regression-check -p ios' | ||
|
|
||
|
|
@@ -90,6 +96,11 @@ Describe 'Resolve-RerunEligibility' { | |
| Should -Be 'feature/regression-check' | ||
| } | ||
|
|
||
| It 'normalizes app-style GitHub actor logins to bot logins' { | ||
| Normalize-GitHubActorLogin 'app/dependabot' | Should -Be 'dependabot[bot]' | ||
| Normalize-GitHubActorLogin 'dev-user' | Should -Be 'dev-user' | ||
| } | ||
|
|
||
| It 'finds latest normal review command while ignoring rerun and tests commands' { | ||
| $comments = @( | ||
| New-TestComment -Id 1 -Body '/review -b old/ref -p android' -CreatedAt '2026-05-31T09:00:00Z' | ||
|
|
@@ -193,17 +204,30 @@ Describe 'Resolve-RerunEligibility' { | |
| $result.Reason | Should -Be 'no-new-comments-or-commits' | ||
| } | ||
|
|
||
| It 'accepts a non-command comment after the latest AI Summary' { | ||
| It 'accepts a non-command PR author comment after the latest AI Summary' { | ||
| $comments = @( | ||
| New-TestComment -Id 1 -Body (New-AISummaryBody) -CreatedAt '2026-05-31T09:00:00Z' -UpdatedAt '2026-05-31T09:30:00Z' -Login 'MauiBot' -Type 'User' | ||
| New-TestComment -Id 2 -Body 'I pushed the requested update.' -CreatedAt '2026-05-31T09:45:00Z' | ||
| New-TestComment -Id 10 -Body '/review rerun' -CreatedAt '2026-05-31T10:00:00Z' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' | ||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeTrue | ||
| $result.Reason | Should -Be 'new-comment-after-ai-summary' | ||
| $result.Reason | Should -Be 'new-author-comment-after-ai-summary' | ||
| } | ||
|
|
||
| It 'rejects a non-author maintainer comment after the latest AI Summary' { | ||
| $comments = @( | ||
| New-TestComment -Id 1 -Body (New-AISummaryBody) -CreatedAt '2026-05-31T09:00:00Z' -UpdatedAt '2026-05-31T09:30:00Z' -Login 'MauiBot' -Type 'User' | ||
| New-TestComment -Id 2 -Body 'Could you please check the AI suggestions?' -CreatedAt '2026-05-31T09:45:00Z' -Login 'kubaflo' -Kind 'review' | ||
| New-TestComment -Id 10 -Body '/review rerun' -CreatedAt '2026-05-31T10:00:00Z' -Login 'kubaflo' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeFalse | ||
| $result.Reason | Should -Be 'no-new-comments-or-commits' | ||
| } | ||
|
|
||
| It 'uses AI Summary creation time as the activity checkpoint when the summary was edited later' { | ||
|
|
@@ -213,10 +237,10 @@ Describe 'Resolve-RerunEligibility' { | |
| New-TestComment -Id 10 -Body '/review rerun' -CreatedAt '2026-05-31T10:00:00Z' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' | ||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeTrue | ||
| $result.Reason | Should -Be 'new-comment-after-ai-summary' | ||
| $result.Reason | Should -Be 'new-author-comment-after-ai-summary' | ||
| } | ||
|
|
||
| It 'selects the newest AI Summary by creation time instead of edit time' { | ||
|
|
@@ -227,10 +251,10 @@ Describe 'Resolve-RerunEligibility' { | |
| New-TestComment -Id 10 -Body '/review rerun' -CreatedAt '2026-05-31T10:30:00Z' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha '2222222abcdef' | ||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha '2222222abcdef' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeTrue | ||
| $result.Reason | Should -Be 'new-comment-after-ai-summary' | ||
| $result.Reason | Should -Be 'new-author-comment-after-ai-summary' | ||
| } | ||
|
|
||
| It 'ignores forged AI Summary comments from non-bots' { | ||
|
|
@@ -277,10 +301,10 @@ Describe 'Resolve-RerunEligibility' { | |
| New-TestComment -Id 4659999999 -Body '/review rerun' -CreatedAt '2026-06-09T09:00:00Z' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 4659999999 -CurrentHeadSha '6e9af5bc8b5d0023400d653500951fb46df44170' | ||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 4659999999 -CurrentHeadSha '6e9af5bc8b5d0023400d653500951fb46df44170' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeTrue | ||
| $result.Reason | Should -Be 'new-comment-after-ai-summary' | ||
| $result.Reason | Should -Be 'new-author-comment-after-ai-summary' | ||
| } | ||
|
|
||
| It 'uses the first session marker from an AI Summary' { | ||
|
|
@@ -308,18 +332,18 @@ new | |
| $result.Reason | Should -Be 'no-new-comments-or-commits' | ||
| } | ||
|
|
||
| It 'accepts a non-command comment after the previous rerun command' { | ||
| It 'accepts a non-command PR author comment after the previous rerun command' { | ||
| $comments = @( | ||
| New-TestComment -Id 1 -Body (New-AISummaryBody) -CreatedAt '2026-05-31T09:00:00Z' -UpdatedAt '2026-05-31T09:30:00Z' -Login 'MauiBot' -Type 'User' | ||
| New-TestComment -Id 8 -Body '/review rerun' -CreatedAt '2026-05-31T09:45:00Z' | ||
| New-TestComment -Id 9 -Body 'Follow-up detail after rerun request.' -CreatedAt '2026-05-31T09:50:00Z' | ||
| New-TestComment -Id 10 -Body '/review rerun' -CreatedAt '2026-05-31T10:00:00Z' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' | ||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeTrue | ||
| $result.Reason | Should -Be 'new-comment-after-previous-rerun' | ||
| $result.Reason | Should -Be 'new-author-comment-after-previous-rerun' | ||
| } | ||
|
|
||
| It 'does not reuse old activity from before a previous rerun command' { | ||
|
|
@@ -343,10 +367,10 @@ new | |
| New-TestComment -Id 10 -Body '/review rerun' -CreatedAt '2026-05-31T10:00:00Z' | ||
| ) | ||
|
|
||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' | ||
| $result = Resolve-RerunEligibility -Comments $comments -Commits @() -CurrentCommentId 10 -CurrentHeadSha 'abcdef123' -PRAuthorLogin 'dev-user' | ||
|
|
||
| $result.Eligible | Should -BeTrue | ||
| $result.Reason | Should -Be 'new-comment-after-ai-summary' | ||
| $result.Reason | Should -Be 'new-author-comment-after-ai-summary' | ||
| } | ||
|
|
||
| It 'accepts a current head SHA that differs from the latest reviewed session' { | ||
|
|
@@ -418,21 +442,35 @@ new | |
| $comments = @( | ||
| New-TestComment -Id 1 -Body (New-AISummaryBody) -CreatedAt '2026-05-31T09:00:00Z' -UpdatedAt '2026-05-31T09:30:00Z' -Login 'MauiBot' -Type 'User' | ||
| New-TestComment -Id 2 -Body 'New author context.' -CreatedAt '2026-05-31T09:45:00Z' | ||
| New-TestComment -Id 11 -Body 'Reviewer reminder.' -CreatedAt '2026-05-31T09:46:00Z' -Login 'reviewer' | ||
| New-TestComment -Id 3 -Body '/review rerun' -CreatedAt '2026-05-31T09:50:00Z' | ||
| ) | ||
| $commits = @( | ||
| New-TestCommit -Sha 'fedcba9876543210' -Date '2026-05-31T09:48:00Z' | ||
| ) | ||
|
|
||
| $context = New-RerunContextMarkdown -Comments $comments -Commits $commits -CurrentHeadSha 'fedcba9876543210' -CurrentLabels @('s/agent-review-in-progress') | ||
| $context = New-RerunContextMarkdown -Comments $comments -Commits $commits -CurrentHeadSha 'fedcba9876543210' -PRAuthorLogin 'dev-user' -CurrentLabels @('s/agent-review-in-progress') | ||
|
|
||
| $context | Should -Match '# Rerun Context' | ||
| $context | Should -Match 'New non-command comments: 1' | ||
| $context | Should -Match 'New non-command author comments: 1' | ||
| $context | Should -Match 'New commits: 1' | ||
| $context | Should -Match '`s/agent-ready-for-rerun` present: false' | ||
| $context | Should -Match '`s/agent-review-in-progress` present: true' | ||
| $context | Should -Match 'New author context' | ||
| $context | Should -Not -Match 'Reviewer reminder' | ||
| $context | Should -Match 'fedcba9' | ||
| $context | Should -Not -Match '\| .*\/review rerun' | ||
| } | ||
|
|
||
| It 'renders normalized app-style bot authors in rerun context' { | ||
| $comments = @( | ||
| New-TestComment -Id 1 -Body (New-AISummaryBody) -CreatedAt '2026-05-31T09:00:00Z' -UpdatedAt '2026-05-31T09:30:00Z' -Login 'MauiBot' -Type 'User' | ||
| New-TestComment -Id 3 -Body '/review rerun' -CreatedAt '2026-05-31T09:50:00Z' | ||
| ) | ||
|
|
||
| $context = New-RerunContextMarkdown -Comments $comments -Commits @() -CurrentHeadSha 'abcdef123' -PRAuthorLogin 'app/dependabot' | ||
|
|
||
| $context | Should -Match 'PR author: dependabot\[bot\]' | ||
| $context | Should -Match 'New non-command author comments: 0' | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Test Quality — this test name overclaims; the "no bot evidence" assertions are satisfied by the pre-existing The round-2 fix added Empirically verified by dot-sourcing the function:
Implication: the fix is decision-neutral for bot evidence — its only functional effect is the displayed Fix: either (a) rename this test to focus solely on display normalization ( |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Regression — empty-stderr temp file causes
.Trim()to throw on every successfulgh apicallFlagged by: 3/3 reviewers (unanimous), empirically reproduced in pwsh 7.4.5
When
gh api repos/.../pulls/Nsucceeds, it writes JSON to stdout and nothing to stderr, so2> $prStdErrFileleaves the temp file at 0 bytes.Get-Content -Rawon an empty file returns$null, and($null).Trim()throws "You cannot call a method on a null-valued expression" under the script-level$ErrorActionPreference = 'Stop'.Line 330 runs unconditionally on every iteration (even though
$prStdErris only read on the error path at line 335). So the throw fires on the happy path, gets caught at line 439, sets$hadProcessingFailure = $true, andcontinues — before any reaction, label removal, or AzDO trigger.Concrete failure scenario: Scheduled scanner runs hourly. Agent emits
trigger/skipfor a real queued PR → line 330 throws → PR is never triggered, thes/agent-ready-for-rerunlabel is never removed (so the same PR is re-queued and re-fails forever), and the job exits1(red) on every run. This is strictly worse than round-2's2>&1regression, which only corrupted JSON when gh actually wrote to stderr.Self-correction note: This regression was introduced by round-3's fix for round-2's
2>&1finding. (Reference: gh-aw reviewer skill self-correction rule — treat as high-confidence even though only one reviewer ran the empirical reproduction; both other reviewers independently flagged the same null-trim bug from static analysis.)Note
$prJson = ($prOutput | Out-String).Trim()at line 329 is safe —Out-Stringreturns"", never$null. Only line 330 is affected.Fix: coerce to string before
.Trim():(
[string]$null→''.)