The application stages the new schedule in 16 KB chunks under the same name, then commits with the token. The complete body must validate as one Rune document before a single checked root publication gives it the name. With a zero volatility window, the commit returns only after that root is durable.
merfs_status replace_schedule(merfs_scope *pump_app,
const merfs_observation *seen, const chest *schedule,
const chest_source *metadata, merfs_completion *done)
{
merfs_builder *builder = NULL;
merfs_publication_options durable_now;
const uint8_t *bytes = (const uint8_t *)chest_bytes(schedule);
size_t size = chest_size(schedule), sent = 0;
merfs_status status = merfs_builder_begin(pump_app, "schedule", 8u,
MERFS_PUBLISH_REPLACE, seen, metadata, &builder);
if (status != MERFS_OK) return status;
while (sent < size) {
size_t step = size - sent < 16384u ? size - sent : 16384u;
status = merfs_builder_append(builder, bytes + sent, step);
if (status != MERFS_OK) {
merfs_builder_abort(&builder);
return status;
}
sent += step;
}
merfs_publication_options_default(&durable_now);
durable_now.max_delay_ns = 0; /* return only after the new root is durable */
return merfs_builder_commit(&builder, &durable_now, done);
}