fix(transport): carry derived composition-slot templates and rebuild them through the compose flow (ScadaBridge#118)
Bundles did not record that a template was a derived slot template, so the
importer re-created every slot as a BASE template named after the slot.
- Export: TemplateDto gains an additive, null-omitted `Derivation`
(owner path + base path by stable names); a derived template carries only
its own rows (overrides/additions, not inherited placeholders). The closure
pulls in each derived template's base/owner; base orders first.
schemaVersion 1.1 -> 1.2, bundleFormatVersion stays 1.
- Import: base templates go through the ordinary passes; derived templates are
ordered topologically (DerivedTemplatePlan; cycle / duplicate / malformed =
preview Blocker + SemanticValidationException before anything is staged),
their owner and base resolved by path (#100 root rule), and the slot is
created with TemplateService.AddCompositionAsync, synced in place when it
already exists with the same base, or deleted+recomposed when the base
differs; own rows applied as overrides, then ResyncInheritedMembersAsync.
Missing owner/base fails that record (BundleImportDerivedTemplateUnresolved
audit + ImportResult warning), never creating a base in its place.
- Preview/diff: derived rows are keyed by qualified name and compared against
the target slot at the same owner path (own rows + base), so an unchanged
slot is Identical and a same-named base template is never matched.
- Pre-#118 bundles import exactly as before (new fixture
pre-118-derived-plaintext.scadabundle, written by a13aabc7). The field is in
content, pinned by the signed manifest's contentHash.
Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -337,6 +337,31 @@ public sealed class DependencyResolverTests
|
||||
Assert.Equal("Top", result.Templates[2].Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ScadaBridge#118: a derived composition-slot template pulls in its BASE (the importer
|
||||
/// rebuilds the slot by composing that base), and the base is ordered before the slot.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Resolve_pulls_in_the_base_of_a_derived_slot_and_orders_it_first()
|
||||
{
|
||||
var motor = new Template("Motor") { Id = 40 };
|
||||
var slot = new Template("M1") { Id = 41, IsDerived = true, ParentTemplateId = 40, OwnerCompositionId = 7 };
|
||||
var pump = new Template("Pump") { Id = 42 };
|
||||
pump.Compositions.Add(new TemplateComposition("M1") { Id = 7, TemplateId = 42, ComposedTemplateId = 41 });
|
||||
|
||||
StubTemplate(pump);
|
||||
StubTemplate(slot);
|
||||
StubTemplate(motor);
|
||||
StubAllSharedScripts();
|
||||
StubAllExternalSystems();
|
||||
StubAllFolders();
|
||||
|
||||
var result = await Sut().ResolveAsync(SelectTemplates(42), CancellationToken.None);
|
||||
|
||||
Assert.Equal(new[] { "Motor", "M1", "Pump" }, result.Templates.Select(t => t.Name));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Site/instance-scoped expansion.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user