Skip to content

fix(herdr): connect eventwait on long socket paths - #4

Merged
karanmrn merged 5 commits into
mainfrom
fm/fm-herdr-eventwait-socket-path
Sep 16, 2026
Merged

karanmrn merged 5 commits into
mainfrom
fm/fm-herdr-eventwait-socket-path

Conversation

@karanmrn

Copy link
Copy Markdown
Owner

Intent

Captain, 16 September 2026: "continue and complete the remaining tasks". Context: the no-mistakes document step on the fm-tests-red-on-main branch raised finding herdr-eventwait-long-socket-path. Firstmate approved it as a follow-up instead of expanding that task. bin/backends/herdr-workspace-move.py now connects to the Herdr control socket by basename (after chdir into the socket's directory) to stay under the 104-byte AF_UNIX path limit, but bin/backends/herdr-eventwait.py still calls sock.connect with the full path and exits 2 under a deep home.

What Changed

  • bin/backends/herdr-eventwait.py now splits the control socket path, changes into the socket directory, and connects by basename, so a Herdr session socket under a deep home no longer exceeds the ~104-byte AF_UNIX address limit and fails with exit 2.
  • The same script now requires an absolute <socket_path>, writes an explanatory message to stderr, and returns exit 2 for a relative path. The usage docstring records the rule, and the chdir comment in bin/backends/herdr-workspace-move.py is updated to give the same reason.
  • tests/fm-backend-herdr.test.sh adds two executed cases: one connects the reader to a throwaway listener on a path longer than 104 bytes and asserts @subscribed output, one asserts the relative-path refusal. The Python unit tests in tests/fm-backend-herdr-eventwait.test.py now pass an absolute socket path and patch os.chdir.

Risk Assessment

✅ Low: A four-line transport fix mirroring an already-shipped sibling, plus an explicitly authorized absolute-path guard, both covered by executed regression tests that fail before the fix and pass after it.

Testing

The configured test command had already passed as baseline, so this step focused on the socket-path surface itself. I stood up throwaway AF_UNIX listeners under directories deep enough to push the socket path to 137 and 141 bytes, then drove the reader directly and through its only production caller. The fixed reader connects, acks, and streams a projected event; the adapter turns that into the normalized blocked record and returns 0. The base-commit reader fails with exit 2 on the identical setup, which reproduces the reported defect and confirms the regression is genuine. The absolute-path guard rejects relative and dotted-relative paths with exit 2 and its stated rule, and absolute paths with no listener still exit 2 without a traceback. I also proved the regression actually guards the fix: with the connect line reverted, the runner-executed suite exits 1 on that test, and passes with the fix restored. This change is a CLI and shell surface with no rendered UI, so there is no screenshot or rendered HTML artifact; the CLI transcripts are the end-user-visible evidence. The worktree is clean and the reverted file was restored.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Reader subscribes and streams a pane status event over a socket path longer than the 104-byte AF_UNIX limit ✅ pass live python3 bin/backends/herdr-eventwait.py &lt;137-byte path&gt; 1.5 pane-1 against a real AF_UNIX listener: exit 0, stdout @subscribed then pane-1 ws-7 blocked claude; artifact eventwait-long-path-fixed…
The same deep socket path fails with exit 2 on the base commit, proving the reported defect ✅ pass live git show 514e48e:bin/backends/herdr-eventwait.py driven against the identical listener: exit 2, empty stdout, listener stuck at ready; artifact eventwait-long-path-prefix.txt
Supervision escalates end-to-end through fm_backend_herdr_wait_transition when the session socket path is 141 bytes ✅ pass live . bin/backends/herdr.sh; fm_backend_herdr_wait_transition demo 3 &lt;state&gt; demo:pane-1 with a fake herdr CLI reporting the deep socket_path and a real listener: prints pane-1 ws-7 blocked claude,…
The same adapter call fails closed to polling (exit 2) when the base-commit reader is used ✅ pass live Same fixture with FM_BACKEND_HERDR_EVENT_READER pointed at the base-commit reader: empty record, wait_transition exit: 2; artifact eventwait-adapter-deep-path-prefix.txt
A relative socket path is refused with exit 2 and a message naming the connect rule ✅ pass live herdr-eventwait.py herdr.sock 1 pane-1 and ./sub/herdr.sock: both exit 2 with socket path must be absolute; the control socket is connected by basename from its own directory; artifact eventwait…
An absolute path with a missing directory or no listener still exits 2 instead of crashing after the chdir ✅ pass live /nonexistent-dir-xyz/herdr.sock and /tmp/.../absent.sock: exit 2, no traceback; artifact eventwait-path-guards.txt
The regression test runs in the suite the runner executes and fails before the fix ✅ pass live bash tests/fm-backend-herdr.test.sh exits 0 with both new ok - lines; with sock.connect reverted the suite exits 1 on not ok - eventwait could not connect over a long socket path; artifact eve…
Evidence: Reader connects and streams over a 137-byte socket path (fixed)

Source: Reader connects and streams over a 137-byte socket path (fixed)

socket path bytes: 137 exit status: 0 stdout: @subscribed pane-1 ws-7 blocked claude

== FIXED reader (target commit) on deep socket path ==
socket path bytes: 137
$ herdr-eventwait.py <104+ byte socket path> 1.5 pane-1
exit status: 0
stdout:
  @subscribed
  pane-1	ws-7	blocked	claude
stderr:
listener saw:
  ready
  request={"id": "fm-eventwait", "method": "events.subscribe", "params": {"subscriptions": [{"type": "pane.agent_status_changed", "pane_id": "pane-1"}]}}
Evidence: Same socket path with the base-commit reader: exit 2, never connects

Source: Same socket path with the base-commit reader: exit 2, never connects

== PRE-FIX reader (base commit 514e48e) on same deep socket path == socket path bytes: 137 exit status: 2 stdout: listener saw: ready

== PRE-FIX reader (base commit 514e48e) on same deep socket path ==
socket path bytes: 137
$ herdr-eventwait.py <104+ byte socket path> 1.5 pane-1
exit status: 2
stdout:
stderr:
listener saw:
  ready
Evidence: Production adapter escalates over a 141-byte socket path

Source: Production adapter escalates over a 141-byte socket path

socket path bytes: 141 adapter stdout (normalized escalation record): pane-1 ws-7 blocked claude wait_transition exit: 0

== production adapter: fm_backend_herdr_wait_transition over a deep socket path ==
socket path bytes: 141
adapter stdout (normalized escalation record):
  pane-1	ws-7		blocked	claude
  wait_transition exit: 0
adapter stderr:
escalation markers written:
Evidence: Production adapter with the base-commit reader falls back: exit 2

Source: Production adapter with the base-commit reader falls back: exit 2

socket path bytes: 141 adapter stdout (normalized escalation record): wait_transition exit: 2

== production adapter with PRE-FIX reader (base 514e48e) over a deep socket path ==
socket path bytes: 141
adapter stdout (normalized escalation record):
  
  wait_transition exit: 2
adapter stderr:
escalation markers written:
Evidence: Absolute-path guard transcript

Source: Absolute-path guard transcript

$ herdr-eventwait.py herdr.sock 1 pane-1 exit status: 2 output: herdr-eventwait.py: socket path must be absolute; the control socket is connected by basename from its own directory

== guard: relative socket path ==
$ cd /tmp/fm-eventwait-drive && herdr-eventwait.py herdr.sock 1 pane-1
exit status: 2
output: herdr-eventwait.py: socket path must be absolute; the control socket is connected by basename from its own directory

== guard: relative dotted path ==
$ herdr-eventwait.py ./sub/herdr.sock 1 pane-1
exit status: 2
output: herdr-eventwait.py: socket path must be absolute; the control socket is connected by basename from its own directory

== guard: absolute path, missing directory ==
$ herdr-eventwait.py /nonexistent-dir-xyz/herdr.sock 1 pane-1
exit status: 2
output: <none>

== guard: absolute path, directory exists, no listener ==
$ herdr-eventwait.py /tmp/fm-eventwait-drive/absent.sock 1 pane-1
exit status: 2
output: <none>
cwd after all runs: /tmp/fm-eventwait-drive
Evidence: Regression red before the fix, green after, in the executed suite

Source: Regression red before the fix, green after, in the executed suite

--- WITH the fix (target 671129f), suite exit 0 --- ok - herdr-eventwait.py connects to a throwaway AF_UNIX listener beyond the 104-byte path limit ok - herdr-eventwait.py refuses a relative socket path --- WITH connect reverted to sock.connect(sock_path), suite exit 1 --- AssertionError: eventwait failed for a long socket path: rc=2 stdout='' stderr='' not ok - eventwait could not connect over a long socket path

tests/fm-backend-herdr.test.sh - the runner-executed suite (bin/fm-test-run.sh globs tests/*.test.sh)

--- WITH the fix (target 671129f), suite exit 0 ---
190:ok - herdr-eventwait.py connects to a throwaway AF_UNIX listener beyond the 104-byte path limit
191:ok - herdr-eventwait.py refuses a relative socket path

--- WITH bin/backends/herdr-eventwait.py connect reverted to sock.connect(sock_path), suite exit 1 ---
Traceback (most recent call last):
  File "<stdin>", line 66, in <module>
AssertionError: eventwait failed for a long socket path: rc=2 stdout='' stderr=''
not ok - eventwait could not connect over a long socket path

(file restored afterwards; git status --porcelain is empty)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • 🚨 tests/fm-backend-herdr-eventwait.test.py:94 - Commit 33e5f24 deleted test_eventwait_connects_to_long_socket_path from tests/fm-backend-herdr.test.sh (a file the runner executes) and re-added it as test_connects_to_a_socket_path_beyond_the_af_unix_limit in tests/fm-backend-herdr-eventwait.test.py, which nothing executes. bin/fm-test-run.sh:996-1003 (all_repo_tests) globs only tests/*.test.sh; run_script_bounded runs each match with bash. bin/fm-test-run.sh:1134 only maps a CHANGE to the .py file onto the real-herdr-gated and backend-dispatch families, so editing it selects other suites and never itself. No .test.sh, no .github/workflows/*.yml, and no other script invokes the file or unittest. Concrete sequence: revert bin/backends/herdr-eventwait.py:103 to sock.connect(sock_path), run any lane or the whole suite - every lane still passes, because the only test that connects over a >104-byte path is never loaded. The new absolute-path guard test (line 88) is unexecuted for the same reason. Relocation is also the component the change did not need: the intent requires the connect fix plus a regression that fails before it, not a change of test home, and review round 2 recorded that placement move as declined. Smallest honest remedy is to remove the relocation - restore the test function and its entry in the run list at the end of tests/fm-backend-herdr.test.sh, and drop the duplicated copy from the .py file. Wiring the .py file into bin/fm-test-run.sh instead would add new runner plumbing plus coverage-guard and lane-composition semantics, so that path extends the change and needs the author's approval.

🔧 Fix applied.
1 info still open:

  • ℹ️ bin/backends/herdr-eventwait.py:81 - The new absolute-path diagnostic writes to stderr, but the only production caller discards it: bin/backends/herdr.sh:3422 spawns the reader as &#34;${reader[@]}&#34; &#34;$sock&#34; &#34;$timeout&#34; &#34;${pane_ids[@]}&#34; &gt; &#34;$fifo&#34; 2&gt;/dev/null &amp;. So in production a relative socket path yields exit 2 and a silent fallback to polling, identical to every other reader failure; only tests observe the text. Behavior is correct and matches the captain decision that required the message and the exit-2 rule, so no change is needed - noting it so the message is not mistaken for an operator-visible signal.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Reader subscribes and streams a pane status event over a socket path longer than the 104-byte AF_UNIX limit ✅ pass live python3 bin/backends/herdr-eventwait.py &lt;137-byte path&gt; 1.5 pane-1 against a real AF_UNIX listener: exit 0, stdout @subscribed then pane-1 ws-7 blocked claude; artifact eventwait-long-path-fixed…
The same deep socket path fails with exit 2 on the base commit, proving the reported defect ✅ pass live git show 514e48e:bin/backends/herdr-eventwait.py driven against the identical listener: exit 2, empty stdout, listener stuck at ready; artifact eventwait-long-path-prefix.txt
Supervision escalates end-to-end through fm_backend_herdr_wait_transition when the session socket path is 141 bytes ✅ pass live . bin/backends/herdr.sh; fm_backend_herdr_wait_transition demo 3 &lt;state&gt; demo:pane-1 with a fake herdr CLI reporting the deep socket_path and a real listener: prints pane-1 ws-7 blocked claude,…
The same adapter call fails closed to polling (exit 2) when the base-commit reader is used ✅ pass live Same fixture with FM_BACKEND_HERDR_EVENT_READER pointed at the base-commit reader: empty record, wait_transition exit: 2; artifact eventwait-adapter-deep-path-prefix.txt
A relative socket path is refused with exit 2 and a message naming the connect rule ✅ pass live herdr-eventwait.py herdr.sock 1 pane-1 and ./sub/herdr.sock: both exit 2 with socket path must be absolute; the control socket is connected by basename from its own directory; artifact eventwait…
An absolute path with a missing directory or no listener still exits 2 instead of crashing after the chdir ✅ pass live /nonexistent-dir-xyz/herdr.sock and /tmp/.../absent.sock: exit 2, no traceback; artifact eventwait-path-guards.txt
The regression test runs in the suite the runner executes and fails before the fix ✅ pass live bash tests/fm-backend-herdr.test.sh exits 0 with both new ok - lines; with sock.connect reverted the suite exits 1 on not ok - eventwait could not connect over a long socket path; artifact eve…
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated
  • bash tests/fm-backend-herdr.test.sh (suite exit 0; includes test_eventwait_connects_to_long_socket_path and test_eventwait_rejects_a_relative_socket_path)
  • bash tests/fm-backend-herdr.test.sh with sock.connect(socket_name) reverted to sock.connect(sock_path) (suite exit 1, not ok - eventwait could not connect over a long socket path; file restored, git status --porcelain empty)
  • Manual live drive: python3 bin/backends/herdr-eventwait.py &lt;137-byte socket path&gt; 1.5 pane-1 against a real AF_UNIX listener that acks subscription_started and emits one pane.agent_status_changed
  • Manual live drive of the same listener with the base-commit reader git show 514e48e:bin/backends/herdr-eventwait.py
  • Manual live drive of the production caller: . bin/backends/herdr.sh; fm_backend_herdr_wait_transition demo 3 &lt;state&gt; demo:pane-1 with a fake herdr CLI reporting a 141-byte socket_path, once with the target reader and once with FM_BACKEND_HERDR_EVENT_READER pointed at the base-commit reader
  • Guard drives: herdr-eventwait.py herdr.sock 1 pane-1, ./sub/herdr.sock, /nonexistent-dir-xyz/herdr.sock, /tmp/.../absent.sock
  • python3 tests/fm-backend-herdr-eventwait.test.py (5 tests OK)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@karanmrn
karanmrn merged commit d36931b into main Sep 16, 2026
0 of 14 checks passed
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