All checks were successful
joule-code conformance gate / joule-moq-relay, its own energy on a counter (macos) (pull_request) Successful in 32s
joule-moq-web browser client / joule-moq-web · does this change touch it (pull_request) Successful in 5s
standards workspaces build + test / which workspaces this change touches (pull_request) Successful in 6s
wai-app and Create / wai-app · does this change touch it (pull_request) Successful in 6s
WAI examples / WAI examples · does this change touch them (pull_request) Successful in 5s
WAI Studio / does this change touch it (pull_request) Successful in 5s
wai-app and Create / wai-app · tests, clippy, the line language's verifier (linux) (pull_request) Successful in 31s
WAI Studio / the catalogue's actions, the unit tests and the core · linux (pull_request) Successful in 54s
joule-code conformance gate / Build + round-trip C1-C4 vectors (pull_request) Successful in 2m21s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 8m19s
WAI examples / WAI examples · portable · linux (pull_request) Successful in 9m24s
wai-app and Create / wai-app · Create, browser end-to-end (macos) (pull_request) Successful in 8m56s
WAI Studio / Studio in WebKit · linux (pull_request) Successful in 11m5s
WAI examples / WAI examples · the archive, the readiness check, the browser and Apple · macos (pull_request) Successful in 9m35s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (pull_request) Successful in 1m43s
WAI Studio / Studio in Chromium and Firefox · macos (pull_request) Successful in 11m30s
joule-code conformance gate / joule-moq-relay, every target (pull_request) Successful in 3m40s
joule-moq-web browser client / joule-moq-web · browser end-to-end (macos) (pull_request) Successful in 19m26s
joule-code conformance gate / joule-moq-ingest, every target (pull_request) Successful in 6m1s
standards workspaces build + test / joule-code-rs (joule-code/joule-code-rs, joule-code-rs, linux-arm64, true) (pull_request) Successful in 6m30s
WAI examples / WAI examples · android-app · linux-arm64 (pull_request) Successful in 7m27s
The room page took a turn's end from its own schedule only. When a lead's new schedule took effect in the middle of a turn, the page of the performer holding it went on sending up to the new schedule's `from`, past its guard (co-performance §8). The relay judged its last objects on arrival, under the schedule they reached it in, and forwarded them. The room's clock, a hop later, logged them after the `from`, under the new schedule. Where the new schedule refuses and gives that turn to someone else, the room with the clock's log then refuses as `turn_violated`. How often depends on that hop: rarely on a quiet host, and once in #619's browser run, on the shared build host under load (the room e2e's refusing schedule takes effect in the middle of the marking schedule's sixth turn, which the other holder held). Now: - A turn ends at its segment's boundary, or at the `from` of a later schedule, if that comes first (§6.1: "A later schedule replaces an earlier one from its `from` on"). - The guard applies before either. - The turns ahead step from the cut turn to the new schedule's first turn. Before, they jumped to the old turn's end and skipped the new schedule's turns up to it. Tests: - `web/room/co.test.mjs` (new, run by `e2e/run.sh` with the page's other module tests): six cases. Against the old `co.js`, three of them fail: the turn's end, the guard before the `from`, and the turns ahead. - The room e2e names an object it refuses: its arrival, and how far it is from the nearest turn boundary or schedule `from`. If the check fails again, it says which race it was. Co-Authored-By: Claude Opus 5.5 <[email protected]>
81 lines
3.6 KiB
JavaScript
81 lines
3.6 KiB
JavaScript
// The room page's co-performance floor (co.js, `node --test web/room/co.test.mjs`): the turn
|
|
// running at an instant ends at its segment's boundary, or at the `from` of a later schedule
|
|
// that replaces its own (co-performance §6.1), whichever comes first; and a performer's page
|
|
// keeps its guard (§8) before either, so that its last objects reach the relay and the room's
|
|
// clock, a hop later, under the same schedule.
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { Co, GUARD_US } from "./co.js";
|
|
|
|
const A = "aa".repeat(32);
|
|
const B = "bb".repeat(32);
|
|
|
|
/** A page of `principal`, holding `schedules` in the room's order, with no records else. */
|
|
function page(principal, schedules) {
|
|
const co = new Co({ wai: { coPolicy: () => "{}" }, me: () => ({ principal }), policyBytes: null });
|
|
co.schedules = schedules.map((s, i) => ({ digest: `s${i}`, order: i + 1, ...s }));
|
|
return co;
|
|
}
|
|
|
|
// Six turns of 5 s from 0, A then B, under mark; then, from 7 s, two turns of 4 s, A then B,
|
|
// under refuse. B holds the first schedule's second turn, [5 s, 10 s), when the second takes
|
|
// effect.
|
|
const MARK = { mode: "mark", from: 0, segments: [{ start: 0, turn_us: 5_000_000, turns: 6, pairs: 0, holders: [A, B] }] };
|
|
const REFUSE = { mode: "refuse", from: 7_000_000, segments: [{ start: 7_000_000, turn_us: 4_000_000, turns: 2, pairs: 0, holders: [A, B] }] };
|
|
|
|
test("a turn a later schedule replaces ends at that schedule's from", () => {
|
|
const co = page(B, [MARK, REFUSE]);
|
|
const t = co.turnAt(6_900_000);
|
|
assert.equal(t.holder, B);
|
|
assert.equal(t.start, 5_000_000);
|
|
assert.equal(t.end, 7_000_000);
|
|
assert.equal(t.mode, "mark");
|
|
const u = co.turnAt(7_000_000);
|
|
assert.equal(u.holder, A);
|
|
assert.equal(u.mode, "refuse");
|
|
assert.equal(u.start, 7_000_000);
|
|
assert.equal(u.end, 11_000_000);
|
|
});
|
|
|
|
test("a turn no later schedule replaces ends at its segment's boundary", () => {
|
|
const co = page(B, [MARK]);
|
|
assert.equal(co.turnAt(6_900_000).end, 10_000_000);
|
|
assert.equal(co.turnAt(1_000_000).end, 5_000_000);
|
|
});
|
|
|
|
test("the holder of a replaced turn stops its guard before the next schedule's from", () => {
|
|
const co = page(B, [MARK, REFUSE]);
|
|
assert.equal(co.sends(7_000_000 - GUARD_US - 1), true);
|
|
assert.equal(co.sends(7_000_000 - GUARD_US), false);
|
|
assert.equal(co.sends(6_999_999), false);
|
|
// From the from on, B does not hold the floor until its turn of the new schedule, guarded.
|
|
assert.equal(co.sends(9_000_000), false);
|
|
assert.equal(co.sends(11_000_000 + GUARD_US - 1), false);
|
|
assert.equal(co.sends(11_000_000 + GUARD_US), true);
|
|
});
|
|
|
|
test("the holder of the next schedule's first turn starts its guard after the from", () => {
|
|
const co = page(A, [MARK, REFUSE]);
|
|
assert.equal(co.sends(7_000_000 + GUARD_US - 1), false);
|
|
assert.equal(co.sends(7_000_000 + GUARD_US), true);
|
|
});
|
|
|
|
test("the turns ahead step from the replaced turn to the next schedule's", () => {
|
|
const co = page(B, [MARK, REFUSE]);
|
|
const ahead = co.turnsAhead(6_000_000, 3).map((t) => [t.holder, t.start, t.end, t.mode]);
|
|
assert.deepEqual(ahead, [
|
|
[B, 5_000_000, 7_000_000, "mark"],
|
|
[A, 7_000_000, 11_000_000, "refuse"],
|
|
[B, 11_000_000, 15_000_000, "refuse"],
|
|
]);
|
|
});
|
|
|
|
test("a schedule stated later governs even where an earlier-stated one's from is later", () => {
|
|
// §6.1: the schedule in effect is the last stated of those whose from has come. REFUSE was
|
|
// stated first; MARK, stated after it, governs from 0 on and nothing replaces it.
|
|
const co = page(B, [REFUSE, MARK]);
|
|
const t = co.turnAt(6_900_000);
|
|
assert.equal(t.mode, "mark");
|
|
assert.equal(t.end, 10_000_000);
|
|
assert.equal(co.turnAt(8_000_000).mode, "mark");
|
|
});
|