Repository: godot
Issue: @tool script object added to scene do not always get accurately recorded into .tscn
Labels: topic:editor,topic:plugin,needs testing

### Tested versions

- found in `v4.2.2.stable.official` [15073afe3]

### System information

Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Forward+)

### Issue description

# Context
I'm building a plugin to add configured versions of a complex scene into our level scene.

# Issue
Under some circumstances the added objects are not faithfully saved into the `.tscn` even though the Scene Tree appears correct in editor.

~~The editor tab does not show `(*)` indicated unsaved changes and even if I make changes then force save the it doesn't save the addon-added objects.~~ Per conversation below this is because I'm not using the EditorUndoRedoPlugin. I added that into the workflow and now get the `(*)` badge until save but it doesn't impact the issue of incorrectly persisted scenes.

If you close the scene and reopen or play the scene some configuration is lost.

# Expectation
What I see in the editor will be saved into the tscn and persist into play or through an unload/load cycle.

### Steps to reproduce

I'm condensing my situation so this is at best an approximation of things but that _should_ be sufficient to break things

### Setup
1. Have scene that will be manipulated: `GreyboxObject.tscn`

```gdscript
@tool

class_name GreyboxObject
extends Node2D

@export_category("Functionality")
@export var can_block_movement: bool = true: # it's important that the default here is set to true
	get:
		return can_block_movement
	set(value):
		can_block_movement = value
		# on-update code elided

func _ready() -> void:
	if Engine.is_editor_hint():
		get_parent().set_editable_instance(self, true)

```

2. At some point when setting you're GreyboxObject up in editor decide that you don't want `can_block_movement` to default to true and change `can_block_movement` to false. In `GreyboxObject.tscn` in the editor this now shows up as a non-default value, e.g., it can be reverted

3. Have an addon that creates `GreyboxObject`s  and configures it
```gdscript
	...
	var obj: GreyboxObject = preload(GREYBOX_OBJECT_SCENE).instantiate()
	obj.name = name
	_objects_parent.add_child(obj)
	# the owner of the new greybox object is the level (Object's parent's parent)
	# by convention this should always be the edited scene
	obj.owner = _objects_parent.get_parent()
	obj.can_block_movement = collides
```

### Repro
At this point if I use the addon code to create a new greybox object in `SomeLevel.tscn` that should collide it'll get added to the scene and correctly configured -- basically can_block_movement triggers adding `RigidBody2D` etc so that you can configure colliders -- but it's impossible to get the object to be saved into the `SomeLevel.tscn` with `can_block_movement=true`.

Without that can_block_movement annotation loading the GreyboxObject results in incorrect state relative to what you see in the editor immediately after adding it and having it report as "saved"

### tl;dr
I had three layers of values.

1. Code: true (not the primitive's default)
2. sceneA using the above code: false (resets to primitive's default)
3. sceneB adding sceneA: true

Basically because 1 and 3 match the resulting scene isn't detecting the value as dirty/needing to be saved.

### Minimal reproduction project (MRP)

TBD, I tried to include sufficient information above but will also try to carve out time to add a MRP as well