Commit a write-once value on the first attempt and report how many later writes were rejected.

Once Value Coordination Report

once_value_coordination.js
const writes = 3;
let value = -1;
let commits = 0;
let rejected = 0;

function coordinate(count) {
    for (let i = 1; i <= count; i++) {
        if (value === -1) {
            value = i * 10;
            commits += 1;
        } else {
            rejected += 1;
        }
    }
    let outcome = "unset";
    if (commits >= 1 && rejected >= 1) {
        outcome = "guarded";
    } else if (commits >= 1) {
        outcome = "sealed";
    }
    console.log(`writes=${count} value=${value} commits=${commits} rejected=${rejected} status=${outcome}`);
}

coordinate(writes);
write-once value A write-once value accepts the first commit and ignores the rest, keeping the stored value and commit count deterministic.