Quick answer: Godot 4 InputMap modifications persisting across editor restarts? InputMap saves to project.godot on edit; runtime changes leak into the project file - guard via Engine.is_editor_hint.
Tool script's _ready ran InputMap.action_add_event. Closed editor; reopened; project's input map now has the extra events.
Guard with is_editor_hint
if Engine.is_editor_hint():
returnTool scripts default-skip the runtime mutation. Project file stays clean.
Or save and restore
Snapshot InputMap before mutation; restore after. Reversible; no persistence.
Audit @tool scripts
@tool scripts run in editor; mutations leak. Inspect every @tool for accidental persistence.
“Tool scripts share the editor's state. State changes persist unless guarded.”
If your project has many @tool scripts, the leak surface is real. Linter that flags InputMap.* calls in @tool helps catch them.