Skip to content

Add Revive Loop Watchdog - #202

Open
Haluzer wants to merge 9 commits into
Darkbot-Plugins:mainfrom
Haluzer:revive-loop-watchdog
Open

Haluzer wants to merge 9 commits into
Darkbot-Plugins:mainfrom
Haluzer:revive-loop-watchdog

Conversation

@Haluzer

@Haluzer Haluzer commented Sep 2, 2026

Copy link
Copy Markdown

Adds a new feature under dev.shared.halizeur.revive_loop_watchdog.

Detects DarkBot's known stuck-on-revive refresh loop bug (see darkbot-reloaded/DarkBot #391, #455). If the ship stays destroyed continuously past a configurable threshold (default 3 min), it pauses the bot instead of refreshing indefinitely, then automatically resumes once the game finishes loading and the ship is confirmed alive again. Only takes ownership of the pause if the bot was actually running at the time (won't interfere with a manual pause). All state changes are logged.

Compiled and tested against darkbot-impl 0.9.8 / DarkBot dc48506543, matching this repo's pinned versions.

This is a split-out from #200 per dm94's request for one feature per PR. The second feature (Death Rate Profile Switcher) will follow in a separate PR.

Summary by Sourcery

Add a configurable watchdog that prevents DarkBot from endlessly refreshing during a stuck revive loop while preserving manual pauses and automatically recovering once the ship is alive.

New Features:

  • Add an enabled-by-default watchdog that detects prolonged ship destruction, pauses a running bot to prevent stuck revive refresh loops, and resumes it after the game reloads and the ship is alive.
  • Expose a configurable revive-loop threshold between 1 and 30 minutes, defaulting to 3 minutes, with state-change logging.

Enhancements:

  • Correct the Log Overlay package, configuration keys, resource keys, and attribution from “Halizeur” to “Haluzer”.

Documentation:

  • Update the README to reflect the corrected Log Overlay attribution.

@sourcery-ai

sourcery-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduces a revive-loop watchdog plugin that prevents indefinite DarkBot refresh loops by taking ownership of a pause after a configurable destroyed-state timeout and automatically releasing it once the ship is alive, with manifest registration and state-change logging.

File-Level Changes

Change Details Files
Adds a watchdog plugin that detects prolonged ship-destroyed revive loops and coordinates pause/resume behavior.
  • Tracks continuous destroyed state against a configurable timeout, defaulting to three minutes.
  • Pauses only when the bot was running, avoiding interference with manual pauses.
  • Resumes after loading completes and the ship is confirmed alive.
  • Logs watchdog state transitions for observability.
src/main/java/dev/shared/halizeur/revive_loop_watchdog/...
Registers the new plugin in the plugin manifest.
  • Updates plugin metadata and registration entries for the revive loop watchdog.
src/main/resources/plugin.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Haluzer Haluzer changed the title Add Revive Loop WatchdogUpdate plugin.json Add Revive Loop Watchdog Sep 2, 2026
sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Sep 2, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@dm94 dm94 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are no changes to this PR

@Haluzer

Haluzer commented Sep 5, 2026

Copy link
Copy Markdown
Author

There are no changes to this PR

What do you mean with no changes?
Is there need to update something or what that that mean?

@dm94

dm94 commented Sep 6, 2026

Copy link
Copy Markdown
Member

There are no changes to this PR

What do you mean with no changes? Is there need to update something or what that that mean?

image

@sourcery-ai
sourcery-ai Bot dismissed their stale review September 6, 2026 19:14

Sourcery withdrew this approval because the latest commits introduced blocking findings.

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Sep 8, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@sourcery-ai
sourcery-ai Bot dismissed their stale review September 8, 2026 19:22

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@Haluzer
Haluzer requested a review from dm94 September 8, 2026 19:23

@dm94 dm94 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated Review

*This review was generated by an automated code analysis tool. The logic was verified against the actual DarkBot dc48506543 and DarkBotAPI 0.9.8 sources to confirm correctness against the bot's behavior lifecycle.


Logic Verification ✅

The core design is sound and well-researched:

  • Pause trigger is correct: While destroyed, GuiManager.canTickModule() returns false (GuiManager.java:288–309), so onStoppedBehavior() runs instead of onTickBehavior() even though bot.isRunning() remains true. The deadSince timer accumulates as intended.
  • Manual pause preserved: If the user pauses the bot manually (isRunning() == false), pauseForStuckLoop() returns early — no ownership taken, no resume.
  • Timer persists across refresh cycles: RepairManager.tick() keeps destroyed == true while hero.address == 0 during game loading (RepairManager.java:115–121, 180–189), so the threshold counter correctly spans multiple refresh attempts.
  • Constructor injection pattern is valid — DarkBot supports direct singleton injection (HeroAPI, BotAPI, RepairAPI).

Issues Requiring Changes

enabledByDefault = true)
public class ReviveLoopWatchdog implements Behavior, Configurable<ReviveLoopWatchdog.Config> {

private static final Logger LOGGER = Logger.getLogger(ReviveLoopWatchdog.class.getName());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Convention: Logger vs System.out.println()

This repo uses System.out.println() for all plugin logging (see AGENTS.md and all existing plugins: FixPetStuck.java:127, OreSeller.java:183, Autobuy.java:614, etc.). Using java.util.logging.Logger here is functionally fine but breaks the established convention.

Consider replacing with:

System.out.println("Revive Loop Watchdog: ...");

to stay consistent with the rest of the SharedPlugin codebase.


@Feature(name = "Revive Loop Watchdog", description =
"Detects the stuck-on-revive refresh loop bug, pauses the bot, and auto-resumes once it recovers.",
enabledByDefault = true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

enabledByDefault = true deviates from repo convention

No other feature in SharedPlugin has enabledByDefault = true. A behavior that globally pauses the bot on by default is a stronger commitment than anything else in this repo (even higher-risk features like SimpleGalaxyGate and OreSeller default to false).

Since the DarkBot core already refreshes at 90s stuck, consider setting enabledByDefault = false so users opt-in explicitly. This is a policy suggestion rather than a strict requirement — worth a discussion.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants