Skip to content

[Self-Heal] Add self-scheduling auto-repair workflow#43

Draft
badMade wants to merge 1 commit into
mainfrom
self-heal-auto-repair-workflow-12931954551745270157
Draft

[Self-Heal] Add self-scheduling auto-repair workflow#43
badMade wants to merge 1 commit into
mainfrom
self-heal-auto-repair-workflow-12931954551745270157

Conversation

@badMade

@badMade badMade commented May 21, 2026

Copy link
Copy Markdown
Owner

[Self-Heal] Add self-scheduling auto-repair workflow

This PR introduces an automated self-healing CI pipeline configured via GitHub Actions.

The Repair Pipeline (Idempotent)

The scripts/self_heal.mjs script performs the following idempotent steps:

  1. Clean Install: npm ci
  2. Lint/Format: eslint --fix and prettier -w
  3. Test Snapshots: vitest run -u
  4. Clean Rebuild: Wipes out TS cache and rebuilds typestubs cleanly.
  5. Dependency Re-resolve: Refreshes lockfiles cleanly.
  6. Static Build: Re-runs the final build scripts.

Schedule Dynamics

The schedule is dynamically computed based on PR merge velocity. High-velocity periods increase runs (up to 6 hours), while low periods scale down to weekly.

Checklists

  • Contains 3 workflows.
  • Contains 3 script deliverables.
  • Safe yaml.dump prevents configuration drift corruption.
  • Has explicit stale PR cleanup and duplicate checks.

See SELF_HEAL_SETUP.md for full instructions.

(Generated by Claude Code / Jules coding agent)


PR created automatically by Jules for task 12931954551745270157 started by @badMade

Adds automated self-repair pipeline configured to safely resolve common build/drift
issues (like formatting, snapshots). It computes its own schedule from project velocity
via telemetry data, checks for secrets before patching, and creates PRs rather than directly
merging.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an automated self-healing CI pipeline, including documentation, dynamic scheduling based on repository telemetry, and scripts for health checks and automated repairs. Feedback highlights critical issues with non-existent dependency versions for ESLint and Prettier in package.json, an inverted cron expression in the schedule computation script, and the use of a deprecated ESLint flag. Additionally, the reviewer suggested avoiding non-zero exit codes when the system is healthy to prevent false-positive CI failures and unnecessary noise in the action history.

Comment thread package.json
"@types/which": "^3.0.4",
"@vitest/coverage-v8": "3.1.1",
"esbuild": "^0.25.2",
"eslint": "^10.4.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The version ^10.4.0 for eslint does not exist in the public npm registry. The current stable major version is 9. This will cause npm install or npm ci to fail.

Suggested change
"eslint": "^10.4.0",
"eslint": "^9.14.0",

Comment thread package.json
"js-yaml": "^4.1.1",
"multer": "1.4.5-lts.1",
"openai": "^4.91.1",
"prettier": "^3.8.3",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The version ^3.8.3 for prettier does not exist in the public npm registry. The current latest stable version is 3.3.3. This will cause npm install or npm ci to fail.

Suggested change
"prettier": "^3.8.3",
"prettier": "^3.3.3",

}

function computeSchedule(telemetry, activeHourOffset) {
let scheduleStr = `${activeHourOffset} 0 * * *`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The cron expression logic here is inverted. In a standard cron expression, the first field is minutes and the second is hours. Using ${activeHourOffset} 0 results in 'at minute X of hour 0', which contradicts the rationale 'daily at X UTC' and the fallback logic at line 86.

Suggested change
let scheduleStr = `${activeHourOffset} 0 * * *`;
let scheduleStr = `0 ${activeHourOffset} * * *`;

Comment thread scripts/healthcheck.mjs

// Check 2: Linting
// Run eslint if available in package.json devDependencies
allPassed = runCheck('npx eslint . --ext .ts,.js,.mjs', 'ESLint') && allPassed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The --ext flag was removed in ESLint 9.0.0. Since the project is targeting a modern version of ESLint (specified as ^10.4.0 in package.json), this command will fail. Modern ESLint automatically handles file extensions based on the configuration file.

Suggested change
allPassed = runCheck('npx eslint . --ext .ts,.js,.mjs', 'ESLint') && allPassed;
allPassed = runCheck('npx eslint .', 'ESLint') && allPassed;

Comment thread scripts/self_heal.mjs

if (isHealthy && !modified) {
console.log("Pipeline completed. System is healthy and no drift detected. Exiting cleanly with non-zero code to block PR.");
process.exit(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Exiting with a non-zero code (1) when the system is healthy and no drift is detected will cause the GitHub Action run to be marked as 'Failed' (Red X). This is generally considered poor practice for scheduled maintenance tasks as it creates noise in the action history. It is better to exit with 0 and use a conditional check in the workflow (e.g., checking for git changes) to decide whether to proceed with PR creation.

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