Summary
Add the core library functions for LGTM comment override support. hasNonStaleLgtm is a pure function that checks PR comments for non-stale LGTM. hasHumanOverride is an async helper that fetches all needed data and checks both override mechanisms (approval + LGTM).
Files to modify
.github/agent-workflow/scripts/lib/approval.js
.github/agent-workflow/scripts/lib/override.js (new)
tests/lib/approval.test.js
tests/lib/override.test.js (new)
Implementation steps
-
Add hasNonStaleLgtm(comments, headCommitDate) to approval.js:
- Check if any comment body (trimmed, uppercased) starts with "LGTM"
- Check if comment
created_at is after headCommitDate
- Export alongside
hasNonStaleApproval
-
Create override.js with hasHumanOverride({ github, owner, repo, prNumber, headSha }):
- Fetch reviews, comments, and commit in parallel via
Promise.all
- Return
true if hasNonStaleApproval(reviews, headSha) OR hasNonStaleLgtm(comments, headCommitDate)
- Export
hasHumanOverride
-
Add tests to approval.test.js for hasNonStaleLgtm:
- LGTM posted after head commit → true
- LGTM posted before head commit (stale) → false
- Lowercase "lgtm" → true
- "LGTM, looks good" (extra text) → true
- No LGTM comments → false
- Empty array → false
-
Create override.test.js for hasHumanOverride:
- Approval present → true (short-circuits, no comment check needed)
- No approval, LGTM present → true
- Neither present → false
- Mock GitHub API calls
Acceptance criteria
Dependencies
None — this is the foundation for the other tasks.
Summary
Add the core library functions for LGTM comment override support.
hasNonStaleLgtmis a pure function that checks PR comments for non-stale LGTM.hasHumanOverrideis an async helper that fetches all needed data and checks both override mechanisms (approval + LGTM).Files to modify
.github/agent-workflow/scripts/lib/approval.js.github/agent-workflow/scripts/lib/override.js(new)tests/lib/approval.test.jstests/lib/override.test.js(new)Implementation steps
Add
hasNonStaleLgtm(comments, headCommitDate)toapproval.js:created_atis afterheadCommitDatehasNonStaleApprovalCreate
override.jswithhasHumanOverride({ github, owner, repo, prNumber, headSha }):Promise.alltrueifhasNonStaleApproval(reviews, headSha)ORhasNonStaleLgtm(comments, headCommitDate)hasHumanOverrideAdd tests to
approval.test.jsforhasNonStaleLgtm:Create
override.test.jsforhasHumanOverride:Acceptance criteria
hasNonStaleLgtmcorrectly identifies non-stale LGTM commentshasNonStaleLgtmis case-insensitive and allows trailing texthasHumanOverridechecks both mechanisms and returns true if either matcheshasHumanOverridefetches reviews, comments, and commit in parallelnode --test tests/lib/approval.test.js tests/lib/override.test.jsDependencies
None — this is the foundation for the other tasks.