parseImagesSection function
Parses the images: section (session image registry, issue #171):
registry (kill switch), maxPerRequest (per-request unique-image
cap), maxBytesPerRequest (per-request image byte budget, issue
#1916) and perModel (per-model cap overrides, issue #1750). Strict —
a bad schema throws ConfigException instead of silently keeping the
defaults. Public so the settings flow's reload-after-write (issue
#395) reuses the same parser the boot runs.
Implementation
ImageRegistryConfig? parseImagesSection(Object? node) {
if (node == null) return null;
if (node is! YamlMap) {
throw ConfigException('images must be a map, got: $node');
}
final (registry, maxPerRequest, maxBytesPerRequest, perModel) =
_parseImagesEntries(node);
if (registry == null &&
maxPerRequest == null &&
maxBytesPerRequest == null &&
perModel == null) {
return null;
}
return ImageRegistryConfig(
enabled: registry ?? true,
maxPerRequest: maxPerRequest ?? defaultMaxImagesPerRequest,
maxBytesPerRequest: maxBytesPerRequest ?? defaultMaxImageBytesPerRequest,
perModel: perModel ?? const {},
);
}