Skip to content

fix(autostart): v0.68 game-agnostic YAML autostarts, wayto overrides, and double-start guard#2310

Merged
mrhoribu merged 5 commits intoelanthia-online:masterfrom
MahtraDR:fix/autostart-double-start-guard
May 5, 2026
Merged

fix(autostart): v0.68 game-agnostic YAML autostarts, wayto overrides, and double-start guard#2310
mrhoribu merged 5 commits intoelanthia-online:masterfrom
MahtraDR:fix/autostart-double-start-guard

Conversation

@MahtraDR
Copy link
Copy Markdown
Contributor

@MahtraDR MahtraDR commented May 4, 2026

Summary

  • Adds next if Script.running?(script_info[:name]) guard to the generic autostart loop to prevent double-starts
  • Extracts YAML-based autostarts, UserVars.autostart_scripts, and Map.apply_wayto_overrides out from behind the if XMLData.game =~ /^DR/ gate -- these features are now game-agnostic
  • Adds a visible warning when a configured autostart script is not found on disk (typos, missing downloads)
  • Simplifies the DR block to only dependency startup and the legacy first-run install path

Problem

Double-start bug: The DR autostart loop (lines 138-163) guarded with Script.running?, but the generic Lich autostart loop (lines 197-227) did not. Scripts in both registries started twice on every login.

DR-only gate: YAML profile autostarts (get_settings.autostarts), UserVars.autostart_scripts, and Map.apply_wayto_overrides were gated behind if XMLData.game =~ /^DR/ despite all underlying infrastructure (get_settings, SetupFiles, Map) being game-agnostic. GS characters could not use YAML profiles for autostarts or wayto overrides.

Silent failures: When a script configured in YAML profiles or UserVars.autostart_scripts did not exist on disk, it was silently skipped with no feedback to the user.

Changes

scripts/autostart.lic

  • New game-agnostic block (before the DR gate):
    • Merges UserVars.autostart_scripts + get_settings.autostarts (deduplicated)
    • Applies Map.apply_wayto_overrides if available
    • Starts each script with guards: skip dependency, skip obsolete, skip running, warn and skip if not found
    • Gated only on respond_to?(:get_settings, true) -- no game check
  • DR block simplified: only starts dependency for runtime helpers + legacy first-run install path
  • Generic Settings/CharSettings loop: added Script.running? guard to prevent double-starts

spec/autostart/autostart_spec.rb

  • 50 specs (up from 0), covering:
    • Generic autostart loop: happy path, running guard, cross-registry dedup, empty/nil/non-array inputs, skipped scripts, DR dependency removal, edge cases
    • YAML autostart loop: YAML autostarts, UserVars autostarts, merge/dedup, wayto overrides, skip guards, game-agnostic behavior (GSIV + DR)
    • GS character with no YAML profiles (nil autostarts, nil UserVars)
    • Adversarial inputs: nil entries, empty strings, duplicates, all running, none exist, both sources nil, dependency in both
    • Missing script warnings: per-script warning, no false warnings for running/dependency/existing scripts, mixed success+failure

Test plan

  • rubocop scripts/autostart.lic spec/autostart/autostart_spec.rb -- 0 offenses
  • rspec spec/autostart/autostart_spec.rb -- 50 examples, 0 failures
  • GS character with no YAML profile: no errors, no warnings, falls through to Settings/CharSettings loop
  • GS character with YAML profile (scripts/profiles/<CharName>-setup.yaml with autostarts: array): starts configured scripts
  • DR character: existing behavior preserved (UserVars + YAML merged, dependency started, legacy path works)
  • Typo in YAML autostart list: visible warning at login

🤖 Generated with Claude Code

The generic autostart loop (Settings['scripts'] / CharSettings['scripts'])
did not check Script.running? before calling Script.start. On DragonRealms,
the DR-specific autostart loop (UserVars + YAML autostarts) already starts
scripts with a running? guard. If a script appeared in both registries, it
would start twice on every login.

Add `next if Script.running?(script_info[:name])` before Script.start in
the generic loop, matching the guard already present in the DR loop.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@MahtraDR has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 32 minutes and 50 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8c2cd96-4e1c-4177-a69f-18465cc34853

📥 Commits

Reviewing files that changed from the base of the PR and between 9b8108d and 3ff1ff6.

📒 Files selected for processing (2)
  • scripts/autostart.lic
  • spec/autostart/autostart_spec.rb
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

- before(:each) -> before (RSpec default)
- Trim verbose comment in dedup test to two lines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MahtraDR MahtraDR changed the title Fix double-start: add Script.running? guard to generic autostart loop fix(autostart): Fix double-start: add Script.running? guard to generic autostart loop May 4, 2026
MahtraDR and others added 2 commits May 4, 2026 19:35
…gnostic

The YAML profile autostart loop, UserVars.autostart_scripts merge, and
Map.apply_wayto_overrides were gated behind `if XMLData.game =~ /^DR/`
but the underlying infrastructure (get_settings, SetupFiles, Map) is
game-agnostic. This extracts them above the DR gate so GS characters
can use YAML profiles and wayto overrides by creating profile files
in scripts/profiles/.

Also adds a visible warning when a configured autostart script is not
found on disk, so typos and missing downloads are surfaced at login
instead of silently skipped.

The DR block is simplified to only dependency startup and the legacy
first-run install path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MahtraDR MahtraDR changed the title fix(autostart): Fix double-start: add Script.running? guard to generic autostart loop fix(autostart): game-agnostic YAML autostarts, wayto overrides, and double-start guard May 4, 2026
Copy link
Copy Markdown
Contributor

@mrhoribu mrhoribu left a comment

Choose a reason for hiding this comment

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

Forgot to bump version of the script in the header, other than that and the one comment I left, looks good.

Comment thread scripts/autostart.lic
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mrhoribu mrhoribu changed the title fix(autostart): game-agnostic YAML autostarts, wayto overrides, and double-start guard fix(autostart): v0.68 game-agnostic YAML autostarts, wayto overrides, and double-start guard May 5, 2026
@mrhoribu mrhoribu merged commit 089810e into elanthia-online:master May 5, 2026
4 checks passed
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