[WIP] Fix repository drift report issues - #1375
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Comment on non-draft PRs missing canonical issue references - Auto-close superseded draft PRs when the newer PR declares supersession - Auto-close the drift report issue when all findings are resolved - Upgrade pull-requests permission from read to write - Add workflow to README catalog Agent-Logs-Url: https://github.com/groupthinking/EventRelay/sessions/36224c07-1067-42d5-a6f8-0c386ec50ed6 Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Agent Completion Truth Gate: BLOCKEDReasons: Machine-readable verdict{
"verdict": "blocked",
"reasons": [
"verdict_artifact_missing"
],
"details": {}
} |
groupthinking
approved these changes
Aug 13, 2026
🔍 PR Validation |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
groupthinking
marked this pull request as ready for review
August 13, 2026 07:53
groupthinking
approved these changes
Aug 26, 2026
…ssues), so freshly-created clean drift reports are left open, causing the workflow to oscillate — spamming a new "Repository drift report" issue every clean run.
This commit fixes the issue reported at .github/workflows/repository-reconciliation.yml:191
## Bug
In `.github/workflows/repository-reconciliation.yml`, the report issue is located via a search restricted to open issues:
```js
const query = `repo:
```
* When an open report already exists, `report` is defined.
* Otherwise the code **creates** a new issue but discards the return value:
```js
await github.rest.issues.create({ owner, repo, title, body }); // not captured
```
The auto-close block was then guarded by `report`:
```js
if (report && untracked.length === 0 && ...) {
await github.rest.issues.update({ ..., state: "closed" });
}
```
### Failure mode (concrete trigger)
Consider the exact state right after a prior clean run closed the report:
1. Run N (clean): no *open* report exists → search returns nothing → `report` is `undefined` → a **brand new** report issue is created → close block is skipped (`report` falsy) → the fresh issue is left **OPEN**.
2. Run N+1 (still clean): the search now finds that open issue → `report` defined → close block runs → issue closed.
3. Run N+2 (still clean): no open report again → creates a new one, leaves it open...
This oscillation spams a new open "Repository drift report" issue on every other run even when the repository is perfectly clean, defeating the auto-close feature.
## Fix
Capture the created issue's number and use a single `reportNumber` variable in the close condition. In `@actions/github-script`, `github.rest.issues.create()` is an Octokit request that resolves to a response object whose payload is under `.data`, so `created.data.number` is the correct path.
```js
let reportNumber;
if (report) {
reportNumber = report.number;
await github.rest.issues.update({ owner, repo, issue_number: report.number, body });
} else {
const created = await github.rest.issues.create({ owner, repo, title, body });
reportNumber = created.data.number;
}
...
if (reportNumber && untracked.length === 0 && duplicates.length === 0 && staleBranches.length === 0) {
await github.rest.issues.update({ owner, repo, issue_number: reportNumber, state: "closed", state_reason: "completed" });
}
```
Now a freshly-created clean report is closed in the same run, eliminating the oscillation.
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: groupthinking <garveyht@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.