6.6 No preload cycle of any length

Rule: §6.6 in the code standards.

Why

Rule 6.5 covers the shortest cycle, a file the aggregator preloads that preloads the aggregator back. A longer loop breaks the same way: if A preloads B and B reaches A through any chain of preloads, loading either one starts loading the other. Godot 4’s cyclic-reference handling has improved, but the engine’s cyclic-dependency tracker is still open, with reports of “cyclic resource inclusion” errors and of objects losing their script. The addon supports a range of engine versions, so it keeps the preload graph acyclic instead of relying on any one version to tolerate a cycle.

Break a cycle by moving the piece both files need into a leaf that both can preload. Do not swap the preload for a runtime load(): the dependency is still there, it just stops being visible to the parser and to a reviewer reading the file’s const block.

Good

The aggregator preloads versioning/update_check_runner.gd, and that file preloads core/consent.gd. So consent.gd reaches its own dependencies by direct preload and says why, instead of preloading the aggregator and closing a three-file loop (addons/godot_mcp_toolkit/core/consent.gd:11-15):

# Direct preloads, not core/modules.gd: the aggregator preloads the update check
# runner, which preloads this file.
const SetupSteps := preload("res://addons/godot_mcp_toolkit/core/setup_steps.gd")
const SetupStepTracker := preload("res://addons/godot_mcp_toolkit/core/setup_step_tracker.gd")
const UpdateCheck := preload("res://addons/godot_mcp_toolkit/versioning/update_check.gd")

Bad

The same file reaching its dependencies through the aggregator. Nothing in the file looks wrong, but modules.gd → update_check_runner.gd → consent.gd → modules.gd is now a cycle:

const Modules := preload("res://addons/godot_mcp_toolkit/core/modules.gd")
const UpdateCheck = Modules.UpdateCheck

No such cycle is in the tree today; this is the shape to refuse in review.

Source


This site uses Just the Docs, a documentation theme for Jekyll.