Why
Testing the autofix system on PR stranske/Manager-Database#84 revealed two issues preventing the system from fully resolving CI failures:
- Bug: Safe sweep pattern matching fails when repo has Python at root
- Gap: Non-agent PRs never get Codex fallback, even when quick autofix partially succeeds
Scope
Bug #1: Safe Sweep Pattern Matching
Location: .github/workflows/reusable-18-autofix.yml - "Summarise safe sweep results" step
Problem: When a repo has Python files at the root directory:
find . -name "*.py" returns . as a directory
clean_dir="${dir#./}" transforms . → . (not empty)
- Pattern becomes
./** which does NOT match paths like tests/file.py
- Git diff outputs paths without leading
./, so ./** never matches
Evidence:
[autofix] Target directories: .
Found 22 errors (16 fixed, 6 remaining).
[autofix] ERROR: safe sweep produced changes outside allowed globs:
- tests/test_autofix_validation.py
Fix:
clean_dir="${dir#./}"
if [[ "$clean_dir" == "." || -z "$clean_dir" ]]; then
allowed_patterns+=("**") # Match all files at root
elif [[ -n "$clean_dir" ]]; then
allowed_patterns+=("${clean_dir}/**")
fi
Gap #2: Auto-Dispatch Codex for Partial Fixes
Location: .github/workflows/agents-autofix-loop.yml - "Evaluate workflow_run" step
Current behavior:
const autofixEnabled = configMatch ? configMatch[1] === 'true' : hasAgentLabel;
if (!autofixEnabled) {
return stop('autofix disabled for this pull request');
}
Problem: Human-created PRs that:
- Get quick autofix (lint/black) ✅
- Have remaining unfixable issues (mypy, test failures) ❌
- Never get Codex dispatch because no
agent:codex label
Proposed Design (Option C): Auto-dispatch Codex when quick autofix partially succeeded:
- Quick autofix runs on all PRs
- If autofix fixed some issues but Gate still fails...
- Automatically enable Codex dispatch for that PR
- Add
autofix:escalated label to track
Implementation approach:
- Check autofix workflow outputs for
changed=true AND remaining > 0
- OR check if Gate failed after autofix commit was pushed
- Enable Codex dispatch with limited attempts (e.g., 1-2 vs 3 for agent PRs)
Non-Goals
- Changing behavior for PRs with explicit
autofix: false in body
- Unlimited Codex retries on non-agent PRs
- Dispatching Codex for PRs where quick autofix made no changes
Tasks
Acceptance Criteria
Test PR
stranske/Manager-Database#84 - Contains intentional lint, mypy, and test failures for validation
Why
Testing the autofix system on PR stranske/Manager-Database#84 revealed two issues preventing the system from fully resolving CI failures:
Scope
Bug #1: Safe Sweep Pattern Matching
Location:
.github/workflows/reusable-18-autofix.yml- "Summarise safe sweep results" stepProblem: When a repo has Python files at the root directory:
find . -name "*.py"returns.as a directoryclean_dir="${dir#./}"transforms.→.(not empty)./**which does NOT match paths liketests/file.py./, so./**never matchesEvidence:
Fix:
Gap #2: Auto-Dispatch Codex for Partial Fixes
Location:
.github/workflows/agents-autofix-loop.yml- "Evaluate workflow_run" stepCurrent behavior:
Problem: Human-created PRs that:
agent:codexlabelProposed Design (Option C): Auto-dispatch Codex when quick autofix partially succeeded:
autofix:escalatedlabel to trackImplementation approach:
changed=trueANDremaining > 0Non-Goals
autofix: falsein bodyTasks
./**vs**pattern matchingautofix:escalatedlabel definitionAcceptance Criteria
autofix:escalatedlabel applied when Codex auto-dispatchedautofix: falsestill opt out completelyTest PR
stranske/Manager-Database#84 - Contains intentional lint, mypy, and test failures for validation