Port the Alibaba Cloud families and refuse ambiguous rule inheritance

This commit is contained in:
Thorsten Sommer committed 2026-09-11 20:52:42 +02:00
1 parent 31a1aec69c
commit 5905f074b6
10 files changed
+285 -3

No files matched your search

+29
View File
@@ -110,6 +110,21 @@ public sealed class ModelFamilyTests
Assert.That(refused?.Message, Does.Contain("does not state"));
}
[Test]
public void InheritingFromARuleTextWhichNamesTwoRulesSaysSo()
{
//
// Stating one text twice is ordinary: a variant of a generation is written as the same
// pattern with a condition on top. What cannot be done afterwards is naming that text to
// inherit from, because it no longer names one rule -- and taking whichever came last
// would be a coin toss nobody sees.
//
var family = new FamilyStatingOneTextTwice();
var refused = Assert.Throws<InvalidOperationException>(() => _ = family.Rules);
Assert.That(refused?.Message, Does.Contain("more than once"));
}
[Test]
public void AFamilyWhichAdjustsRatherThanChoosesStatesAModifier()
{
@@ -221,6 +236,20 @@ public sealed class ModelFamilyTests
}
}
private sealed class FamilyStatingOneTextTwice : ModelFamily
{
public override ModelVendor Vendor => ModelVendor.UNKNOWN;
public override ModelSource Source => new("https://example.invalid/twice", new DateOnly(2026, 9, 11), "A family stating one pattern text twice and then naming it to inherit from.");
protected override void Declare(ModelFamilyBuilder builder)
{
builder.Rule("thing").Capabilities(Capability.TEXT_INPUT);
builder.Rule("thing").AlsoContains("special").Capabilities(Capability.FUNCTION_CALLING);
builder.Rule("thing-mini").InheritsFrom("thing");
}
}
private sealed class FamilyWithAModifier : ModelFamily
{
public override ModelVendor Vendor => ModelVendor.UNKNOWN;
@@ -33,6 +33,7 @@ public sealed class PortingDifferenceTests
LLMProviders.ANTHROPIC,
LLMProviders.GOOGLE,
LLMProviders.MISTRAL,
LLMProviders.ALIBABA_CLOUD,
];
[Test]