From 810bd684f47c77f19b50806dd947580cf001e7f3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 25 Sep 2026 18:42:41 -0700 Subject: [PATCH 1/2] chore(quest): claim interop-flakes Co-Authored-By: GPT-6 From 11dbcb677105061bc49b5df4ea89c76bd47ad04d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 25 Sep 2026 19:05:52 -0700 Subject: [PATCH 2/2] fix(test): isolate concurrent interop harness runs Co-Authored-By: GPT-6 --- .github/workflows/interop.yml | 18 ++++++++- quest/m1/interop-flakes.md | 10 +++++ test/README.md | 12 +++--- test/interop/README.md | 2 +- test/interop/clients/js/driver.ts | 13 ++++--- test/interop/clients/js/harness.test.ts | 24 ++++++++++++ test/interop/clients/js/harness.ts | 6 +++ test/interop/clients/js/media.ts | 5 +-- test/interop/clients/js/tsconfig.json | 10 ++++- test/interop/interop.sh | 2 +- test/justfile | 5 +++ test/lib/harness.sh | 18 +++++---- test/lib/harness.test.sh | 52 +++++++++++++++++++++++++ 13 files changed, 152 insertions(+), 25 deletions(-) create mode 100644 test/interop/clients/js/harness.test.ts create mode 100755 test/lib/harness.test.sh diff --git a/.github/workflows/interop.yml b/.github/workflows/interop.yml index 7116bd39c19..b3d44f73415 100644 --- a/.github/workflows/interop.yml +++ b/.github/workflows/interop.yml @@ -82,8 +82,22 @@ jobs: run: nix develop --command bash -c "bun install --frozen-lockfile && bunx playwright install --with-deps chromium" shell: bash -leo pipefail {0} - - name: Interop (full matrix) - run: nix develop --command just test interop --all + - name: Harness regressions + run: nix develop --command just test harness + shell: bash -leo pipefail {0} + + - name: Interop (concurrent full matrices) + run: | + mkdir -p "$MOQ_TEST_RUNS" + nix develop --command just test interop --all >"$MOQ_TEST_RUNS/parallel-a.log" 2>&1 & + first=$! + nix develop --command just test interop --all >"$MOQ_TEST_RUNS/parallel-b.log" 2>&1 & + second=$! + status=0 + wait "$first" || status=1 + wait "$second" || status=1 + cat "$MOQ_TEST_RUNS/parallel-a.log" "$MOQ_TEST_RUNS/parallel-b.log" + exit "$status" shell: bash -leo pipefail {0} env: # The run writes its directory here, so a failed one is uploaded below diff --git a/quest/m1/interop-flakes.md b/quest/m1/interop-flakes.md index 679c0344cff..de2ba237c29 100644 --- a/quest/m1/interop-flakes.md +++ b/quest/m1/interop-flakes.md @@ -16,6 +16,16 @@ pause click is sometimes blocked by the canvas (`js -> js`). keyboard path, or waiting for the element to be actionable), not a retry. - Prove it by running two `--all` harnesses at once, several times. +Current implementation fixes the two known failures and isolates Go staging in +per-run output. Focused regressions pass. Concurrent full matrices with pinned +Nix Cargo and a private target directory passed 32/32 and 31/32 cells; the +remaining `python -> js` failure stalled while processing 2.5 ms Opus groups. +The Pause button remained in the trace, but page snapshots stopped progressing +for tens of seconds. Diagnose that browser stall before declaring the parallel +proof complete. The external mbx cache also omits `target/include/moq.h` when +replaying libmoq's build-script side effects; uncached validation isolates that +separate tooling limitation. + Public API: none. Wire: none. ## Related diff --git a/test/README.md b/test/README.md index 5c4f994c433..b295bf5f466 100644 --- a/test/README.md +++ b/test/README.md @@ -21,7 +21,7 @@ Every run owns three things and touches nothing else. holding every log, generated config, and capture. `MOQ_TEST_RUNS` moves the root. **Reserved ports.** A port is claimed by creating a directory under -`$TMPDIR/moq-test-ports-` (`MOQ_TEST_PORTS`), held for the whole run, and +`/tmp/moq-test-ports-` (`MOQ_TEST_PORTS`), held for the whole run, and released on the way out. That reservation is the point: probing for a free port and then releasing it is a race, and two runs that probe at the same moment pick the same number. The walk starts at `MOQ_TEST_PORT_BASE` (4500). A reservation whose owner @@ -30,10 +30,12 @@ Replacement is serialized by `flock` on Linux or `lockf` on macOS, and the reservation records the owner's process start so a reused PID is not mistaken for the original run. -Both roots carry the user id because `TMPDIR` is usually unset on Linux: a fixed -name in a world-writable `/tmp` belongs to whoever ran first, and everyone else -would fail to create anything under it. Two worktrees still share, since they run -as the same user, which is what makes the reservations mean anything. +The reservation root ignores `TMPDIR`: Nix shells have private temporary +directories but share the host's ports. The user id avoids ownership conflicts in +world-writable `/tmp`. `MOQ_TEST_PORTS` must name the same root for all of a user's runs sharing the +network. A reservation root must belong to the +current user and cannot be a symlink; new roots are private. Runs by different +users still need disjoint ports. The reservation settles contention between harness runs, not with the rest of the machine, so each harness still refuses a port something unrelated is already diff --git a/test/interop/README.md b/test/interop/README.md index e41a0d7179d..29dbe453887 100644 --- a/test/interop/README.md +++ b/test/interop/README.md @@ -180,6 +180,6 @@ clients/ ## CI -`.github/workflows/interop.yml` runs the full matrix nightly (and on demand, and on +`.github/workflows/interop.yml` runs two full matrices concurrently in separate Nix shells nightly (and on demand, and on PRs that touch `test/interop/`). A red cell means a real interop break in the current tree. diff --git a/test/interop/clients/js/driver.ts b/test/interop/clients/js/driver.ts index efa0c1ecd47..b04fceca212 100644 --- a/test/interop/clients/js/driver.ts +++ b/test/interop/clients/js/driver.ts @@ -22,6 +22,7 @@ import { type PlayerState, POLL_INTERVAL_MS, pageUrl, + pause, readPlayerState, SELECTORS, serve, @@ -88,7 +89,12 @@ const browser = await launch([ let code = 1; try { - const [page, errors] = await open(browser, pageUrl(server.origin, role, { url, broadcast }), role, role === "subscribe"); + const [page, errors] = await open( + browser, + pageUrl(server.origin, role, { url, broadcast }), + role, + role === "subscribe", + ); if (role === "subscribe") await waitForWatch(page); if (role === "publish") { @@ -129,10 +135,7 @@ try { }); } - // The chrome auto-hides while playing. Pointer activity reveals the real - // control, then the click must flow through the public player API. - await page.dispatchEvent(SELECTORS.ui, "pointermove"); - await page.locator(SELECTORS.ui).locator(SELECTORS.pauseControl).click(); + await pause(page); await waitForState(page, errors, { deadline: interactionDeadline, description: "paused player UI", diff --git a/test/interop/clients/js/harness.test.ts b/test/interop/clients/js/harness.test.ts new file mode 100644 index 00000000000..ec07edd3780 --- /dev/null +++ b/test/interop/clients/js/harness.test.ts @@ -0,0 +1,24 @@ +import { expect, test } from "bun:test"; +import { launch, pause } from "./harness"; + +test("pause activates its button when a canvas intercepts pointer input", async () => { + const browser = await launch(); + try { + const page = await browser.newPage(); + await page.setContent(` + + + `); + await pause(page); + expect(await page.locator("body").getAttribute("data-paused")).toBe("true"); + } finally { + await browser.close(); + } +}); diff --git a/test/interop/clients/js/harness.ts b/test/interop/clients/js/harness.ts index 019d4a003f5..4a7dd6ed161 100644 --- a/test/interop/clients/js/harness.ts +++ b/test/interop/clients/js/harness.ts @@ -63,6 +63,12 @@ export const SELECTORS = { fixture: "#fixture", } as const; +/** Activate the player's pause button without depending on pointer hit testing. */ +export async function pause(page: Page): Promise { + // Enter focuses and activates the real button even when the chrome auto-hides. + await page.locator(SELECTORS.ui).locator(SELECTORS.pauseControl).press("Enter"); +} + /** How often a wait re-reads the page. */ export const POLL_INTERVAL_MS = 100; diff --git a/test/interop/clients/js/media.ts b/test/interop/clients/js/media.ts index 6ac033f31b2..787b00665e3 100644 --- a/test/interop/clients/js/media.ts +++ b/test/interop/clients/js/media.ts @@ -30,6 +30,7 @@ import { type PlayerState, POLL_INTERVAL_MS, pageUrl, + pause, readFixtureState, readPlayerState, SELECTORS, @@ -526,9 +527,7 @@ try { // ── pause and resume ───────────────────────────────────────────────────── if (wants("pause")) { console.error("=== pause and resume ==="); - // The chrome auto-hides while playing; pointer activity reveals the real control. - await player.dispatchEvent(SELECTORS.ui, "pointermove"); - await player.locator(SELECTORS.ui).locator(SELECTORS.pauseControl).click(); + await pause(player); await waitForState(player, playerErrors, { deadline: Date.now() + SETTLE_MS, assertion: "pause takes effect", diff --git a/test/interop/clients/js/tsconfig.json b/test/interop/clients/js/tsconfig.json index a02418e9625..144af0bbba9 100644 --- a/test/interop/clients/js/tsconfig.json +++ b/test/interop/clients/js/tsconfig.json @@ -3,5 +3,13 @@ "compilerOptions": { "types": ["bun", "vite/client"] }, - "include": ["driver.ts", "harness.ts", "media.ts", "src", "vite.config.ts", "../../../../js/common/worklet.d.ts"] + "include": [ + "driver.ts", + "harness.ts", + "harness.test.ts", + "media.ts", + "src", + "vite.config.ts", + "../../../../js/common/worklet.d.ts" + ] } diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 713d4e6865b..f90f4b25b9b 100755 --- a/test/interop/interop.sh +++ b/test/interop/interop.sh @@ -256,7 +256,7 @@ prepare_go() { } echo "building go client (workspace moq-go via uniffi-bindgen-go)..." local staged ffi_pkg wrapper_pkg src="$HARNESS_RUN/go-client" - if ! staged=$(bash "$WORKSPACE/go/scripts/stage.sh" 2>"$HARNESS_RUN/go-stage.log"); then + if ! staged=$(bash "$WORKSPACE/go/scripts/stage.sh" --output "$HARNESS_RUN/go-stage" 2>"$HARNESS_RUN/go-stage.log"); then mark_broken go "go/scripts/stage.sh failed" sed 's/^/ /' "$HARNESS_RUN/go-stage.log" >&2 || true return diff --git a/test/justfile b/test/justfile index 91ba59ba80d..cc95901f76f 100644 --- a/test/justfile +++ b/test/justfile @@ -22,6 +22,11 @@ set working-directory := '.' default: @just --justfile {{ justfile() }} --list test +# Port isolation across private temp roots and keyboard activation under a canvas. +harness: + ./lib/harness.test.sh + bun test interop/clients/js/harness.test.ts + # Cross-language media interop test, built from this checkout. Stands up a # relay and runs the publisher x subscriber matrix. Default: rust only (fast # sanity check). `interop --all` runs the full matrix: rust + python + go + diff --git a/test/lib/harness.sh b/test/lib/harness.sh index 7180d384c5d..7cd50c85e9e 100644 --- a/test/lib/harness.sh +++ b/test/lib/harness.sh @@ -105,13 +105,11 @@ harness_begin() { # Where port reservations live. Shared across worktrees on purpose: the point is # that a run in one worktree cannot hand out a port another already took. # -# The default is suffixed with the user id, like the run root. On Linux TMPDIR is -# usually unset, so both would land in a world-writable /tmp under a fixed name -# owned by whoever ran first: a second user's `mkdir` would then fail for every -# port and the walk would report the whole range taken with nothing reserved. Two -# worktrees still share, because they run as the same user. +# Nix shells give TMPDIR a private directory, but their sockets still share the +# host network. Keep claims in /tmp regardless of each shell's scratch root. +# The user id avoids ownership conflicts with another user's harnesses. harness_port_root() { - local root="${MOQ_TEST_PORTS:-${TMPDIR:-/tmp}}" + local root="${MOQ_TEST_PORTS:-/tmp}" root="${root%/}" [[ -n "${MOQ_TEST_PORTS:-}" ]] || root="$root/moq-test-ports-$(id -u)" echo "$root" @@ -146,7 +144,13 @@ harness_port() { local label="$1" wanted="${2:-}" local root port last status root=$(harness_port_root) - mkdir -p "$root" + # Only the reservation root needs private permissions, not its parents. + # shellcheck disable=SC2174 + mkdir -m 700 -p "$root" + if [[ -L "$root" || ! -O "$root" ]]; then + echo "error: port reservation root must be owned by this user and not a symlink: $root" >&2 + return 2 + fi if [[ -n "$wanted" ]]; then harness_valid_port "$wanted" || { diff --git a/test/lib/harness.test.sh b/test/lib/harness.test.sh new file mode 100755 index 00000000000..e1bb411478d --- /dev/null +++ b/test/lib/harness.test.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Independent shells must reserve different ports even with private temp roots. +set -euo pipefail + +lib=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +scratch=$(mktemp -d) +owner="" +trap '[[ -z "$owner" ]] || { kill "$owner" 2>/dev/null || true; wait "$owner" 2>/dev/null || true; }; rm -rf "$scratch"' EXIT +mkdir "$scratch/one" "$scratch/two" +mkfifo "$scratch/ready" "$scratch/release" +export MOQ_TEST_RUNS="$scratch/runs" +unset MOQ_TEST_PORTS + +TMPDIR="$scratch/one" bash -euo pipefail -c ' + source "$1/harness.sh" + harness_begin ports >&2 + harness_port first + printf "%s\n" "$HARNESS_PORT" >"$2/ready" + read -r _ <"$2/release" +' bash "$lib" "$scratch" & +owner=$! +read -r first <"$scratch/ready" +TMPDIR="$scratch/two" bash -euo pipefail -c ' + source "$1/harness.sh" + harness_begin ports >&2 + harness_port second + if [[ "$HARNESS_PORT" == "$2" ]]; then + echo "FAIL: separate TMPDIR shells both reserved $2" >&2 + exit 1 + fi + if harness_port pinned "$2"; then + echo "FAIL: pinned port ignored another shell reservation" >&2 + exit 1 + fi +' bash "$lib" "$first" +printf 'done\n' >"$scratch/release" +wait "$owner" +owner="" +# Refuse an unexpected owner-controlled target under the predictable root. +ln -s "$scratch/one" "$scratch/ports-link" +MOQ_TEST_PORTS="$scratch/ports-link" bash -euo pipefail -c ' + source "$1/harness.sh" + harness_begin ports >&2 + if harness_port symlink; then + echo "FAIL: accepted a symlink reservation root" >&2 + exit 1 + else + status=$? + [[ "$status" == 2 ]] + fi +' bash "$lib" +echo "cross-shell port reservations passed"