fix false positive 'Ready to merge' with multi-layer CI detection (Issue #1480)#1481
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #1480
…od (Issue #1480) GitHub Actions workflow runs take 30-120s to appear in the API after a push. The previous fix (issue #1442) assumed 0 workflow runs meant "CI definitively NOT triggered", causing false positive "Ready to merge" comments when checked within seconds of a push. Adds a 120-second grace period: if a commit is recent and no workflow runs are registered yet, treat it as a potential race condition instead of concluding CI won't run. Also adds workflow file parsing to check for PR triggers as an additional signal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
21 tests covering: - Exact PR #1479 false positive scenario reproduction - Grace period boundary conditions (0s, 119s, 120s, 300s) - Null commit date edge case - Workflow file PR trigger parsing patterns - Backward compatibility with issue #1466 (action_required) - End-to-end scenarios (fork PRs, paths-ignore, schedule-only) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ready to merge was posted as false positiveCo-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 2792e08.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Gist (2539KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart 1/3Detected uncommitted changes from previous run. Starting new session to review and commit or discard them. Uncommitted files: Auto-restart will stop after changes are committed or discarded, or after 2 more iterations. Please wait until working session will end and give your feedback. |
🔄 Auto-restart 1/3 LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Gist (3068KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
|
I think not all my requirements from the original issue are implemented. We need to ensure all changes are correct, consistent, validated, tested, logged and fully meet all discussed requirements (check issue description and all comments in issue and in pull request). Ensure all CI/CD checks pass. |
|
🤖 AI Work Session Started Starting automated work session at 2026-03-26T10:31:25.028Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
…flow parsing (Issue #1480) Layer 3 defense: check if previous PR commits had CI workflow runs before concluding "CI not triggered" when grace period elapses. If earlier commits had CI and workflow files have PR triggers, wait one more cycle as safety measure against GitHub API delays. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…#1480) When .github/workflows folder doesn't exist or has no workflow files, skip the grace period entirely and immediately conclude "CI not configured at file level". This avoids unnecessary waiting for repos with no workflows. Also adds hasWorkflowFiles field to checkWorkflowsHavePRTriggers return value to distinguish "no workflow files" from "files exist but no PR triggers". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Downloaded PR #1479 details including statusCheckRollup (confirms lint and check-file-line-limits failures at 09:56:11, CI started at 09:55:18), PR comments showing the false positive "Ready to merge" timeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…es, and references (Issue #1480) Enhanced documentation with: - All 7 GitHub API endpoints used for CI/CD status detection - Multi-layer defense architecture (4 layers) - Updated code path diagram showing the full decision tree - GitHub API documentation references - Links to downloaded evidence data files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t history (Issue #1480) Extended test suite from 21 to 31 tests: - Suite 8: Empty workflows folder detection (3 tests) — Layer 1 priority - Suite 9: Previous commit CI history (4 tests) — Layer 3 safety measure - Suite 10: Multi-layer defense interaction (3 tests) — layer priority ordering Updated simulation function to match enhanced getMergeBlockers logic with hasWorkflowFiles field and previousCI parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Gist (3210KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
|
Get latest changes from default branch, and double check everything. We need to ensure all changes are correct, consistent, validated, tested, logged and fully meet all discussed requirements (check issue description and all comments in issue and in pull request). Ensure all CI/CD checks pass. |
|
🤖 AI Work Session Started Starting automated work session at 2026-03-28T19:23:47.907Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Gist (399KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
Summary
Fixes #1480
The auto-merge monitor posted a false positive "Ready to merge" comment on PR #1479 just 19 seconds after the last commit was pushed. CI workflows had not yet been registered in the GitHub Actions API, but the code incorrectly concluded "CI was definitively NOT triggered."
Root Cause
The fix for issue #1442 assumed that if
getWorkflowRunsForSha()returns 0 workflow runs, CI was "definitively NOT triggered." But GitHub Actions workflow runs take 30-120 seconds to appear in the API after a push. The code only protected against check-runs not appearing yet, but not against workflow runs themselves not appearing yet.Timeline of the false positive:
Fix: Multi-Layer CI Detection Defense
Four-layer defense against the race condition, collecting data from all available GitHub API endpoints:
Layer 1 — Empty workflows folder detection: Parse
.github/workflows/*.ymlfiles via repository content API. If no workflow files exist, immediately conclude "no CI configured" — skip all other checks.Layer 2 — Grace period (120 seconds): When
getWorkflowRunsForSha()returns 0 runs but commit is recent (< 120s), treat as potential race condition (ci_pendingblocker). Also reports workflow PR triggers as context.Layer 3 — Previous commit CI history: After grace period, check if earlier commits in the same PR had workflow runs (
checkPreviousPRCommitsHadCI()). If previous commits had CI AND workflow files have PR triggers, wait one more cycle as safety measure against GitHub API delays.Layer 4 — Definitive conclusion: Only conclude "CI not triggered" when grace period elapsed AND no previous commit CI evidence supports expecting CI.
GitHub API Data Sources Used
commits/{sha}/check-runs)commits/{sha}/status)actions/runs?head_sha={sha})actions/workflows)contents/.github/workflows)pulls/{number}/commits)commits/{sha})Changes
src/solve.auto-merge.lib.mjs: Multi-layer defense ingetMergeBlockers()— empty workflows check, grace period, previous commit CI historysrc/github-merge.lib.mjs: AddedcheckPreviousPRCommitsHadCI(), enhancedcheckWorkflowsHavePRTriggers()withhasWorkflowFilesfieldtests/test-false-positive-workflow-run-race-1480.mjs: 31 unit tests (10 test suites) covering all layers, priorities, edge casesdocs/case-studies/issue-1480/README.md: Full case study with timeline, all API data sources, multi-layer architecturedocs/case-studies/issue-1480/data/: Evidence data (PR add retry logic for transient GitHub API errors during PR creation (Issue #1478) #1479 details, comments, CI runs).changeset/fix-false-positive-ready-to-merge-1480.md: Changeset for patch releaseTest plan
node tests/test-false-positive-workflow-run-race-1480.mjs)Ready to mergeas false positive #1363 tests still passnode -c)🤖 Generated with Claude Code