Skip to content

fix(autostart.lic): load dependency before DR scripts#2312

Merged
mrhoribu merged 1 commit intoelanthia-online:masterfrom
MahtraDR:fix/autostart-dependency-ordering
May 6, 2026
Merged

fix(autostart.lic): load dependency before DR scripts#2312
mrhoribu merged 1 commit intoelanthia-online:masterfrom
MahtraDR:fix/autostart-dependency-ordering

Conversation

@MahtraDR
Copy link
Copy Markdown
Contributor

@MahtraDR MahtraDR commented May 6, 2026

Summary

  • v0.68 moved the YAML autostart loop above the DR dependency block, causing DR scripts (tome, moonwatch, etc.) to start before dependency.lic loads
  • These scripts call parse_args(), a bridge function defined in dependency.lic:148 that wraps ArgParser.new.parse_args(...) -- it is not provided by lich-5 core
  • Swaps the two blocks to restore the v0.67 ordering: start dependency first, then user scripts

Root cause

v0.67 (correct order):

start_scripts_if_available('dependency')  # 1. dependency loads, defines parse_args()
dr_autostarts.each { start_script(...) }  # 2. scripts can call parse_args()

v0.68 (broken order):

all_autostarts.each { start_script(...) } # 1. scripts call parse_args() -- undefined!
start_scripts_if_available('dependency')  # 2. too late

Errors observed

--- Lich: error: undefined method 'parse_args' for an instance of Lich::Common::Tome
    tome:18:in 'Lich::Common::Tome#initialize'

--- Lich: error: undefined method 'parse_args' for module Lich::Common
    moonwatch:23:in 'Lich::Common#_script'

Test plan

  • Login to DR and verify dependency loads before tome/moonwatch
  • Verify parse_args() errors no longer appear on startup
  • Verify non-DR games still get the game-agnostic autostart loop

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved autostart dependency loading for DragonRealms to ensure dependencies are available early
    • Removed legacy first-run path
  • Refactor

    • Reorganized autostart configuration structure and YAML formatting while preserving existing startup behavior

v0.68 moved the YAML autostart loop before the DR dependency block,
causing tome/moonwatch/etc. to start before dependency.lic defines
the parse_args() bridge function. Swap the blocks to restore the
v0.67 ordering: dependency first, then user scripts.

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

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Walkthrough

The PR updates scripts/autostart.lic to add a DragonRealms-specific prelude that loads the dependency script early in the startup sequence, removes the legacy DR dependency path, and reformats the YAML-based autostart configuration block while preserving its core aggregation logic.

Changes

DragonRealms Dependency Prelude and Autostart Refactor

Layer / File(s) Summary
DR Prelude Logic
scripts/autostart.lic (lines 141–146)
New DR-specific prelude loads dependency before other scripts and attempts to start it via start_scripts_if_available('dependency'), ensuring the parse_args bridge is ready early.
Legacy Path Removal
scripts/autostart.lic (lines 176–178)
Legacy DR-first-run dependency installation path is removed and replaced by the new DR prelude, eliminating the redundant fallback flow.
YAML Block Reorganization
scripts/autostart.lic (lines 179–202)
Autostart configuration block is reformatted with adjusted spacing and line breaks; aggregation logic from UserVars and get_settings, override application, and script execution flow remain functionally unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • elanthia-online/scripts#2277: Both PRs coordinate DR autostart handling—this PR adds the early dependency prelude while the related PR switches DR autostart reads to UserVars now that dependency is run-once.
  • elanthia-online/scripts#2288: Both PRs add DR-specific autostart paths using start_scripts_if_available('dependency') with fallback to legacy dependency handling.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title directly addresses the main change: restoring correct load ordering so dependency.lic loads before DR scripts that depend on it.

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

✨ 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.

@MahtraDR MahtraDR changed the title Fix autostart ordering: load dependency before DR scripts Fix(autostart): load dependency before DR scripts May 6, 2026
@MahtraDR MahtraDR changed the title Fix(autostart): load dependency before DR scripts fix(autostart.lic): load dependency before DR scripts May 6, 2026
@mrhoribu mrhoribu merged commit 9a8a2f9 into elanthia-online:master May 6, 2026
4 checks passed
mrhoribu pushed a commit that referenced this pull request May 6, 2026
…ipts (#2315)

## Summary

- [#2312](#2312) fixed
the ordering (dependency before autostart scripts) but
`start_scripts_if_available` is async -- it only waits 0.25s before
moving on
- `dependency.lic` takes longer than that, so `parse_args()` is still
undefined when autostart scripts begin
- Switches to `Script.run('dependency')`, which blocks until the script
fully exits the `@@running` list

## Root cause

`start_scripts_if_available` (lich-5 `global_defs.rb:42-57`) calls
`start_script` then polls for up to 0.25s:

```ruby
start_script(script_name)
pause 0.05
snapshot = Time.now
until !Script.running?(script_name) || Time.now - snapshot > 0.25
  pause 0.05
end
```

`Script.run` (`script.rb:365-369`) blocks indefinitely until the script
finishes:

```ruby
def Script.run(*args)
  if (s = @@elevated_script_start.call(args))
    sleep 0.1 while @@running.include?(s)
  end
end
```

## Test plan

- [ ] Login to DR and verify dependency fully loads before
tome/moonwatch start
- [ ] Verify `parse_args()` errors no longer appear on startup
- [ ] Verify non-DR games are unaffected (they skip the DR block
entirely)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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