loadProjectCompactionEngine function

CompactionEngine? loadProjectCompactionEngine(
  1. String projectDir
)

Loads the PROJECT-level compaction: section from <projectDir>/.fah/config.yaml — the engine choice travels with the repo (issue #148). Project wins over the user-level compaction: section; the runtime flag wins over both. Null when the file or the section is absent/unreadable; a present-but-invalid section throws ConfigException (strict, like the user config).

Implementation

CompactionEngine? loadProjectCompactionEngine(String projectDir) {
  final file = File('$projectDir/.fah/config.yaml');
  if (!file.existsSync()) return null;
  try {
    final doc = loadYaml(file.readAsStringSync());
    if (doc is! YamlMap) return null;
    return CompactionEngine.fromSection(
      doc['compaction'],
      label: '$projectDir/.fah/config.yaml',
    );
  } on ConfigException {
    rethrow;
  } on Object {
    return null;
  }
}