Skip to content

CI: adopt ci-kit; timing tests assert events, not speed - #143

Merged
SSFSKIM merged 10 commits into
mainfrom
ci-kit-adoption
Oct 16, 2026
Merged

SSFSKIM merged 10 commits into
mainfrom
ci-kit-adoption

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

What

cua adopts ci-kit (its M2). Pull requests get ci / test, ci / plugin and ci / verdict checks on GitHub's free hosted macOS runner, and any worktree can verify a commit off the MacBook with ci-gate. The timing-sensitive tests that made local gates nondeterministic under load now assert events, or check their budget arithmetic on a controlled clock. Test code and the two CI files only; nothing under src/, no manifest, no merge setting.

  • CI (the last commit; the two files as ci-kit's docs/adopting.md gives them). .github/workflows/ci.yml calls SSFSKIM/ci-kit/.github/workflows/gates.yml@v1. .github/ci-kit.yml defines two gates on hosted-macos, with Node 24, npm ci and full history (fetch_depth: 0, which the parity tests' committed evidence revisions need):
    • test: npm test.
    • plugin: installs the claude CLI (each attempt cut at 3 min, up to 3 attempts; one hosted install hung for 6 min), then runs claude plugin validate . and npm run test:mods.
    • There is no ubuntu leg. It waits for the Linux fixes in Linux (ubuntu-latest) test failures found by the CI probe #142. Live checks (verify.mjs, accept-native, accept-chrome) stay local. Nothing is made required.
  • Test fixes, one commit each. test/browser-service/support/controlled-clock.mjs is new: it gives a test node:test's mocked Date and setTimeout and moves time 1 ms per event-loop turn, so code that decides from the clock decides the same way on any machine.

A10: each fix before and after, under induced CPU load

Every count below comes from a ci-gate run on a throwaway commit (its ref deleted afterwards) on GitHub's hosted macOS runner. The runner had 3 cores, or 5 where noted, with yes loops at 2x the cores beside the test loop (8x where noted). Runs go 4 at a time, as the full suite runs files side by side. "Before" is the file at main, run until its first failure or the stated cap. The scripts are in the PR comment.

Commit Test(s) Before (main) After Load
aedd920 extension-host waits for the host to serve whole file 7/20 failed, connect ECONNREFUSED …sock in 6 different tests 20/20 2x
db81d2f mcp-upstream confirmed-teardown budget (#123) whole file 1/20 failed: "owned descendants … are reaped" (teardown unconfirmed at 3.26 s). In a 10-run full-suite survey at 2x, this was the only failure. 20/20 2x
3725082 cdp on a controlled clock (+ 06c6594, review fix: setTimeout mocked too) 3 tests 0/20 at 2x, 0/200 at 2x (5 cores), 1/220 failed at 8x: timeoutMs 357 with 328 ms left 20/20 at 2x and at 8x 2x, 8x
8d50ddf actions selector polling on a controlled clock element without a box; never-enabled click 1/20 failed ("never becomes possible") 20/20 2x
b98fbd0 eof-drain orders the late elicitation by events whole file, run one at a time 0/20 20/20 2x
fed7885 chrome-host-run and real-host waits: liveness bound whole file 0/200 20/20 2x
f4e49a9 chrome-host-run reads the orphan's outcome once whole whole file 1/4 failed: Unexpected end of JSON input (0/200 in a later round) 20/20 2x
3d3ebe3 actions clipboard-queue tests on a controlled clock (the product race it exposed: #144) fill's paste budget; shortcut queued behind another 1/36 failed: "a fill's paste has the caller's budget" (1 paste for 0). The same failure also hit an unloaded gate run in the first 20-run series. 20/20 2x

The "fails before" evidence is thin for two fixes:

  • eof-drain. The before-failure was not reproduced on the hosted runner (0/20). The evidence for it is 6 failures in the MacBook's gate logs at load 100–250, plus a mutation check: with the host's closing check removed, the new test fails. Other proof shapes for this file lost the hosted runner itself, with no log uploaded.
  • chrome-host-run's ceiling (fed7885). It did not fail before the fix (0/200).

Also, cdp's failure class appeared only at 8x (0/200 at 2x).

The review fix 06c6594 was re-run: the cdp and actions files each passed 20/20 under 2x load (results below).

A1 and A2

  • A1. This PR's checks finished 5 min 10 s after the push: ci / plan, ci / test (2,316 pass, 0 fail, 86 skip), ci / plugin (validate plus 32/32 mods) and ci / verdict, all green.
  • A2 and the 20-run series. ci-gate on head 9ab5439 returned GREEN 20 times in a row (stabb1…stabb20). The first series, on the previous head, went RED at run 11 on the clipboard-queue test, which commit 3d3ebe3 fixes. The review fix touches only the cdp test and the controlled-clock helper. One final ci-gate run of the new head b45df7d was GREEN (run 38846002116). Under 2x load, the whole cdp file (45 tests) and the whole actions file (24 tests) each passed 20/20 after the fix (run 38845997387).

Deferred

  • The serve/repl-host teardown flakes in test/repl-host/* stay with the own-REPL-host M4 branch, which has those files in flight.
  • serve-cli / serve-lazy (cua serve teardown budget (5 s) is not controllable; serve-cli/serve-lazy flake under load #145). Their logged failures ("runtime teardown unconfirmed … group enumeration failed or timed out", exit 1) come from cua serve's own 5 s teardown budget. They appeared on one MacBook run at load 107–154, with the own host. The tests can only raise that budget through a product seam: serve() does not forward teardownBudgetMs, and serve-cli spawns the CLI. That seam is not made here. None of these failed in 10 full-suite runs at 2x on the gate lane.

…ile (#123)

The host runs in its own process and binds its socket path before it listens, so a client that connects as soon as
the file appears can be refused (ECONNREFUSED, seen in three tests of this file under load). start() now waits for an
accepted connection, and every wait's ceiling is a 20 s liveness bound rather than 5 s.
Teardown sends SIGKILL at 0.7 of its budget and must observe the group empty in the rest, so a 3 s budget left a
loaded machine 0.9 s to deliver the signal and run pgrep: 'owned descendants ... are reaped' read unconfirmed at
3.26 s on a hosted macOS runner under 2x CPU load, and the same family ('group enumeration failed or timed out') on the
MacBook. Confirming teardowns now get 10 s, and the waits for a reply or a pid file end on their condition within a
20 s liveness bound instead of a fixed number of polls.
Three tests judged a budget against the wall clock and failed when the machine was slow between two of the
controller's steps: 'timeoutMs 368 with 365 ms left' (and 288 with 285), the joined caller that did not re-attach
because the host double's timer fired before the starter's deadline read as spent, and the dispatch-time check of a
deadline that runs out during attachment. Time now passes only as the test moves it (node:test mock timers), so each
setup command's allowance is asserted exactly (380, 360, 340, 320) and the starter's deadline is spent exactly when the
host times out.
Which sentence ends a polling click depends on where its budget runs out, and on a loaded machine it can run out
mid-attempt, giving a third ending the tests did not accept ('... CDP operation exceeded its deadline before command
dispatch', seen for the element without a box). On a controlled clock the budget runs out at the same point everywhere,
so the element-without-box and never-enabled tests assert the exact sentence, that a missing element is polled every
100 ms until its budget ends, and that nothing was clicked.
… not a delay

'during the drain a new elicitation is not asked of the departed client' ended input 100 ms after submitting a cell
whose service asked 300 ms later; on a loaded machine the host read the EOF after that, so the 'late' request reached
the client (6 failures in the MacBook's logs). The service now asks it only after its first request was withdrawn, which
the host does when the drain begins. 'Answered at once' is now a liveness bound of half the cell's 30 s budget (one
run took 5.3 s against 2.5 s), the wait for the first request ends on its condition, and the per-test ceiling is 60 s.
…iveness bound

Their waits for a socket, an event or a closed client gave up after 3 s, a speed claim a loaded machine can miss
(the in-process host tests named in tech-debt (b)). The condition still ends each wait; the ceiling is now 20 s.
The connector writes its result file in one write, and the test parsed it as soon as the file existed: under 2x CPU
load on a hosted macOS runner that read caught it empty ('Unexpected end of JSON input', 1 of 4 runs). The wait now
ends when the file parses.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T00:12:24.647654Z ac852d9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

'a fill's paste has the caller's budget' failed once in the 20-run ci-gate series on a hosted macOS runner (1 paste
for 0): the wait in the clipboard queue rejected on its timer, the test released the queue at once, and the queued
paste's own deadline check still read the budget as unspent, because a loaded event loop can fire a timer before
Date.now() reaches its end. On a controlled clock the timeout and the spent budget are the same instant. The next test
(a shortcut queued behind another) has the same shape and a 500 ms speed claim; it moves too, and now asserts that the
rejection came at its 300 ms budget.
@SSFSKIM

SSFSKIM commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

A10 proof scripts (ci-kit M2). Each A10 round was a ci-gate <throwaway commit> --label a10… run whose .github/ci-kit.yml gates call these on hosted-macos (Node 24, npm ci), with the file at main copied beside the fixed one as <name>.test.a10before.mjs. Example gate: bash .github/a10.sh test/browser-service/cdp.test.mjs '<pattern>' 200 (env A10_LOAD_FACTOR: "8" for the 8x round). The throwaway refs were deleted after each run.

.github/a10.sh (runs 4 at a time):

#!/bin/bash
# Temporary (ci-kit M2, A10): a fixed test file before and after its fix, 20 runs each, under an induced CPU load of 2x
# the cores (`yes` loops; stress-ng is absent on the macOS runner). Runs go 4 at a time, as the full suite runs files
# side by side. The before set runs in batches of 4 until a run fails or <before runs> (default 20) were made.
# A run still going after 240 s is killed and counts as failed. A10_LOAD_FACTOR (default 2) sets the loops per core.
# Usage: a10.sh <test file> [name pattern] [before runs]. Exits 1 if any after-run failed.
file=$1 pattern=${2:-} before_max=${3:-20}
before="${file%.mjs}.a10before.mjs"
n=$(sysctl -n hw.ncpu 2>/dev/null || nproc)
factor=${A10_LOAD_FACTOR:-2}
for i in $(seq $((factor * n))); do (yes > /dev/null &); done
trap 'pkill -x yes' EXIT
echo "cores=$n load=$((factor * n)) yes loops; $(uptime)"
mkdir -p a10-out
after_failed=0
run_set() {
  label=$1 path=$2 max=$3 pass=0 fail=0 batch=0
  while [ $((batch * 4)) -lt "$max" ]; do
    batch=$((batch + 1))
    if [ "$label" = before ] && [ "$fail" -gt 0 ]; then break; fi
    pids=""
    for i in 1 2 3 4; do
      if [ -n "$pattern" ]; then
        ( HOME=$(mktemp -d) perl -e 'alarm 240; exec @ARGV' node --test --test-reporter=tap --test-name-pattern="$pattern" "$path" > "a10-out/$label-$batch-$i.tap" 2>&1 ) &
      else
        ( HOME=$(mktemp -d) perl -e 'alarm 240; exec @ARGV' node --test --test-reporter=tap "$path" > "a10-out/$label-$batch-$i.tap" 2>&1 ) &
      fi
      pids="$pids $!"
    done
    for p in $pids; do if wait "$p"; then pass=$((pass + 1)); else fail=$((fail + 1)); fi; done
  done
  tests=$(cat a10-out/$label-*.tap | grep -E '^# pass ' | awk '{print $3}' | sort -u | tr '\n' ' ')
  echo "A10 $label $file${pattern:+ [$pattern]}: pass $pass/$((pass + fail)), fail $fail/$((pass + fail)); passing tests per run: $tests; $(uptime | sed 's/.*averages*: //')"
  grep -h '^not ok' a10-out/$label-*.tap | sed 's/^not ok [0-9]* - /  failed: /' | sort | uniq -c
  grep -h -A8 '^not ok' a10-out/$label-*.tap | grep -E "^  error:" | cut -c1-200 | sort | uniq -c
  [ "$label" = after ] && after_failed=$fail
}
run_set before "$before" "$before_max"
run_set after "$file" 20
[ "$after_failed" = 0 ]

.github/a10-seq.sh (eof-drain: one at a time, leftovers killed between runs):

#!/bin/bash
# Temporary (ci-kit M2, A10): like a10.sh, one run at a time, each cut at 150 s, and every process a run left under
# src/repl-host/ killed before the next (a hung own-host run otherwise piles up kernels and wedges the runner).
# Usage: a10-seq.sh <test file> <name pattern> [runs per side]
file=$1 pattern=$2 runs=${3:-20}
shift 3 2>/dev/null || shift $#
before="${file%.mjs}.a10before.mjs"
n=$(sysctl -n hw.ncpu 2>/dev/null || nproc)
for i in $(seq $((2 * n))); do (yes > /dev/null &); done
trap 'pkill -x yes' EXIT
echo "cores=$n load=$((2 * n)) yes loops; $(uptime)"
mkdir -p a10-out
after_failed=0
for label in before after; do
  path=$file; [ $label = before ] && path=$before
  pass=0 fail=0
  for i in $(seq "$runs"); do
    start=$(date +%s)
    if [ -n "$pattern" ]; then set -- --test-name-pattern="$pattern"; else set --; fi
    if HOME=$(mktemp -d) perl -e 'alarm 150; exec @ARGV' node --test --test-reporter=tap "$@" "$path" > "a10-out/$label-$i.tap" 2>&1; then
      pass=$((pass + 1)); r=pass
    else
      fail=$((fail + 1)); r=FAIL
    fi
    pkill -9 -f "src/repl-host/" 2>/dev/null
    echo "  $label run $i: $r in $(( $(date +%s) - start ))s; $(grep -h '^not ok' a10-out/$label-$i.tap | tr '\n' ' ')"
    [ $label = before ] && [ $fail -gt 0 ] && break
  done
  echo "A10 $label $file [$pattern]: pass $pass/$((pass + fail)), fail $fail/$((pass + fail)); $(uptime | sed 's/.*averages*: //')"
  grep -h -A8 '^not ok' a10-out/$label-*.tap | grep -E "^  error:" | cut -c1-200 | sort | uniq -c
  [ $label = after ] && after_failed=$fail
done
[ "$after_failed" = 0 ]

…mp has a liveness bound

Review of #143: 'a first attachment gives each setup command what the command has left' mocked only Date, so the
controller's Deadline.race kept a real 400 ms timer; a 450 ms stall in one backend answer failed it with 'CDP operation
exceeded its deadline before command dispatch' (reproduced, and passing with the fix). And onControlledClock pumped
without bound, so work that never settles kept the test running; it now fails after 60 s of controlled time and still
restores the real clock.
Two files, as ci-kit's docs/adopting.md gives them: the caller workflow, and the gates. test runs npm test; plugin
installs the claude CLI (each attempt cut at 3 minutes, 3 attempts) and runs claude plugin validate and test:mods.
Node 24, npm ci, full history for the parity tests' committed evidence. Live checks stay local.
@SSFSKIM
SSFSKIM merged commit 45c003a into main Oct 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant