validate method
void
validate()
Config is wrong at startup or not at all, so this throws rather than asserts: a stripped assert would leave compaction quietly unable to converge in release builds.
Implementation
void validate() {
void require(bool ok, String message) {
if (!ok) throw ArgumentError.value(this, 'compactionSetup', message);
}
require(recentCharsToKeep > 0, 'recentCharsToKeep must be positive');
require(minCharsToCompact > 0, 'minCharsToCompact must be positive');
require(
compactionTargetChars > 0,
'compactionTargetChars must be positive',
);
// Otherwise a summary can be large enough to trigger its own compaction,
// and the chat summarises its own summary forever.
require(
compactionTargetChars < minCharsToCompact,
'compactionTargetChars must be below minCharsToCompact, or compaction '
'never converges',
);
// Otherwise every compaction would drop content instead of summarising it.
require(
maxCharsToSummarize >= minCharsToCompact,
'maxCharsToSummarize must be at least minCharsToCompact',
);
}