apply method
Prepares and commits changes while serializing the complete operation.
Adapters that do not need the inspection seam can use this operation so concurrent callers never prepare from the same source state. Call prepare and commit separately when downstream policy must inspect the immutable candidate between them.
Implementation
Future<OkfBundleApplication> apply(
String rootPath,
OkfBundleChangeSet changes,
) => OkfBundleLock.write(rootPath, () async {
final preparation = await prepare(rootPath, changes);
return switch (preparation) {
OkfPreparationReady(prepared: final prepared) => OkfBundleApplied(
result: await _commitLocked(prepared),
),
OkfPreparationRefused(validation: final validation) =>
OkfBundleApplicationRefused(validation: validation),
};
});