Fix nested inheritance history and budget accounting

This commit is contained in:
2026-09-30 00:04:02 +00:00
parent b45f7a0410
commit 83c59ea7d3
5 changed files with 187 additions and 9 deletions

View File

@@ -194,3 +194,26 @@ func TestInheritanceExpansionHonorsOutputNodeAndDepthBudgets(t *testing.T) {
})
}
}
func TestInheritanceBudgetIncludesOtherScopesAndSequenceItems(t *testing.T) {
input := parseCompositionDocument(t, "source-1", `extends: null
groups:
- a: {x: one}
b: {extends: a}
- a: {x: two}
b: {extends: a}
unchanged: {x: three}
`)
// Root (1), groups key/list (2), two expanded scopes (18), and
// unchanged key/mapping/key/value (4). Consumed controls cost nothing.
for _, limit := range []int{24, 25, 26} {
result, diagnostics := expandInheritanceTree(input, projectionLimits{nodes: limit, depth: 5})
if limit < 25 {
if result != nil || len(diagnostics) != 1 || diagnostics[0].Code != CodeSchemaProjectionLimit {
t.Fatalf("limit %d accepted or wrong error: %#v", limit, diagnostics)
}
} else if result == nil || len(diagnostics) != 0 {
t.Fatalf("limit %d rejected: %#v", limit, diagnostics)
}
}
}