Skip to content

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

Draft
badMade wants to merge 1 commit into
mainfrom
self-heal-automation-9237814936222548749
Draft

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

Conversation

@badMade

@badMade badMade commented May 20, 2026

Copy link
Copy Markdown
Owner

Self-Heal Coding Agent Workflow

Adds an autonomous self-healing pipeline to continuously check project health, perform idempotent auto-repairs, and self-schedule based on repository telemetry.

Included Features

  1. Healthcheck Gate (scripts/healthcheck.mjs): Verifies types, tests, and build.
  2. Idempotent Repair (scripts/self_heal.mjs): Executes npm ci, format updates, test snapshots, and asset regenerations.
  3. Telemetry Self-Scheduling (scripts/compute_schedule.mjs): Modulates schedule based on commit activity.
  4. Triggers (self-heal.yml): Can be run via Cron, CI failure workflow_run, or manual dispatch.
  5. Safeguards: Prevent branch loops, prevent partial fixes, and scan out accidental secret staging.

Validation

Verified manually via node --check, running npm install, and locally running the healthchecks. No new test failures were introduced.


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

Add dynamic scheduled jobs, healthchecks, idempotent repairs, and drift detection to automatically fix configuration and format drift.

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 scripts for health checks, repair automation, and autonomous scheduling based on repository telemetry. The reviewer identified critical issues with invalid dependency versions for ESLint and Prettier that would prevent successful installation. Furthermore, corrections were suggested for incorrect string escaping and regex patterns in the scheduling script, along with an improvement to the self-heal script's exit logic to avoid unnecessary CI failures when the system is already healthy.

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.

high

ESLint version ^10.4.0 is not a stable release (current is 9.x). This will likely cause installation failures in most environments unless a custom registry is being used.

Suggested change
"eslint": "^10.4.0",
"eslint": "^9.17.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.

high

Prettier version ^3.8.3 does not exist in the public npm registry (current stable is 3.5.x). This will cause installation failures.

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

sinceDate.setDate(sinceDate.getDate() - 30);
const dateStr = sinceDate.toISOString();
const result = execSync(`git log --since="${dateStr}" --format="%h"`, { cwd: REPO_ROOT }).toString();
commitCount = result.split('\\n').filter(Boolean).length;

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 split('\\n') call attempts to split the string by a literal backslash followed by the character 'n'. To correctly count lines from the git log output, use split('\n').

Suggested change
commitCount = result.split('\\n').filter(Boolean).length;
commitCount = result.split('\n').filter(Boolean).length;

try {
let workflowContent = await fs.readFile(WORKFLOW_FILE_PATH, 'utf8');
// Using sed-like replacement anchored by # AUTO-UPDATED
const regex = /cron:\\s*['"].*?['"]\\s*# AUTO-UPDATED/g;

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

In a regular expression literal, \\s matches a literal backslash and the character 's'. To match whitespace characters, use \s.

Suggested change
const regex = /cron:\\s*['"].*?['"]\\s*# AUTO-UPDATED/g;
const regex = /cron:\s*['"].*?['"]\s*# AUTO-UPDATED/g;

Comment thread scripts/self_heal.mjs
Comment on lines +104 to +106
// If we exhausted all steps and still aren't healthy + diff
console.log('\\n❌ Self-heal pipeline completed but did not find a working repair.');
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

The script currently exits with code 1 if no repair diff was generated, even if the repository is already healthy. This will cause unnecessary CI failures. The script should exit with code 0 if the system is healthy at the end of the pipeline.

  // If we exhausted all steps, check if the system is healthy
  if (checkHealth()) {
    console.log('\\n✅ Self-heal pipeline completed and system is healthy. Exiting 0.');
    process.exit(0);
  }

  console.log('\\n❌ Self-heal pipeline completed but did not find a working repair.');
  process.exit(1);

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