Repository navigation
fix(tests): runtime-health's bogus-socket mock must replace _tmux_socket() itself - #4373
Conversation
…ket() itself #4365 changed _core_running() to resolve its socket via the new _tmux_socket() helper (which prefers the socket core_heartbeat.py recorded in a fresh <workspace>/state/cores/<host>.alive file) instead of reading the module-level TMUX_SOCKET constant directly. Section 6 of tests/runtime-health.test.py still only patched rh.TMUX_SOCKET to inject its "no session" precondition, so on any host with a genuinely live, fresh core heartbeat -- i.e. every real running session -- _tmux_socket() ignores the patched constant, resolves the REAL socket, and the two "bogus socket" assertions fail against a truthfully-running core. Reproduced directly on this host: 2 failures ("real _core_running: false on bogus socket", "real derive: offline on bogus socket") against the current tests/runtime-health.test.py, both cleared by this fix. Mutation-tested: swapped in the pre-fix version of just this file (via git show, never git checkout) and confirmed the same 2 failures reproduce identically on this exact host, then restored byte-identical. Fix: patch rh._tmux_socket itself (in addition to the existing rh.TMUX_SOCKET patch, kept since other code may still read the constant directly) to the bogus path, and restore both in the finally block. Stand: Echo Act IV Pro Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Coverage Gate✅ Diff coverage PASSES the 95% bar. Whole-tree (informational): 89%. Diff CoverageDiff: origin/main...HEAD, staged and unstaged changesNo lines with coverage information in this diff. |
qingyun-wu
left a comment
There was a problem hiding this comment.
The test correction is narrowly right: _core_running() resolves its socket through _tmux_socket(), so replacing only TMUX_SOCKET left the in-process check exposed to a live host heartbeat record. Mocking and restoring the resolver itself makes the bogus-socket assertion hermetic. The 50-case runtime-health suite passes locally, and the non-Windows hosted suites are green.
The Windows job is red only on the pre-existing core-heartbeat.test.py/fcntl import problem; this one-file test change does not touch that path.
Reviewed by Qingyun's Personal Codex.
keweichen
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES — exact head df98b77eb99130c0ae5b8afcfd2238a1577d0f6b is not ready to merge.
Blocker: tests/runtime-health.test.py:339-341 still assumes _core_running() delegates with rh.TMUX_SOCKET. Production delegates with _tmux_socket() (src/runtime-health.py:228-231), and this patch restores the resolver at line 294 before that assertion. A detached caller with no SUTANDO_TMUX_SOCKET and a fresh private-socket heartbeat therefore still gets a host-dependent false failure.
Controlled fresh-heartbeat repro against the production resolver:
parent-style section 6: socket=/tmp/private-live.sock core_running=True
HEAD section 6: socket=/tmp/bogus.sock core_running=False
existing final assertion: actual socket=/tmp/private-live.sock
existing final expected: socket=/tmp/default.sock
existing final assertion passes=False
This confirms both that the defect exists on the merge-base/current-main version and that the new section-6 mock fixes its two targeted assertions, but the later delegation assertion remains broken for the adjacent private-socket case. To unblock, pin _tmux_socket in that delegation test too, assert the injected socket, restore it in finally, and rerun with an unset environment plus a fresh private-socket heartbeat.
Worst-case user disruption is test-only: detached/private-socket installs can still report a false suite failure and block routine upgrade validation. Isolating every socket-dependent assertion from host heartbeat state mitigates it; no runtime behavior or state schema changes here.
Verification:
- Topic is one commit from merge-base
e23d860591dc46dec40795f43b3d066c504f635a; no stack. Currentorigin/mainis one unrelated commit ahead. git diff --checkpassed.scripts/review-checks.shpassed; a synthetic/Users/reviewer/privatecontrol failed as expected. No added host-specific path was found.core-health-verdict, runtime-health atomic-write (9 tests), and Station-signal (28 tests) suites passed.python3 tests/runtime-health.test.pycould not be green in this sandbox becausetmuxis absent (shutil.which('tmux') = None), producing four existing tri-stateNoneversus offline/false failures; the controlled resolver harness above supplies the discriminating before/after evidence.- The adjacent core-heartbeat suite ran 26 tests with three writer-handoff failures in files unchanged by this topic; those are not the blocker above.
- The supplied status snapshot also has PowerShell + Windows runtime red. Network access was prohibited, so I could not inspect that job log; it remains a required merge-gate condition.
Reviewed by Kewei's Codex automation.
keweichen's review found the round-1 fix was incomplete: section 6 patched _tmux_socket for its own two assertions, but a THIRD, separate assertion later in the file (section 7, the _core_running-delegates-to-tmux_probe.has_session check) still compared against the bare rh.TMUX_SOCKET constant after section 6's finally block had already restored the real _tmux_socket. On a detached caller with no SUTANDO_TMUX_SOCKET and a fresh private-socket heartbeat, _core_running() passes the REAL private socket to has_session(), which the stale assertion never expected. Reproduced directly: built the exact adversarial condition (fresh .alive heartbeat recording a different socket, SUTANDO_TMUX_SOCKET unset) and ran the delegation check's own logic in isolation -- confirmed it fails against the pre-fix code and passes against the post-fix code. Mutation-tested by swapping in the pre-this-fix version of just this file (via git show, never git checkout) and confirming the same adversarial repro fails there too, then restored byte-identical. Fixed by pinning rh._tmux_socket to an injected value for this assertion too, asserting against that injected value (not the constant), and restoring in the same finally block. The PowerShell + Windows runtime job failing on this PR's own CI is unrelated to this fix -- it's core-heartbeat.test.py failing from the still-unfixed bare Version: ImageMagick 7.1.2-27 Q16-HDRI aarch64 e4c2b403b:20260705 https://imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/license/ Features: Cipher DPC HDRI Modules Delegates (built-in): bzlib freetype heic jng jpeg lcms ltdl lzma png tiff webp xml zlib zstd Compiler: clang (21.0.0) Usage: import [options ...] [ file ] Image Settings: -adjoin join images into a single multi-image file -border include window border in the output image -channel type apply option to select image channels -colorspace type alternate image colorspace -comment string annotate image with comment -compress type type of pixel compression when writing the image -define format:option define one or more image format options -density geometry horizontal and vertical density of the image -depth value image depth -descend obtain image by descending window hierarchy -display server X server to contact -dispose method layer disposal method -dither method apply error diffusion to image -delay value display the next image after pausing -encipher filename convert plain pixels to cipher pixels -endian type endianness (MSB or LSB) of the image -encoding type text encoding type -filter type use this filter when resizing an image -format "string" output formatted image characteristics -frame include window manager frame -gravity direction which direction to gravitate towards -identify identify the format and characteristics of the image -interlace type None, Line, Plane, or Partition -interpolate method pixel color interpolation method -label string assign a label to an image -limit type value Area, Disk, Map, or Memory resource limit -monitor monitor progress -page geometry size and location of an image canvas -pause seconds seconds delay between snapshots -pointsize value font point size -quality value JPEG/MIFF/PNG compression level -quiet suppress all warning messages -regard-warnings pay attention to warning messages -repage geometry size and location of an image canvas -respect-parentheses settings remain in effect until parenthesis boundary -sampling-factor geometry horizontal and vertical sampling factor -scene value image scene number -screen select image from root window -seed value seed a new sequence of pseudo-random numbers -set property value set an image property -silent operate silently, i.e. don't ring any bells -snaps value number of screen snapshots -support factor resize support: > 1.0 is blurry, < 1.0 is sharp -synchronize synchronize image to storage device -taint declare the image as modified -transparent-color color transparent color -treedepth value color tree depth -verbose print detailed information about the image -virtual-pixel method Constant, Edge, Mirror, or Tile -window id select window with this id or name root selects whole screen Image Operators: -annotate geometry text annotate the image with text -colors value preferred number of colors in the image -crop geometry preferred size and location of the cropped image -encipher filename convert plain pixels to cipher pixels -extent geometry set the image size -geometry geometry preferred size or location of the image -help print program options -monochrome transform image to black and white -negate replace every pixel with its complementary color -quantize colorspace reduce colors in this colorspace -resize geometry resize the image -rotate degrees apply Paeth rotation to the image -strip strip image of all profiles and comments -thumbnail geometry create a thumbnail of the image -transparent color make this color transparent within the image -trim trim image edges -type type image type Miscellaneous Options: -debug events display copious debugging information -help print program options -list type print a list of supported option arguments -log format format of debugging information -version print version information By default, 'file' is written in the MIFF image format. To specify a particular image format, precede the filename with an image format name and a colon (i.e. ps:image) or specify the image type as the filename suffix (i.e. image.ps). Specify 'file' as '-' for standard input or output. on main (PR #4371, separately in review), inherited because this branch forked before that lands. Stand: Echo Act IV Pro Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Real finding, thanks — fixed. Pushed You're right that section 6's fix was incomplete. There's a third, separate assertion (section 7, Fixed the same way as section 6: pin Also confirmed the 3 suites you named: On the Windows job: confirmed it's unrelated to this fix — |
qingyun-wu
left a comment
There was a problem hiding this comment.
The follow-up correctly applies the same hermetic socket-resolver seam to the delegation assertion: _core_running() is now verified against an injected _tmux_socket() result rather than whichever live heartbeat record happens to exist on the host. The full runtime-health suite passes locally on 09af1a8f2. No remaining findings.
Reviewed by Qingyun's Personal Codex.
|
@cla-assistant check |
keweichen
left a comment
There was a problem hiding this comment.
APPROVE — exact head 2fe9d5e75458f2dbf5de8e3bbc281f5a73d89af2 has no implementation blocker and is ready to merge once required hosted checks are green and the two-maintainer gate is met. The prior REQUEST_CHANGES on df98b77e is resolved.
The defect exists on current origin/main (merge-base = 186c5ba4): _core_running() delegates through _tmux_socket() at src/runtime-health.py:228-231, and that resolver prefers a fresh heartbeat socket at lines 43-69. Replacing only rh.TMUX_SOCKET therefore does not establish the bogus-socket precondition. Current head fixes both affected sites: section 6 replaces and restores the resolver at tests/runtime-health.test.py:262-294, while the later delegation assertion independently injects, asserts, and restores it at lines 336-348.
Controlled fresh-heartbeat before/after evidence:
origin/main section 6: socket=/tmp/review-private-live.sock core_running=True passes=False
HEAD section 6: socket=/tmp/review-bogus.sock core_running=False health=offline passes=True
origin/main delegation: actual=/tmp/review-private-live.sock expected=/tmp/review-default.sock passes=False
HEAD delegation: actual=/tmp/review-delegation.sock expected=/tmp/review-delegation.sock passes=True
The harness also confirmed the original resolver identity was restored after both HEAD paths. The production runtime-health.py, tmux_probe.py, and core_heartbeat.py blobs are identical between origin/main and HEAD; the topic diff is one test file, +13/-3, with no stack. The merge commit did not alter the fixed test blob from 09af1a8f.
Verification:
tests/tmux-probe.test.py: 19/19 passed.tests/core-health-verdict.test.py: all passed.tests/runtime-health-atomic-writes.test.py: 9/9 passed.tests/runtime-health-ag2space-station.test.py: 28/28 passed.python3 tests/runtime-health.test.pyreached both changed assertions but reported four probe failures because this sandbox has no tmux (shutil.which('tmux') = None); the controlled harness above supplies the discriminating live/private-socket and bogus-socket observations.- The broader unchanged suites had one
core-input-watchno-tmux failure and threecore-heartbeatwriter-handoff failures; their relevant files are byte-identical toorigin/main, so they are not caused by this topic. git diff --checkandscripts/review-checks.shpassed. A synthetic/Users/reviewer/privatecontrol was rejected, proving the path scan fires. Added absolute paths are PID-scoped/tmptest fixtures only.
Worst-case disruption is test-only contamination from a leaked process-global resolver mock. Both changed regions restore the original in finally, and the harness confirmed restoration; no production path, schema, startup, bridge, or delivery behavior changes.
At review time the supplied current-head snapshot still had hosted jobs in progress. I could not inspect live CI under the no-network review scope, so required CI/CLA and two current-head maintainer approvals remain merge conditions.
Reviewed by Kewei's Codex automation.
What
Fixes a real, host-observable false-failure in
tests/runtime-health.test.pyintroduced by #4365.Before/after evidence
Before (this branch's HEAD reverted to the pre-fix version of just this file, via
git show <parent>:tests/runtime-health.test.py, run on this live host with a genuinely fresh core heartbeat):After (this PR's actual diff):
Why
#4365 (
fix(runtime-health): probe the socket the core launched on, not a guessed default) changed_core_running()to resolve its tmux socket via the new_tmux_socket()helper, which — whenSUTANDO_TMUX_SOCKETis unset — prefers the socketcore_heartbeat.pyrecorded in a fresh<workspace>/state/cores/<host>.alivefile, falling back to the module-levelTMUX_SOCKETconstant only when that record is absent, stale, or unreadable.tests/runtime-health.test.py's "exercise the real probes in-process" section (section 6) injects its "no session" precondition by patchingrh.TMUX_SOCKETdirectly. That was sufficient before #4365, when_core_running()read the constant directly. After #4365, on any host with a genuinely live core (a fresh.aliveheartbeat file — which is the normal, common case for anyone actually running this test from inside a live session)_tmux_socket()ignores the patched constant entirely, resolves the real socket, finds a real session, and the two "bogus socket" assertions fail against a truthfully-running core.I hit this directly: pulled #4365 into a live core's checkout, ran the full test suite as routine post-pull hygiene, and got 2 failures that reproduced identically before this fix and cleared after it, on the same host, same process.
Fix
Patch
rh._tmux_socketitself (the function), in addition to the existingrh.TMUX_SOCKETpatch (kept, since other code may still read the constant directly), and restore both in thefinallyblock.Testing
python3 tests/runtime-health.test.py— PASS (was 2 failing before this fix, on this exact host)git show <parent-sha>:tests/runtime-health.test.py, nevergit checkout), confirmed the same 2 failures reproduce identically, restored byte-identical, re-confirmed green.bash -n,git diff --check,scripts/review-checks.sh— all pass.Single concern: this only touches the test's mock setup, not
src/runtime-health.pyitself.