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

@@ -58,6 +58,28 @@ func BenchmarkInheritanceInspectedLoad(b *testing.B) {
}
}
// Each scope has constant-sized output and evidence. This distinguishes budget
// accounting overhead from legitimate growth in expanded parent payloads.
func BenchmarkInheritanceIndependentScopes(b *testing.B) {
for _, size := range []int{256, 512, 1024} {
b.Run(strconv.Itoa(size), func(b *testing.B) {
input := &document.Node{Kind: document.Mapping}
for index := 0; index < size; index++ {
input.Mapping = append(input.Mapping, document.Entry{
Key: strconv.Itoa(index), Value: inheritanceBenchmarkInput("wide", 1),
})
}
b.ReportAllocs()
b.ResetTimer()
for range b.N {
if _, diagnostics := expandInheritanceTree(input, defaultProjectionLimits()); len(diagnostics) != 0 {
b.Fatal(diagnostics)
}
}
})
}
}
func inheritanceBenchmarkInput(shape string, size int) *document.Node {
value := func(text string) *document.Node { return &document.Node{Kind: document.String, Text: text} }
mapping := func(entries ...document.Entry) *document.Node {