Skip to content

assess offline guard: allow socketpair's loopback connect on Windows (Fixes #5250) - #5253

Merged
squid-protocol merged 1 commit into
mainfrom
churn/5250-20261016T1251Z
Oct 16, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
churn/5250-20261016T1251Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Root cause

#5234's offline guard refuses every non-AF_UNIX connect. Windows has no native socket.socketpair; CPython emulates it with an AF_INET loopback listen + connect, so socket.socketpair() raised OfflineViolation under the guard. Run 38901093215: both test_assess.py guard tests failed on every Windows job (3.10, 3.12), identical traceback through socket.py socketpair -> csock.connect -> offline.guarded. Not a flake. Linux/macOS have native socketpair, so they passed.

Fix

offline.install() wraps socket.socketpair to set a thread-local exemption for its duration (_allow_local). Direct loopback connects, create_connection, getaddrinfo, sendto stay refused.

Tests

  • Existing two guard tests (fail on Windows before, pass now; only CI can confirm Windows).
  • New platform-independent test_the_guard_exempts_only_socketpair_loopback: loopback connect refused, allowed inside _allow_local, refused again after, socketpair() works.

Evidence

Local: guard tests pass; pr_gates --fast 6/6, --ratchets 8/8. No golden impact (no parsing change).

Sibling gaps

none (the existing docstring note on spawn-start workers on Windows/macOS lacking the guard is a separate #4726 follow-up).

Lessons for agents

A guard that wraps socket.connect also catches stdlib-internal loopback plumbing on Windows (socketpair); test socket guards on a Windows leg.

🤖 Generated with Claude Code

…rough (Fixes #5250)

Windows has no native socketpair; CPython builds one from an AF_INET loopback listen + connect, which the
guard refused, so two test_assess guard tests (and any socketpair user, e.g. asyncio) failed on every Windows job.
The guard now exempts the calling thread only for the duration of socket.socketpair; direct loopback and
network calls stay refused.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 16, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol marked this pull request as ready for review October 16, 2026 12:59
@squid-protocol
squid-protocol enabled auto-merge (squash) October 16, 2026 13:05
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol

Copy link
Copy Markdown
Owner Author

PR #5253 @ c95ee7c: 2 failed check(s)

== full-suite-matrix (windows-latest, 3.10, 2, 3, true, 25) (failure) -- real
https://github.com/squid-protocol/gitgalaxy/actions/runs/38904328517/job/116984061755
repro: python tests/tools/pr_gates.py --fast
failing tests: tests/tools/test_blocker_report.py::test_salt_file_created_once_and_never_written_to_reports
errors:
fail-on-cache-miss: false
E AssertionError: assert (b'z\x08\xc4L...x838\xd5\x80*' == b'z\x08\xc4L...x838\xd5\x80*'
tests\tools\test_blocker_report.py:132: AssertionError
FAILED tests/tools/test_blocker_report.py::test_salt_file_created_once_and_never_written_to_reports - AssertionError: assert (b'z\x08\xc4L...x838\xd5\x80*' == b'z\x08\xc4L...x838\xd5\x80*'
##[error]Process completed with exit code 1.
log tail:
SKIPPED [1] tests\tools\test_box_tools.py:80: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_box_tools.py:132: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_cache_keys.py:62: owner-protected (#4935): hashes pyproject.toml alone
SKIPPED [1] tests\tools\test_ci_retry.py:49: ci_retry.sh is a bash script for the Linux runners
SKIPPED [1] tests\tools\test_crucible_case.py:87: no cics-crucible checkout (CICS_CRUCIBLE_PATH)
SKIPPED [1] tests\tools\test_crucible_case.py:103: no cics-crucible checkout (CICS_CRUCIBLE_PATH)
SKIPPED [1] tests\tools\test_crucible_case.py:232: no cics-crucible checkout (CICS_CRUCIBLE_PATH)
SKIPPED [1] tests\tools\test_ctags_reader_qualify.py:35: ctags not on PATH
SKIPPED [1] tests\tools\test_timeouts_4904.py:32: could not import 'fcntl': No module named 'fcntl'
XFAIL tests/extraction/languages/test_dart.py::test_dart_class_start_xfail_invalid[var query = '''\nclass FakeClass {\n''';] - String/comment lookalikes lack AST block shielding
XFAIL tests/extraction/languages/test_dart.py::test_dart_func_start_xfail_invalid[/* \n void main() { \n /] - String/comment lookalikes lack AST block shielding
XFAIL tests/extraction/languages/test_dart.py::test_dart_dependency_capture_xfail_invalid[/
\n import 'package:foo/foo.dart'; \n /] - String/comment lookalikes lack AST block shielding
XFAIL tests/extraction/languages/test_jcl.py::test_jcl_class_start_invalid[//SYSIN DD \n//FAKE JOB 1\n/] - Known limitation: No block shielding for instream data in JCL
XPASS tests/extraction/languages/test_jcl.py::test_jcl_args_valid["//STEP1 EXEC PGM=PROG,PARM='THIS STRI"...len102-1d86da8b-"'THIS STRING CONTINUES "...len72-7c3fedb5] - Known limitation: Engine cannot parse JCL line con
XPASS tests/extraction/languages/test_jcl.py::test_jcl_dependency_invalid[//DD DATA \n INCLUDE MEMBER=NOPE \n/
] - Known limitation: No block shielding for instream data in JCL
FAILED tests/tools/test_blocker_report.py::test_salt_file_created_once_and_never_written_to_reports - AssertionError: assert (b'z\x08\xc4L...x838\xd5\x80*' == b'z\x08\xc4L...x838\xd5\x80*'
Full diff:
(b'z\x08\xc4L\x85\x9c\xf3u4\x02\x1a\xd4p\xa5%GP(/\xb4\xa0\xd6\xda\x901I?\x83'
b'8\xd5\x80*') and (33206 & 63) == 0)
+ where 33206 = os.stat_result(st_mode=33206, st_ino=1125899908226962, st_dev=742408122, st_nlink=1, st_uid=0, st_gid=0, st_size=66, st_atime=1792156279, st_mtime=1792156279, st_ctime=1792156279).st_mode
+ where os.stat_result(st_mode=33206, st_ino=1125899908226962, st_dev=742408122, st_nlink=1, st_uid=0, st_gid=0, st_size=66, st_atime=1792156279, st_mtime=1792156279, st_ctime=1792156279) = stat()
+ where stat = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/popen-gw1/test_salt_file_created_once_an0/private/salt').stat
1 failed, 6714 passed, 464 skipped, 4 xfailed, 2 xpassed, 4 subtests passed in 789.93s (0:13:09)
##[error]Process completed with exit code 1.
Post job cleanup.
[command]"C:\Program Files\Git\bin\git.exe" version
git version 2.56.0.windows.2
Temporarily overriding HOME='D:\a_temp\e6b12809-4f7a-4227-96a5-031d4014cbb1' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\gitgalaxy\gitgalaxy
Removing SSH command configuration
[command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp core.sshCommand
[command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :""
Removing HTTP extra header
[command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extrahe
Removing includeIf entries pointing to credentials config files
[command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp ^includeIf.gitdir:
[command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "git config --local --show-origin --name-only --get-regexp remote.origin.url"
Cleaning up orphan processes

== full-suite-matrix (windows-latest, 3.12, 2, 2, true, 25) (failure) -- real
https://github.com/squid-protocol/gitgalaxy/actions/runs/38904328517/job/116984061833
repro: python tests/tools/pr_gates.py --fast
failing tests: tests/tools/test_blocker_report.py::test_salt_file_created_once_and_never_written_to_reports
errors:
fail-on-cache-miss: false
tests\tools\test_blocker_report.py:132: AssertionError
FAILED tests/tools/test_blocker_report.py::test_salt_file_created_once_and_never_written_to_reports - assert (b'6m\xa4E\xb0...\xd6\x18U\x00' == b'6m\xa4E\xb0...\xd6\x18U\x00'
##[error]Process completed with exit code 1.
log tail:
SKIPPED [1] tests\tools\test_pin_requirements.py:94: uv executable not installed in this environment
SKIPPED [1] tests\tools\test_blocker_report.py:182: aws-mainframe-modernization-carddemo not checked out under GITGALAXY_MAINFRAME_CORPORA
SKIPPED [1] tests\tools\test_blocker_report.py:182: cics-genapp not checked out under GITGALAXY_MAINFRAME_CORPORA
SKIPPED [1] tests\tools\test_box_tools.py:41: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_box_tools.py:48: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_box_tools.py:80: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_box_tools.py:100: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_box_tools.py:123: the box tools are bash scripts (flock, /proc, kill) for the Linux box
SKIPPED [1] tests\tools\test_timeouts_4904.py:32: could not import 'fcntl': No module named 'fcntl'
SKIPPED [1] tests\tools\test_unicode_gauntlet_vs_treesitter.py:52: keyword-rosetta corpus not available
XFAIL tests/core_engine/test_aperture.py::test_aperture_embedded_hex_shield - Engine currently allows hex arrays if has_intent=True. Pending engine patch.
XFAIL tests/extraction/languages/test_dart.py::test_dart_func_start_xfail_invalid[/* \n void main() { \n */] - String/comment lookalikes lack AST block shielding
XFAIL tests/extraction/languages/test_dart.py::test_dart_dependency_capture_xfail_invalid[// import 'package:test/test.dart';] - String/comment lookalikes lack AST block shielding
XFAIL tests/extraction/languages/test_zig.py::test_zig_args_invalid[// fn (a: i32, b: i32)] - Known limitation: No block shielding for args inside comments
XPASS tests/extraction/languages/test_jcl.py::test_jcl_dependency_invalid['//STEP1 EXEC PGM=PROG1 THIS COMMENT CO'...len69-d3e393cd] - Known limitation: Inline comments aren't stripped before dependency capture
FAILED tests/tools/test_blocker_report.py::test_salt_file_created_once_and_never_written_to_reports - assert (b'6m\xa4E\xb0...\xd6\x18U\x00' == b'6m\xa4E\xb0...\xd6\x18U\x00'
Full diff:
(b'6m\xa4E\xb0\xd206\x91\x84\x7fS"h8\x1fL\xd3\xc3]\x83\x8e\x8d7\xe6\xb9O\x81'
b'\xd6\x18U\x00') and (33206 & 63) == 0)
+ where 33206 = os.stat_result(st_mode=33206, st_ino=281474978101745, st_dev=17594508763472084922, st_nlink=1, st_uid=0, st_gid=0, st_size=66, st_atime=1792156320, st_mtime=1792156320, st_ctime=1792156320).st_mode
+ where os.stat_result(st_mode=33206, st_ino=281474978101745, st_dev=17594508763472084922, st_nlink=1, st_uid=0, st_gid=0, st_size=66, st_atime=1792156320, st_mtime=1792156320, st_ctime=1792156320) = stat()
+ where stat = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/popen-gw0/test_salt_file_created_once_an0/private/salt').stat
1 failed, 10070 passed, 701 skipped, 4 xfailed, 1 xpassed, 1 warning, 9 subtests passed in 818.15s (0:13:38)
##[error]Process completed with exit code 1.
Post job cleanup.
[command]"C:\Program Files\Git\bin\git.exe" version
git version 2.56.0.windows.2
Temporarily overriding HOME='D:\a_temp\e0c809bf-1f88-4a89-80ea-bcc89f0604b7' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\gitgalaxy\gitgalaxy
Removing SSH command configuration
[command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp core.sshCommand
[command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :""
Removing HTTP extra header
[command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extrahe
Removing includeIf entries pointing to credentials config files
[command]"C:\Program Files\Git\bin\git.exe" config --local --name-only --get-regexp ^includeIf.gitdir:
[command]"C:\Program Files\Git\bin\git.exe" submodule foreach --recursive "git config --local --show-origin --name-only --get-regexp remote.origin.url"
Cleaning up orphan processes

@squid-protocol squid-protocol added the shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md label Oct 16, 2026
@squid-protocol
squid-protocol merged commit 722e889 into main Oct 16, 2026
83 of 85 checks passed
@squid-protocol
squid-protocol deleted the churn/5250-20261016T1251Z branch October 16, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant