From 6366a05806600166456150d70f47fa3f1f2a4723 Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 21:51:30 -0500 Subject: [PATCH 1/3] fix(linux): paging deadline test measured its own serialisation a_server_that_stops_reading_ends_the_request_by_the_deadline built a 64 MB body and timed the whole post(). post() serialises the body inside the request deadline, and a debug build takes about 4 s to serialise 64 MB, so the test saw 4.2 s for a request that ends at its 500 ms deadline. Change: the body is 16 MB, still larger than the loopback socket buffers, and the elapsed bound is 3 s. The server releases the socket after 4 s, so a request that ignored its deadline still fails the bound. Checks, run on the aarch64 Linux host against a copy of this tree: - cargo fmt --check: exit 0 - cargo clippy -- -D warnings: exit 0 - cargo test --no-fail-fast: 598 passed, 1 failed, 17 ignored. The paging test passes. The one failure is proc::tests::a_pid_that_does_not_exist_signals_nothing_and_does_not_panic, which also fails on the base commit (pre-existing, not changed here). --- poc/reverse-attach-linux/src/external_tests.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/poc/reverse-attach-linux/src/external_tests.rs b/poc/reverse-attach-linux/src/external_tests.rs index 0f21bb8..3c79a31 100644 --- a/poc/reverse-attach-linux/src/external_tests.rs +++ b/poc/reverse-attach-linux/src/external_tests.rs @@ -708,12 +708,16 @@ mod paging { drop(held); }); let e = External::for_test("browser", &url).with_deadline(Duration::from_millis(500)); - let big = json!({"cursor": "a".repeat(64 << 20)}); + // 16 MB is more than the loopback socket buffers hold. It is small enough that serialising + // it in a debug build (`post` does that inside the deadline) takes about a second, not four. + let big = json!({"cursor": "a".repeat(16 << 20)}); let started = Instant::now(); let r = e.post(&big, Some(Duration::from_secs(30))); assert_eq!(r.err().as_deref(), Some("upstream_timeout")); + // The request deadline is 500 ms. The server releases the socket after 4 s, so a request that + // ignored its deadline would take at least 4 s; 3 s separates the two. assert!( - started.elapsed() < Duration::from_millis(1500), + started.elapsed() < Duration::from_secs(3), "{:?}", started.elapsed() ); From d29d8e6c4ae9277aed8a0f3c7571af8533fffe01 Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 21:51:36 -0500 Subject: [PATCH 2/3] test(pins): guard the README npm ci isolation settings Tests/Fixtures/README.md tells the reader how to re-record the Playwright fixture with an isolated npm ci: --ignore-scripts, --userconfig, --globalconfig, --cache, --registry https://registry.npmjs.org/ and HOME. Those are the same settings run_smoke passes in scripts/playwright-pins.py. The README already had them. Nothing checked that they stayed there. Change: FixtureReadme checks that the README names each setting, and that run_smoke still passes the flags. Removing --cache from the README makes the new test fail; restoring it makes the test pass. Checks, run on the aarch64 Linux host against a copy of this tree: - python3 scripts/test-playwright-pins.py: 54 tests OK, playwright pins: ok (offline) - python3 scripts/test-playwright-pins.py FixtureReadme on a copy with --cache removed from the README: FAILED (failures=1); restored copy: OK --- scripts/test-playwright-pins.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/test-playwright-pins.py b/scripts/test-playwright-pins.py index 731571b..4270819 100644 --- a/scripts/test-playwright-pins.py +++ b/scripts/test-playwright-pins.py @@ -582,6 +582,23 @@ def test_a_darwin_platform_has_no_cdn_fallback(self): pins.choose_chromium_source("9.9", "7", "darwin-arm64") +class FixtureReadme(unittest.TestCase): + """The npm ci step in Tests/Fixtures/README.md must carry the isolation settings run_smoke uses.""" + + ISOLATION = ["npm ci", "--ignore-scripts", "--userconfig", "--globalconfig", "--cache", + "--registry https://registry.npmjs.org/", "HOME="] + + def test_the_readme_npm_ci_step_names_every_isolation_setting(self): + doc = read(os.path.join(ROOT, "Tests", "Fixtures", "README.md")) + self.assertEqual([s for s in self.ISOLATION if s not in doc], []) + + def test_run_smoke_passes_the_same_isolation_flags(self): + src = read(os.path.join(HERE, "playwright-pins.py")) + for flag in ("--ignore-scripts", "--userconfig", "--globalconfig", "--cache", "--registry"): + self.assertIn(flag, src) + self.assertIn('"HOME": work', src) + + class Generate(unittest.TestCase): def test_generate_refuses_to_run_without_a_node_team_id(self): err = io.StringIO() From 1594e56f602464d8a86f0dd0c387cecf6c444c7c Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 06:59:55 -0500 Subject: [PATCH 3/3] test(pins): scope the npm ci isolation check to the command itself The FixtureReadme checks matched flags anywhere in their file. The run_smoke check was a whole-file substring match, and --userconfig, --globalconfig, --ignore-scripts and --cache also occur in the lockfile-generation call, so removing them from run_smoke still passed. - run_smoke: parse playwright-pins.py with ast, find the subprocess call that runs npm ci inside run_smoke, and require the four flags on that call and a HOME key in the env dict assigned inside run_smoke. - README: take the logical command that contains npm ci (with its line continuations) from the fenced block and require the flags, HOME= and the registry on that command only. This also covers the low finding that the README check was a whole-document substring match. - Low finding on the paging test bound (3 s): not changed here. A safe bound needs a measurement on the CI runner, and the change would be to a Rust test that this step did not otherwise touch. Tests added: removing each of the four flags from the README command, from the run_smoke npm ci call, and removing HOME from the run_smoke env fails its test. The current README and run_smoke pass. Verification run for this commit: - python3 scripts/test-playwright-pins.py FixtureReadme: 5 tests, OK. - python3 scripts/test-playwright-pins.py: 57 tests, OK; playwright pins offline check ok. - Mutation, file level, one flag at a time in a scratch copy: each of --userconfig, --globalconfig, --ignore-scripts, --cache removed from the run_smoke npm ci call fails FixtureReadme; the same four removed from the README command fail; HOME removed from the run_smoke env fails. Unmodified copy: OK. - swift build (macOS build host, scratch copy under /private/tmp): complete. - swift test: 852 executed, 0 failures, 5 skipped. - Rust: skipped, no .rs or Cargo file changed. --- scripts/test-playwright-pins.py | 96 +++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 11 deletions(-) diff --git a/scripts/test-playwright-pins.py b/scripts/test-playwright-pins.py index 4270819..e994af3 100644 --- a/scripts/test-playwright-pins.py +++ b/scripts/test-playwright-pins.py @@ -3,11 +3,14 @@ Run: python3 scripts/test-playwright-pins.py """ +import ast import contextlib import importlib.util import io import json import os +import re +import shlex import shutil import tarfile import tempfile @@ -18,6 +21,7 @@ HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.dirname(HERE) +README = os.path.join(ROOT, "Tests", "Fixtures", "README.md") spec = importlib.util.spec_from_file_location("playwright_pins", os.path.join(HERE, "playwright-pins.py")) pins = importlib.util.module_from_spec(spec) spec.loader.exec_module(pins) @@ -582,21 +586,91 @@ def test_a_darwin_platform_has_no_cdn_fallback(self): pins.choose_chromium_source("9.9", "7", "darwin-arm64") -class FixtureReadme(unittest.TestCase): - """The npm ci step in Tests/Fixtures/README.md must carry the isolation settings run_smoke uses.""" +def run_smoke_npm_ci(src): + """Return (run_smoke function node, the subprocess call that runs npm ci inside it).""" + fn = next(n for n in ast.walk(ast.parse(src)) if isinstance(n, ast.FunctionDef) and n.name == "run_smoke") + for node in ast.walk(fn): + if isinstance(node, ast.Call) and node.args and isinstance(node.args[0], ast.List): + if [e.value for e in node.args[0].elts[:2] if isinstance(e, ast.Constant)] == ["npm", "ci"]: + return fn, node + raise AssertionError("run_smoke has no npm ci call") + - ISOLATION = ["npm ci", "--ignore-scripts", "--userconfig", "--globalconfig", "--cache", - "--registry https://registry.npmjs.org/", "HOME="] +def readme_npm_ci_command(doc): + """Return the raw text of the one npm ci command in the fixture README, with its line continuations.""" + blocks = [b for b in re.findall(r"```[^\n]*\n(.*?)```", doc, re.S) if "npm ci" in b] + if len(blocks) != 1: + raise AssertionError("expected one npm ci block, found %d" % len(blocks)) + lines = blocks[0].split("\n") + start = next(i for i, line in enumerate(lines) if "npm ci" in line) + while start > 0 and lines[start - 1].rstrip().endswith("\\"): + start -= 1 + end = next(i for i, line in enumerate(lines) if "npm ci" in line) + while lines[end].rstrip().endswith("\\"): + end += 1 + return "\n".join(lines[start:end + 1]) - def test_the_readme_npm_ci_step_names_every_isolation_setting(self): - doc = read(os.path.join(ROOT, "Tests", "Fixtures", "README.md")) - self.assertEqual([s for s in self.ISOLATION if s not in doc], []) - def test_run_smoke_passes_the_same_isolation_flags(self): +class FixtureReadme(unittest.TestCase): + """The npm ci command in Tests/Fixtures/README.md and in run_smoke must both isolate npm.""" + + FLAGS = ("--ignore-scripts", "--userconfig", "--globalconfig", "--cache") + + @classmethod + def readme_gaps(cls, doc): + words = shlex.split(re.sub(r"\\\n\s*", " ", readme_npm_ci_command(doc))) + gaps = [f for f in cls.FLAGS if f not in words] + if not words[0].startswith("HOME="): + gaps.append("HOME") + if not any(words[i:i + 2] == ["--registry", "https://registry.npmjs.org/"] for i in range(len(words))): + gaps.append("--registry") + return gaps + + @classmethod + def smoke_gaps(cls, src): + fn, call = run_smoke_npm_ci(src) + words = {e.value for e in call.args[0].elts if isinstance(e, ast.Constant)} + gaps = [f for f in cls.FLAGS if f not in words] + home_set = any(isinstance(n, ast.Assign) and isinstance(n.value, ast.Dict) + and any(isinstance(k, ast.Constant) and k.value == "HOME" for k in n.value.keys) + for n in ast.walk(fn)) + if not home_set or not any(k.arg == "env" for k in call.keywords): + gaps.append("HOME") + return gaps + + def test_the_readme_npm_ci_command_carries_every_isolation_setting(self): + self.assertEqual(self.readme_gaps(read(README)), []) + + def test_removing_a_flag_from_the_readme_command_is_caught(self): + doc = read(README) + command = readme_npm_ci_command(doc) + for flag in self.FLAGS: + with self.subTest(flag=flag): + mutated_command = command.replace(flag + " ", "", 1) + self.assertNotEqual(mutated_command, command) + mutated = doc.replace(command, mutated_command, 1) + self.assertIn(flag, self.readme_gaps(mutated)) + + def test_run_smoke_npm_ci_carries_every_isolation_setting(self): + self.assertEqual(self.smoke_gaps(read(os.path.join(HERE, "playwright-pins.py"))), []) + + def test_removing_a_flag_from_the_run_smoke_npm_ci_call_is_caught(self): + src = read(os.path.join(HERE, "playwright-pins.py")) + _, call = run_smoke_npm_ci(src) + text = ast.get_source_segment(src, call) + for flag in self.FLAGS: + with self.subTest(flag=flag): + mutated_text = text.replace('"%s", ' % flag, "", 1) + self.assertNotEqual(mutated_text, text) + self.assertIn(flag, self.smoke_gaps(src.replace(text, mutated_text, 1))) + + def test_removing_home_from_the_run_smoke_env_is_caught(self): src = read(os.path.join(HERE, "playwright-pins.py")) - for flag in ("--ignore-scripts", "--userconfig", "--globalconfig", "--cache", "--registry"): - self.assertIn(flag, src) - self.assertIn('"HOME": work', src) + fn, _ = run_smoke_npm_ci(src) + text = ast.get_source_segment(src, fn) + mutated_text = text.replace('"HOME": work', '"HOME_X": work', 1) + self.assertNotEqual(mutated_text, text) + self.assertIn("HOME", self.smoke_gaps(src.replace(text, mutated_text, 1))) class Generate(unittest.TestCase):