Skip to content

fix: stop auto-fix retries for setup blockers#47

Merged
khaliqgant merged 1 commit intomainfrom
codex/stop-autofix-env-var-retries
May 5, 2026
Merged

fix: stop auto-fix retries for setup blockers#47
khaliqgant merged 1 commit intomainfrom
codex/stop-autofix-env-var-retries

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

  • Stops the auto-fix loop immediately for external setup blockers: MISSING_ENV_VAR, CREDENTIALS_REJECTED, and WORKDIR_DIRTY.
  • Preserves escalation details and recovery steps instead of spending every retry on persona workflow repair.
  • Keeps persona repair coverage for actual workflow/artifact blockers.

Why

A Ricky local run exhausted 7/7 auto-fix attempts on MISSING_ENV_VAR at runtime-launch. Missing env/config is not safely patchable by rewriting the generated workflow, so Ricky should surface the setup blocker directly.

Verification

  • npm test -- src/local/auto-fix-loop.test.ts
  • npm run typecheck

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

The PR adds external setup blocker detection to the auto-fix loop. When MISSING_ENV_VAR, CREDENTIALS_REJECTED, or WORKDIR_DIRTY blockers are encountered, the system immediately escalates instead of attempting repair, with appropriate error messaging and next actions for the user.

Changes

External Setup Blocker Escalation

Layer / File(s) Summary
Blocker Detection
src/local/auto-fix-loop.ts
New isExternalSetupBlocker() helper identifies MISSING_ENV_VAR, CREDENTIALS_REJECTED, and WORKDIR_DIRTY as blockers that cannot be auto-repaired.
Escalation Logic
src/local/auto-fix-loop.ts
runWithAutoFix checks for external setup blockers early; when matched, sets fix_error, runs failure classification and debugger generation, populates nextActions with debugger output, attaches escalation metadata, and returns immediately without attempting repair.
Test Coverage
src/local/auto-fix-loop.test.ts
Updated persona repair test to use INVALID_ARTIFACT blocker (confirming persona repair path works with non-external blockers). Added new test verifying MISSING_ENV_VAR blockers: single attempt, no workflowRepairer invocation, ok: false with blocker status, and appropriate nextActions for user setup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A blocker arrives—no repair in sight!
Credentials and paths now escalate right.
External blockers know when to bail,
With helpful next steps to light up the trail.
No silent struggles, just clear guidance's glow! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: stop auto-fix retries for setup blockers' clearly and concisely summarizes the main change: stopping auto-fix loop retries for external setup blockers.
Description check ✅ Passed The description is directly related to the changeset, explaining why setup blockers should stop auto-fix retries and how it preserves escalation details while maintaining persona repair for workflow blockers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/stop-autofix-env-var-retries

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/local/auto-fix-loop.test.ts (1)

378-410: ⚡ Quick win

Consider table-driving this test across all external setup blocker codes.

Right now only MISSING_ENV_VAR is asserted. Adding CREDENTIALS_REJECTED and WORKDIR_DIRTY here would better lock down the new gate behavior.

Example refactor
-  it('does not auto-repair missing environment prerequisites', async () => {
-    const runSingleAttempt = vi
-      .fn()
-      .mockResolvedValue(blockerResponse('MISSING_ENV_VAR', 'run-1', 'runtime-launch'));
+  it.each(['MISSING_ENV_VAR', 'CREDENTIALS_REJECTED', 'WORKDIR_DIRTY'] as const)(
+    'does not auto-repair external setup blocker %s',
+    async (code) => {
+      const runSingleAttempt = vi
+        .fn()
+        .mockResolvedValue(blockerResponse(code, 'run-1', 'runtime-launch'));
     const workflowRepairer = vi.fn().mockResolvedValue(workflowRepair('should not run'));
 
     const result = await runWithAutoFix(baseRequest, {
       maxAttempts: 7,
       runSingleAttempt,
@@
     expect(runSingleAttempt).toHaveBeenCalledTimes(1);
     expect(workflowRepairer).not.toHaveBeenCalled();
@@
       attempts: [
         expect.objectContaining({
           attempt: 1,
-          blocker_code: 'MISSING_ENV_VAR',
+          blocker_code: code,
           fix_error: 'external setup blocker; no safe automatic workflow repair',
         }),
       ],
     });
     expect(result.auto_fix?.escalation?.summary).toContain('environment or credentials prerequisite');
     expect(result.nextActions.join('\n')).toContain('Set TEST_TOKEN before retrying.');
-  });
+    },
+  );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/local/auto-fix-loop.test.ts` around lines 378 - 410, The test currently
only asserts behavior for the 'MISSING_ENV_VAR' blocker; change it to
table-drive the same expectations for each external setup blocker code (e.g.,
'MISSING_ENV_VAR', 'CREDENTIALS_REJECTED', 'WORKDIR_DIRTY') by iterating over an
array of codes and running the same setup/assertions per code using the existing
runWithAutoFix, runSingleAttempt, fakeClassification and workflowRepairer mocks;
ensure you assert runSingleAttempt called once, workflowRepairer not called,
result.ok false, result.auto_fix.attempts[0].blocker_code equals the current
code and fix_error equals 'external setup blocker; no safe automatic workflow
repair', plus the escalation summary and nextActions contain the same
prerequisite message — keep test name descriptive or use test.each/forEach to
create separate it() cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/local/auto-fix-loop.ts`:
- Line 145: Update the escalation reason string that currently reads "The
blocker is an environment or credentials prerequisite outside Ricky's safe
auto-fix scope." to explicitly include WORKDIR_DIRTY so users aren’t misled;
locate the mapping or constant where WORKDIR_DIRTY is assigned this reason
(symbol WORKDIR_DIRTY and the surrounding object/variable in auto-fix-loop.ts)
and change the message to mention "environment/credentials prerequisites or a
dirty working directory (WORKDIR_DIRTY) outside Ricky's safe auto-fix scope,"
keeping proper escaping for the apostrophe.

---

Nitpick comments:
In `@src/local/auto-fix-loop.test.ts`:
- Around line 378-410: The test currently only asserts behavior for the
'MISSING_ENV_VAR' blocker; change it to table-drive the same expectations for
each external setup blocker code (e.g., 'MISSING_ENV_VAR',
'CREDENTIALS_REJECTED', 'WORKDIR_DIRTY') by iterating over an array of codes and
running the same setup/assertions per code using the existing runWithAutoFix,
runSingleAttempt, fakeClassification and workflowRepairer mocks; ensure you
assert runSingleAttempt called once, workflowRepairer not called, result.ok
false, result.auto_fix.attempts[0].blocker_code equals the current code and
fix_error equals 'external setup blocker; no safe automatic workflow repair',
plus the escalation summary and nextActions contain the same prerequisite
message — keep test name descriptive or use test.each/forEach to create separate
it() cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aa99b475-fc7a-4044-88d0-18d818059268

📥 Commits

Reviewing files that changed from the base of the PR and between 67cb814 and 6e8c062.

📒 Files selected for processing (2)
  • src/local/auto-fix-loop.test.ts
  • src/local/auto-fix-loop.ts

request: currentRequest,
response,
debuggerResult,
reason: 'The blocker is an environment or credentials prerequisite outside Ricky\'s safe auto-fix scope.',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify the escalation reason text for WORKDIR_DIRTY.

The current reason mentions only environment/credentials prerequisites, but WORKDIR_DIRTY is also classified here and can make the message misleading for users.

Suggested wording update
-        reason: 'The blocker is an environment or credentials prerequisite outside Ricky\'s safe auto-fix scope.',
+        reason: 'The blocker is an external setup prerequisite (environment, credentials, or dirty workdir) outside Ricky\'s safe auto-fix scope.',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
reason: 'The blocker is an environment or credentials prerequisite outside Ricky\'s safe auto-fix scope.',
reason: 'The blocker is an external setup prerequisite (environment, credentials, or dirty workdir) outside Ricky\'s safe auto-fix scope.',
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/local/auto-fix-loop.ts` at line 145, Update the escalation reason string
that currently reads "The blocker is an environment or credentials prerequisite
outside Ricky's safe auto-fix scope." to explicitly include WORKDIR_DIRTY so
users aren’t misled; locate the mapping or constant where WORKDIR_DIRTY is
assigned this reason (symbol WORKDIR_DIRTY and the surrounding object/variable
in auto-fix-loop.ts) and change the message to mention "environment/credentials
prerequisites or a dirty working directory (WORKDIR_DIRTY) outside Ricky's safe
auto-fix scope," keeping proper escaping for the apostrophe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant