Skip to content

test: the mock remote server closes the descriptors it inherits at startup - #1156

Merged
fujibee merged 1 commit into
integration/terminal-driver-v1from
agdev-cc3-1107-mock-fd
Sep 12, 2026
Merged

test: the mock remote server closes the descriptors it inherits at startup#1156
fujibee merged 1 commit into
integration/terminal-driver-v1from
agdev-cc3-1107-mock-fd

Conversation

@fujibee

@fujibee fujibee commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Independent hygiene, not a fix for #1107.

The hazard

A helper that a test backgrounds and that runs until killed holds every descriptor it inherits for as long as it lives. Under a parallel bats run that includes the harness's own high pipes, and tests/helpers/mock_remote_server.py is exactly that shape — every mock-using test backgrounds it (test_remote, test_perf_harness, test_team_list, tests/perf/join-harness.sh) and closes only fd 3 by name (3>&-), which never reaches a high harness fd. #575 solved this class for the sync engine (scripts/lib/close-fds.sh); the mock was not covered. A survivor could hold a harness pipe open, which is a real hazard worth removing on its own.

The fix

  • mock_remote_server.py closes every descriptor at or above 3 before it opens the listen socket, mirroring scripts/lib/close-fds.sh (enumerate /dev/fd, fall back to a bounded range). 0/1/2 stay — the port is printed on stdout. A survivor now holds nothing the harness opened.
  • test_engine_inherited_fds.bats grows the matching regression, measured against a baseline the way the engine case is, and mutation-checked (it fails when the close is disabled).
  • test_team_list.bats reaps its mock in teardown, so a case that fails before its inline kill leaves no process (or port) behind.

Not #1107

The #1107 macOS shard cancellations are a wall-clock cap being reached by a still-progressing shard, not a descriptor-inheritance hang. Read as a time series, the hang-samples show new tests starting right up to the cut-off (the suite advances through test_terminal_registry → test_remote → … → test_codex_bridge_launcher), and the surviving mocks are all from an early window, gone before the cut-off. The workflow's own #848/#857 note warns that a shard passing tests up to the cap looks identical to a stuck one. #1107's cause is the suite having outgrown the partitioner's baseline; that is separate from this change, which stands as hygiene.

Verification

test_perf_harness.bats (9/9, curl paging through the mock), test_team_list.bats, and test_remote.bats --filter connect (60/60) green locally.

@fujibee
fujibee force-pushed the agdev-cc3-1107-mock-fd branch from 671cbf2 to 71c33a5 Compare September 11, 2026 16:53
@fujibee fujibee changed the title fix(test): the mock remote server closes inherited descriptors so it cannot hang a shard (#1107) test: the mock remote server closes the descriptors it inherits at startup Sep 11, 2026
…artup

A helper that a test backgrounds and that runs until killed holds every
descriptor it inherits for as long as it lives -- including, under a parallel
bats run, the harness's own high pipes. #575 fixed this class for the sync
engine (scripts/lib/close-fds.sh); the mock was not covered. It now closes
every descriptor at or above 3 before it opens the listen socket, so a survivor
holds nothing the harness opened; 0/1/2 stay (the port is printed on stdout).

This is HYGIENE, not a fix for the macOS shard cancellations tracked in #1107.
Reading the hang-samples as a time series shows the shard still starting new
tests right up to the cut-off: it is a wall-clock cap being reached by a
still-progressing shard (the workflow's own #848/#857 note), not a
descriptor-inheritance hang. Kept separate so the review and the ledger stay
accurate; the mock/fd was a bystander caught in a snapshot, not the cause.

test_engine_inherited_fds.bats grows the matching regression (baseline
comparison, mutation-checked); test_team_list.bats reaps its mock in teardown.
@fujibee
fujibee force-pushed the agdev-cc3-1107-mock-fd branch from 71c33a5 to 610345b Compare September 11, 2026 22:29
@fujibee
fujibee merged commit 33e10ae into integration/terminal-driver-v1 Sep 12, 2026
27 checks passed
@fujibee
fujibee deleted the agdev-cc3-1107-mock-fd branch September 12, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant