Skip to content

Scripting: honour optional resource dependencies - #246

Open
Kheartz wants to merge 1 commit into
developfrom
optional_deps
Open

Scripting: honour optional resource dependencies#246
Kheartz wants to merge 1 commit into
developfrom
optional_deps

Conversation

@Kheartz

@Kheartz Kheartz commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

optional was parsed onto ResourceDependency and never read, so a missing dependency always blocked the boot. warnOnMissingDependency was the only escape and is global, so declaring a real-but-optional dependency would make a partial install fail to start.

ValidateDependencies now skips a missing dependency its declarer marked optional, and StartResource stops recursing into one -- that second gate would otherwise fail the dependent with 'Resource not found' right after validation let it through.

A dependency declared twice stays required unless every declaration is optional. ComputeLoadOrder is untouched: it already ignores deps absent from _resources, and changing it would break cycle detection.

Summary by CodeRabbit

  • New Features

    • Resources can now declare dependencies as optional.
    • Installed optional dependencies continue to load in the correct order.
  • Bug Fixes

    • Missing optional dependencies are skipped with a warning instead of preventing resource startup.
    • Required missing dependencies continue to trigger the appropriate warning or error.
    • Duplicate dependency declarations are treated as required when any declaration is non-optional.

optional was parsed onto ResourceDependency and never read, so a
missing dependency always blocked the boot. warnOnMissingDependency
was the only escape and is global, so declaring a real-but-optional
dependency would make a partial install fail to start.

ValidateDependencies now skips a missing dependency its declarer
marked optional, and StartResource stops recursing into one -- that
second gate would otherwise fail the dependent with 'Resource not
found' right after validation let it through.

A dependency declared twice stays required unless every declaration
is optional. ComputeLoadOrder is untouched: it already ignores deps
absent from _resources, and changing it would break cycle detection.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f0dfdb82-4231-45c6-9f0d-b791f971d0cc

📥 Commits

Reviewing files that changed from the base of the PR and between 41f7e49 and de89abb.

📒 Files selected for processing (5)
  • code/framework/src/scripting/resource/resource.cpp
  • code/framework/src/scripting/resource/resource.h
  • code/framework/src/scripting/resource/resource_manager.cpp
  • code/framework/src/scripting/resource/resource_manager.h
  • code/tests/modules/resource_manager_ut.h

Walkthrough

The resource system now identifies optional dependency declarations. ResourceManager skips missing optional dependencies during validation and startup, while required dependencies retain existing failure behavior. Tests cover missing, installed, ordered, and duplicate dependency declarations.

Changes

Optional dependency handling

Layer / File(s) Summary
Dependency optionality contract
code/framework/src/scripting/resource/resource.h, code/framework/src/scripting/resource/resource.cpp, code/framework/src/scripting/resource/resource_manager.h, code/framework/src/scripting/resource/resource_manager.cpp
Resource::IsOptionalDependency checks all matching declarations. ResourceManager exposes locked and unlocked helpers for manifest-based optionality checks.
Dependency validation and startup
code/framework/src/scripting/resource/resource_manager.cpp
Missing optional dependencies produce warnings and are skipped. Missing required dependencies retain the configured warning-or-failure behavior.
Optional dependency regression coverage
code/tests/modules/resource_manager_ut.h
Tests cover missing optional dependencies, missing required dependencies, installed dependency ordering, and duplicate declarations where any required declaration makes the dependency required.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to de89a

The change allows explicitly optional missing resources to be skipped during validation and startup while preserving required dependencies; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant ResourceManager
  participant Resource
  participant DependencyManifest
  ResourceManager->>Resource: Check IsOptionalDependency(depName)
  Resource->>DependencyManifest: Read matching declarations
  DependencyManifest-->>Resource: Optionality declarations
  Resource-->>ResourceManager: Return optionality result
  ResourceManager->>Resource: Validate or start dependency
  Resource-->>ResourceManager: Report missing dependency
  ResourceManager-->>ResourceManager: Skip missing optional dependency
Loading

Suggested reviewers: segfaultd

Poem

I’m a rabbit with a manifest sheet,
Optional hops skip empty streets.
Required roots still guard the gate,
Installed friends load in order and wait.
Duplicate vows keep the stricter rule—
Carrots for tests, and startup stays cool!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: support optional resource dependencies during scripting resource startup.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch optional_deps

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants